The four outcomes: TP, FP, FN, TN
A confusion matrix for binary classification is a 2 by 2 table counting four outcomes. True Positives (TP): the model predicted positive and the actual label is positive (correct). True Negatives (TN): predicted negative, actual negative (correct). False Positives (FP): predicted positive, actual negative (incorrect; a false alarm). False Negatives (FN): predicted negative, actual positive (incorrect; a miss).
The matrix reveals class imbalance effects. A dataset with 99% negatives can achieve 99% accuracy by always predicting negative, yet the model is useless. The confusion matrix exposes this: it would show zero TP and zero FP, revealing that the positive class was never recognized.
Deriving metrics from the matrix
Common metrics derive from these four cells. Precision = TP / (TP + FP) answers 'of predictions of positive, how many were correct?' Recall (or sensitivity) = TP / (TP + FN) answers 'of actual positives, how many did we find?' The F1-score is the harmonic mean of precision and recall, balancing both.
Different domains prioritize different metrics. Medical diagnosis prioritizes recall (miss no true cases, even if some false alarms). Spam filtering prioritizes precision (avoid false positives, even if some spam slips through). The confusion matrix lets you compute all these metrics and choose the one matching your cost structure. Accuracy alone is insufficient; always examine the full matrix.