What is a confusion matrix and what four quantities does it report?
The short answer
A confusion matrix tallies predictions against ground truth in a 2x2 table: true positives, true negatives, false positives, and false negatives. From those four cells every classification metric — accuracy, precision, recall, F1, specificity — can be derived. It exposes *which kind* of error a model makes, not just how often it errs.
How to think about it
State the four cells, derive the key rates, then show why raw accuracy alone hides the breakdown that actually matters.
The four cells
For a binary classifier predicting Positive (P) or Negative (N):
| Predicted P | Predicted N | |
|---|---|---|
| Actual P | True Positive (TP) | False Negative (FN) |
| Actual N | False Positive (FP) | True Negative (TN) |
- TP — model said positive, and it was.
- TN — model said negative, and it was.
- FP — model said positive, but it was negative. Also called a Type I error.
- FN — model said negative, but it was positive. Also called a Type II error.
Key rates derived from the matrix
- Accuracy =
(TP + TN) / (TP + TN + FP + FN) - Precision =
TP / (TP + FP)— of all positive predictions, how many were right? - Recall (Sensitivity) =
TP / (TP + FN)— of all actual positives, how many did we catch? - Specificity =
TN / (TN + FP)— of all actual negatives, how many did we correctly dismiss?
Why it matters beyond accuracy
A model that predicts “no fraud” for every transaction achieves 99.9% accuracy on a 0.1% fraud dataset — the confusion matrix exposes that TP = 0, FN = all positives.