Confusion Matrix
The 2x2 table from which every classification metric flows.
When a model predicts categories, every prediction falls into one of four buckets based on whether the model was right, and what it guessed.
The 2x2 Structure
Organising these four buckets into a grid creates the confusion matrix. By convention, rows represent the model's predictions and columns represent the actual ground truth.
Extracting the Metrics
Nearly every classification metric is built from this table. Precision asks: "Of the ones we flagged, how many were right?" Recall asks: "Of the real targets, how many did we find?"
Where It Breaks
On imbalanced data, accuracy hides total failure. A model that predicts "legitimate" for every transaction can be 99% accurate while missing 100% of the fraud. The confusion matrix exposes this immediately.
The Quick Version
- Four Outcomes: True Positive, False Positive, True Negative, False Negative.
- The Table: Rows are predictions, columns are reality.
- Metrics: Precision and recall both rely on True Positives but divide by different totals.
- Failure: Accuracy alone can be deeply misleading, especially with rare events.