liveBook · Manning

Confusion matrix

As explained in Deep Learning with PyTorch, Second Edition

A 2D breakdown of classification outcomes into true/false positives/negatives used to analyze model predictions.

A confusion matrix organizes binary classification results into four outcomes: true positives, false positives, true negatives, and false negatives. It exposes mistakes that overall accuracy can hide when classes are imbalanced. section 14.0 section 14.3

The four outcomes come from comparing two decisions: the human-provided label and the model’s predicted value against a classification threshold. Crossing those two boundaries divides samples into four quadrants. section 14.3

Read the quadrants as follows:

  • True positive: the model predicts the event of interest and the label agrees. section 14.3
  • False positive: the model predicts the event of interest, but the label does not. section 14.3
  • True negative: the model rejects the event of interest and the label agrees. section 14.3
  • False negative: the model rejects the event of interest even though the label identifies it. section 14.3

A guard-dog analogy

Imagine a dog deciding whether to bark at a burglar. The human label identifies whether each visitor is actually a burglar; the dog’s bark-worthiness score is compared with a barking threshold. Correct and incorrect barking decisions populate the four quadrants. section 14.3

Figure 14.4 Cats, birds, rodents, and robbers make up our four classification quadrants. They are separated by a human label and the dog classification threshold.
figure

Use the quadrant diagram to see how human labels and model thresholds separate true and false positives and negatives. section 14.3

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Defines four outcome quadrants through labels and thresholds, then stops short of detailed metric formulas.
Examples
Uses lung-nodule classification and a guard-dog scenario involving burglars, harmless animals, and barking thresholds.
What it assumes
Assumes binary labels and predictions while establishing the label-versus-threshold comparison from basic examples.
What you can do after
Evaluate classification errors by separating correct predictions from false alarms and missed positive cases.
How it connects
Connects true and false outcomes to precision, recall, F1 score, classification thresholds, and imbalanced data.

Also explained in

Compare how 14 books explain confusion matrix →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with PyTorch, Second Edition. The section links point to the parts of the book it draws on.