Confusion Matrix

A confusion matrix is a table used to summarize and assess the success of a classification model by comparing its predicted labels against actual ground truth labels. It provides a detailed breakdown of how many instances the model classified correctly and, crucially, which specific classes it confused with others.

1. Structure and Building a Confusion Matrix

In a binary classification problem (where there are two classes, often designated as positive and negative), the confusion matrix is a 2x2 table. While conventions can vary slightly, most common implementations (such as scikit-learn) use rows to represent actual classes and columns to represent predicted classes. (Note: some sources reverse this, using columns for ground truth).

Pasted image 20260319021025.png

The matrix is built by counting model outcomes in four categories:

For multiclass classification, the matrix expands to a K×K grid for K classes. For example, in a 10-digit classification task, the matrix would be 10x10, with the main diagonal representing correctly identified digits.

2. How to Interpret the Matrix

Powered by Forestry.md