The Confusion Matrix is a nice way to summarize the results from a binary classification problem. While scikit-learn offers a nice method to compute this matrix (for multiclass classification, as well), I’m not aware of a built-in method that shows the relevant statistics from the confusion matrix. Often the matrix is just shown, color-coded according to entry values.

I wrote a little script for displaying the confusion matrix (as computed by scikit-learn), using matplotlib. The results look like this:

Here’s the function for generating the confusion matrix:

… and here’s the code that generates the above example: