A confusion matrix is a table that counts how a classification model’s predictions compare with the true labels. For binary classification, its rows contain true labels and its columns contain predicted labels. section 7.6
The four cells in a binary confusion matrix distinguish correct predictions from two kinds of error:
- True positive: a positive case predicted as positive. section 7.6
- True negative: a negative case predicted as negative. section 7.6
- False positive: a negative case predicted as positive. section 7.6
- False negative: a positive case predicted as negative. section 7.6
A medical diagnosis example
Suppose a model diagnoses every patient as healthy. Among 1,000 patients, it produces 990 true negatives, 10 false negatives, and no true positives or false positives. The matrix exposes the dangerous pattern: every sick patient is missed, even though the model may appear accurate because most patients are healthy. section 7.6
Table 7.1 The confusion matrix helps us count how many times each class is predicted correctly and how many times each class is confused with a different class. In this matrix, the rows represent the label, and the columns represent the prediction. The elements in the diagonal are classified correctly, and the elements off the diagonal are not.
|
Person’s condition
|
Predicted positive
|
Predicted negative
|
|
Positive
|
Number of true positives
|
Number of false negatives
|
|
Negative
|
Number of false positives
|
Number of true negatives
|
Use the matrix diagram to see how rows represent actual conditions, columns represent predictions, diagonal cells represent correct classifications, and off-diagonal cells represent confusion. section 7.6















