confusion matrix
/ kun-FYOO-zhun MAY-triks /
A confusion matrix is the honest, full breakdown of how a classifier did — a little table that sorts every prediction into one of four bins. Down one axis is the truth (was it actually yes or no), across the other is the model's guess (did it say yes or no). The four cells are: true positives (said yes, was yes), true negatives (said no, was no), false positives (said yes, was no — a false alarm), and false negatives (said no, was yes — a miss).
It is called a confusion matrix because it shows exactly where the model gets confused: which real things it mistakes for which other things. Almost every other metric — accuracy, precision, recall, F1 — is just a different arithmetic squeezed out of these four numbers. The matrix is the raw truth; the metrics are summaries of it.
Its great virtue is that it refuses to hide the kind of mistake being made. Two models can share the same accuracy yet have wildly different matrices — one trigger-happy with false alarms, one too timid and missing real cases. Since false alarms and misses often cost very different amounts in the real world, looking at the full matrix before settling on a single score is one of the most useful habits in evaluation. For more than two classes it grows into a larger grid, one row and column per class.
100 emails, 30 truly spam. The filter's matrix: true positives 25, false negatives 5 (spam that got through), false positives 8 (real mail wrongly trashed), true negatives 62. From these: precision 25/33 ≈ 76%, recall 25/30 ≈ 83%, accuracy 87/100 = 87%.
All the headline metrics are just arithmetic on the matrix's four cells.
Conventions for which axis is rows vs columns differ between textbooks and software, so always check the labels before reading someone's matrix — a transposed matrix swaps false positives and false negatives, quietly inverting your conclusions.