A Confusion Matrix from Four Counts

A binary confusion matrix compares predictions with known labels by counting true positives, false positives, false negatives, and true negatives.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a test set
  2. Label rows and columns
  3. Name both axes before calculating a metric
  4. Verify marginal totals and tested label

Trace a test set

If ten items are truly positive and six are predicted positive correctly, four are false negatives. If two of the negative items are marked positive, those are false positives. Classification targets define which label is positive.

Label rows and columns

Matrix displays can put actual labels on different axes. Include explicit axis titles. Table context ensures the numbers keep their meaning in another view.[1][2]

Name both axes before calculating a metric

Five genuine positive examples and seven negatives produce counts three true positives, two false negatives, one false positive and six true negatives. Actual positives are the sum of true positives and false negatives, while predicted positives use false positives. See precision among predicted positives.

Rows actual, columns predicted
                 positive  negative
Actual positive     3         2
Actual negative     1         6

Verify marginal totals and tested label

Row totals five and seven match the fixture. Reversing positive class changes the meanings of counts. Display the axis names and positive label to make every metric reproducible.

References

  1. Gareth James et al., An Introduction to Statistical Learning ↩
  2. scikit-learn Developers, Metrics and Scoring: Quantifying the Quality of Predictions ↩