← Measures

Precision, Recall and F1 Score

Two ways of being wrong, measured separately, and one number that trades them off. The standard answer to accuracy's blind spot.

At a glance

Full name Precision, recall, and their harmonic mean, the F1 score
What it measures How many flagged items were actually relevant (precision), and how many of the relevant items got flagged (recall)
Formula Precision = TP ÷ (TP + FP). Recall = TP ÷ (TP + FN). F1 = 2 × (Precision × Recall) ÷ (Precision + Recall)
Typical range 0 to 1 for each
Used for Any classification or detection task where false positives and false negatives have different costs
Best used for Imbalanced classes. Deciding where to set a model’s threshold
Pair with A confusion matrix, and whichever of precision or recall matters more for the specific decision

Where accuracy collapses two different kinds of mistake into one number, precision and recall keep them apart. Precision asks: of everything the model flagged, how much was right? Recall asks: of everything that should have been flagged, how much did the model catch? A model can be excellent on one and poor on the other, and knowing which is which tells you what the model is actually doing.

What it is and how it’s computed

Start from four counts: true positives (TP, correctly flagged), false positives (FP, wrongly flagged), false negatives (FN, missed), and true negatives (correctly left alone). Precision is TP divided by everything the model flagged (TP + FP). Recall is TP divided by everything that should have been flagged (TP + FN). F1 is the harmonic mean of the two, which punishes a model more than a simple average would if either precision or recall is very low.

A worked example

Take a spam filter run on 100 genuine spam emails and a much larger inbox of regular mail. The model flags 80 emails as spam. Of those, 70 really are spam (true positives) and 10 are not (false positives, legitimate mail wrongly binned). The model also misses 30 real spam emails, which land in the inbox (false negatives).

Precision = 70 ÷ 80 = 87.5%. Recall = 70 ÷ 100 = 70%. F1 = 2 × (0.875 × 0.70) ÷ (0.875 + 0.70) ≈ 77.8%.

Read that as: when this filter calls something spam, it is right seven times out of eight, but it only catches seven out of every ten actual spam emails that exist.

Where it matters

Every detection system has to decide which error it fears more, and that decision shows up directly in these numbers. A cancer screening test wants high recall, because missing a real case (a false negative) is far worse than a false alarm that leads to a follow-up scan. A spam filter wants high precision, because a false positive means a real email from a real person disappears without anyone noticing. Search and recommendation systems, content moderation, fraud detection and medical diagnosis all make this same trade-off, just in different directions.

Strengths

Precision and recall separate the two kinds of error that accuracy hides, which makes them far more informative on imbalanced data. They map directly onto a real decision (where to set a threshold) rather than being an abstract summary. And because they are simple ratios, they are easy to compute, easy to explain and easy to track over time.

Limitations, and the things that go wrong

Precision and recall move in opposite directions as you shift a model’s decision threshold: tighten it to catch more spam and precision drops as more false positives creep in; loosen it to avoid false alarms and recall drops as real cases slip through. F1 forces them into a single number by weighting them equally, which is a choice, not a law, and it is often the wrong choice. A medical application that cares ten times more about recall than precision should not use the plain F1 score; it should use a weighted version (Fβ) that reflects that priority. And like accuracy, none of these three say anything about how confident the model was, or how its performance differs across subgroups of the data.

When I would use it, and what to pair it with

I report precision and recall together, every time, rather than collapsing straight to F1, because the pair tells a story that the single number erases. I pick the threshold by asking which error costs more in this particular setting, not by optimising F1 for its own sake. And I pair all three with a full confusion matrix and, if the data is very imbalanced, with the precision-recall curve rather than the ROC curve, because PR curves are far more informative when positives are rare.