Suppose a spam filter checks 1,000 emails. A single accuracy number, say 95%, hides the important detail. The confusion matrix shows it in four boxes: spam correctly caught (true positives), real mail wrongly sent to spam (false positives), spam that slipped into the inbox (false negatives) and real mail correctly delivered (true negatives). For most people a lost job offer in the spam folder is far worse than one extra junk email, and only the matrix tells you which mistake the filter makes.
Most classification metrics are just ratios of these boxes. Precision is true positives divided by everything flagged; recall is true positives divided by everything that should have been flagged; the F1 score combines the two. Changing the decision threshold moves examples between boxes, which is what the ROC curve and AUC summarize. For problems with more than two classes, the matrix grows to one row and column per class, and off-diagonal cells reveal which classes the model mixes up, for example “cat” mistaken for “fox.”
It’s the natural first view for any yes/no system, whether a fraud model, a medical test or an LLM-based content filter or guardrail, and it’s essential for imbalanced datasets, where accuracy is misleading. The two error types are covered in false positives and false negatives.
Sources
- Google Machine Learning Crash Course: Thresholds and the confusion matrix — Lays out the 2x2 grid of true positives, false positives, false negatives and true negatives with a spam example, and shows how changing the threshold moves counts between cells; checked October 24, 2026.
- scikit-learn: Confusion matrix — Documents confusion matrices for evaluating classifiers, including multiclass and normalized versions; checked October 24, 2026.