01The confusion matrix and everything derived from it
Four cells: true positives, false positives, false negatives, true negatives. Every classification metric worth knowing is a ratio of these, so memorise the matrix and derive the rest rather than memorising formulas.
Precision = TP / (TP + FP) — of everything you flagged, how much was real. It's the metric to optimise when a false positive is expensive: blocking a legitimate payment, quarantining a real email, telling a healthy patient they're ill.
Recall (sensitivity) = TP / (TP + FN) — of everything real, how much you caught. Optimise it when a miss is expensive: an undetected tumour, a missed fraudulent transfer, a security breach that goes unflagged.
F1 is their harmonic mean, which punishes imbalance between them — 0.9 and 0.1 gives F1 of 0.18, not 0.5. It's a reasonable single number when the two errors cost about the same, and a poor one when they don't. If a false negative costs ten times a false positive, say so and use a weighted Fβ or an explicit cost function instead of pretending F1 captures it.
Precision = TP/(TP+FP) · Recall = TP/(TP+FN)
Of what you flagged, how much was real · of what was real, how much you flagged.
F1 = 2PR/(P+R)
Harmonic mean — heavily penalises a lopsided pair. Only fair when both error types cost the same.
Try it
Threshold, prevalence, and the metrics
Drag the threshold. Then set prevalence to 1% and watch ROC-AUC refuse to notice what precision is doing.