← All lessons
0253

Precision, Recall & the Confusion Matrix

A disease test that says healthy to everyone scores 90% accuracy if only 10% of patients are sick — and catches nobody. Whenever classes are imbalanced, accuracy lies, so classifiers are judged on the confusion matrix instead: the four-way count of caught cases, missed cases, false alarms, and correct all-clears. From it come the two numbers that matter: precision (of everything flagged, how much was real) and recall (of everything real, how much was caught). They pull against each other, and the threshold slider is the lever — where to set it is a question about costs, not math.

Drag the threshold. Watch the four confusion-matrix cells trade against each other, and find the settings where accuracy stays impressively high while recall — the number that actually matters here — collapses.

Screening test: 100 patients, only 10 actually sick.

Flag as sick if score 50%
9sick, flagged (caught)
1sick, missed!
14healthy, false alarm
76healthy, cleared
Accuracy
85%of all 100, how many labeled correctly
Precision
39%of those flagged, how many were really sick
Recall
90%of the 10 sick, how many were caught

The threshold trades precision against recall. Which way to lean is not a math question: missing a cancer costs more than a false alarm, so screening leans toward recall.

Check yourself

For a cancer screening test, would you rather have 90% precision with 60% recall, or 60% precision with 90% recall — and what does each error cost?

Go deeper (free): Google ML Crash Course — Classification metrics

Next: Bias & Fairness