← Lessons

quiz vs the machine

Gold1340

Machine Learning

The Confusion Matrix In Depth

The four count table every classification metric is built from.

5 min read · core · beat Gold to climb

The foundation table

Almost every classification metric descends from one small table, the confusion matrix. For binary problems it has four counts that tally how predictions line up with truth.

The four cells

  • True positives are positives correctly flagged.
  • True negatives are negatives correctly cleared.
  • False positives are negatives wrongly flagged, also called type one errors.
  • False negatives are positives wrongly missed, also called type two errors.

Metrics from the cells

  • Precision is true positives over all flagged positives.
  • Recall is true positives over all actual positives.
  • Specificity is true negatives over all actual negatives.
  • Accuracy is the correct cells over the total.

Reading the full matrix tells you not just how often the model errs but which kind of error it makes, which a single score can never reveal.

Key idea

The confusion matrix tallies true and false positives and negatives. Nearly every classification metric is a ratio of its cells, and reading the whole table reveals which mistakes the model favors.

Check yourself

Answer to earn rating on the learn ladder.

1. A false negative is best described as what?

2. Recall is computed as which ratio?