Skip to content
AI360Xpert
Core ML
Visual explainer

Confusion Matrix

The 2x2 table from which every classification metric flows.

Two classes, four outcomes: TP, FP, TN, FN defined visually
Two classes, four outcomes: TP, FP, TN, FN defined visually

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

The 2x2 table and how to read it left-to-right
The 2x2 table and how to read it left-to-right

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

Precision and recall derived from the same four cells
Precision and recall derived from the same four cells

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

The failure: a 99% accurate model that misses every rare case
The failure: a 99% accurate model that misses every rare case

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.

What to Read Next