Confusion matrix
In one sentence A confusion matrix is a small table showing how many predictions were right and exactly which kinds of mistakes the model made.
Updated
A confusion matrix is a table that counts every prediction by what the model said versus what was actually true.
A single score hides the story. A confusion matrix is the itemised bill: it shows not only how often the model was wrong, but in which direction. For a yes/no problem it has four cells.
actually spam actually not spam
predicted spam 412 9 ← 9 real emails lost
predicted not spam 31 548 ← 31 spam got throughThe diagonal (412 and 548) is everything the model got right. The other two cells are the two different mistakes: false positives (top right) and false negatives (bottom left). Every headline metric is a ratio of these four numbers — accuracy, precision and recall each slice them differently.
With more than two classes, the matrix grows, and its off-diagonal cells become a diagnosis tool. If a digit classifier keeps confusing 4 with 9, one bright off-diagonal cell says so instantly. That tells you what extra training data to collect, which no single number can.
Where to go next
- Full lesson: Model evaluation
- Related terms: precision, recall, accuracy, f1-score