Precision, Recall & F1
Precision, Recall & F1 — Trade off catching positives against being right about them.
Precision asks “when I say positive, am I right?” Recall asks “did I catch all the positives?” They pull against each other, and F1 balances the two.
One-sided! Chasing precision alone crashes recall — the model ignores most positives.
- Swept so far
- Not yet reached
- No-skill baseline
- Operating point
Precision, recall and F1.0 against the threshold (click to jump)
- Precision
- Recall
- F1.0
Precision / recall controls
The idea in plain words
Precision asks “when I say positive, am I right?” Recall asks “did I catch all the positives?” They pull against each other: lower the threshold to catch more (higher recall) and you let in more false alarms (lower precision).
F1 balances the two into one number. On imbalanced data, watch precision collapse even as accuracy looks fine — which is why the confusion matrix underneath matters.
Now, the math
Precision, recall, and their harmonic mean F1:
- precision — correctness of positive predictions.
- recall — coverage of the actual positives.
- harmonic mean — high only when both are high.
▸ Show the derivation
The harmonic mean punishes imbalance between P and R far more than an arithmetic mean would, so F1 peaks near where the two gauges cross. Which metric to optimize depends on the cost of a false alarm versus a miss — the theme of the decision threshold.
Trace it by hand
Ten scored predictions at threshold 0.5 (score at or above 0.5 predicts positive). The 5 actual positives scored 0.9, 0.8, 0.6, 0.4, 0.2; the 5 actual negatives scored 0.7, 0.55, 0.35, 0.25, 0.1. Counts verified with the site's threshold engine.
Count the confusion cells
Positives at 0.9, 0.8, 0.6 clear the bar (TP); 0.4 and 0.2 are missed (FN). Negatives at 0.7 and 0.55 sneak over it (FP).
Precision: when it says positive, is it right?
Of the 5 points flagged positive, 3 really were.
Recall: did it catch all the positives?
Of the 5 actual positives, 3 were caught.
Combine into F1
When P and R are equal, their harmonic mean equals both. The imbalanced cases are where F1 bites.
What just happened: At threshold 0.5 this classifier is perfectly balanced: precision 0.6, recall 0.6, F1 0.6. The tension only appears when the threshold moves — the decision threshold page re-runs these exact ten predictions at 0.3 and 0.7 and watches P and R trade places.
Now Break It
Try this: Optimizing precision alone lets recall collapse — the model only predicts the easiest cases.
Control: Threshold slider (push to extreme)
What happens: One-sided! Chasing precision alone crashes recall — the model ignores most positives.
Where precision, recall & f1 is used
Precision and recall separate two distinct questions that accuracy blurs together. Precision asks, of everything the model flagged as positive, how many were actually positive, so it measures how much you can trust a positive prediction. Recall asks, of all the true positives that exist, how many did the model catch, so it measures coverage. In fraud detection a bank tuning for high recall wants to catch as many fraudulent transactions as possible even at the cost of reviewing some legitimate ones, while a spam filter often prioritizes precision so genuine email is rarely lost. The F1 score is the harmonic mean of the two, giving a single balanced number that punishes a model that sacrifices one to inflate the other.
A key misconception is treating precision and recall as independent goals you can maximize at once; usually they trade off. Lowering the decision threshold catches more positives and raises recall but tends to lower precision as more false alarms slip in, and raising the threshold does the reverse. Reporting only one is misleading: a model that flags everything as positive has perfect recall but terrible precision. Another pitfall is defaulting to F1 when the two errors have very different costs; F1 weights precision and recall equally, so if missing a positive is far worse than a false alarm, a weighted F-beta score or an explicit cost analysis reflects your priorities better.
Frequently asked questions
What is the difference between precision and recall?
What is the F1 score and when should I use it?
Why does improving recall often hurt precision?
When should I prioritize precision over recall, or vice versa?
Why not just use accuracy instead of precision and recall?
Written & reviewed by the ML Visualization team · Last updated .