Precision and recall, explained with an example
Last updated: 2026-11-23
Precision is the share of the items a model flagged that really were positive, and recall is the share of the really positive items that the model found. A model that flags more items usually raises recall and lowers precision, so the two are read together, with a confusion matrix to show where each number comes from.
Start learning No account needed
1. Precision and recall in plain words
A confusion matrix counts a model's answers in four groups. A true positive (TP) is a real positive that the model flagged. A false positive (FP) is a flag on something that was not positive. A false negative (FN) is a real positive the model missed. A true negative (TN) is a non-positive the model left alone.
The scikit-learn precision-recall example defines precision as the true positives over the true positives plus the false positives, and recall as the true positives over the true positives plus the false negatives. In words, precision divides by everything the model flagged, and recall divides by everything that was really positive.
2. A worked example: a spam filter on 100 emails
The numbers below are made up for this page. Of 100 emails, 50 are spam. The same filter is run at two settings, a strict one that flags an email only when it is quite sure, and a loose one that flags more freely.
| Flagged as spam | Not flagged | |
|---|---|---|
| Strict: really spam (50) | TP = 30 | FN = 20 |
| Strict: really not spam (50) | FP = 10 | TN = 40 |
- Precision = TP / (TP + FP) = 30 / (30 + 10) = 30 / 40 = 0.75. Of the 40 emails flagged, 30 were spam.
- Recall = TP / (TP + FN) = 30 / (30 + 20) = 30 / 50 = 0.60. Of the 50 spam emails, the filter caught 30.
Now the loose setting.
| Flagged as spam | Not flagged | |
|---|---|---|
| Loose: really spam (50) | TP = 40 | FN = 10 |
| Loose: really not spam (50) | FP = 30 | TN = 20 |
- Precision = 40 / (40 + 30) = 40 / 70 = 0.571. Of the 70 emails flagged, 40 were spam.
- Recall = 40 / (40 + 10) = 40 / 50 = 0.80. Of the 50 spam emails, the filter caught 40.
Loosening the filter moved recall from 0.60 to 0.80 and precision from 0.75 to 0.571. The scikit-learn example describes this as the tradeoff between precision and recall for different thresholds. Which setting suits you depends on what each mistake costs. If a real email lost in the spam folder is a bigger problem than a spam message in the inbox, you would favor the strict setting, and that choice is ours to illustrate, not a rule from the source.
The F1 score combines the two: F1 = 2 x precision x recall / (precision + recall). For the strict setting it is 2 x 0.75 x 0.60 / (0.75 + 0.60) = 0.90 / 1.35 = 0.667, and for the loose setting it is 2 x 0.571 x 0.80 / (0.571 + 0.80) = 0.914 / 1.371 = 0.667. The two settings tie on F1 though they make different mistakes, which is one reason to look at precision and recall separately.
These numbers come from a short script, precision-vs-recall-example.mjs, run on 2026-11-23.
3. A common misconception: high accuracy means a good model
Accuracy is the share of all answers that were right, (TP + TN) / total. In the example above, the strict setting has accuracy (30 + 40) / 100 = 0.70 and the loose setting has (40 + 20) / 100 = 0.60, so accuracy fell while recall went up, and it hid the tradeoff.
Accuracy can mislead more when positives are rare. Say 1,000 emails hold only 10 spam messages, and a filter flags nothing. It is right on all 990 non-spam emails, so its accuracy is 990 / 1,000 = 0.99. Its recall is 0 / (0 + 10) = 0, because it caught none of the spam, and its precision is 0 / 0, which is undefined because it flagged nothing. A 99 percent accuracy figure would look strong, and the filter does no work at all.
4. Check that you understand it
Work this on paper first. A model flags 10 items. Of those, 8 were really positive and 2 were not. It also missed 4 really positive items. Find the precision and the recall.
Answer
Precision = 8 / (8 + 2) = 8 / 10 = 0.80. Recall = 8 / (8 + 4) = 8 / 12 = 0.667.
Then close this page and explain to someone else why a model can have high accuracy and low recall. For the general method, see how to test yourself.
What the sources found, and their limits
scikit-learn example, precision-recall. It defines precision and recall as above and says the precision-recall curve shows the tradeoff between them for different thresholds. Limits: the page loaded only in part when we read it on 2026-11-23, and we used the definitions and the tradeoff sentence, not its code or its curve discussion. The spam filter, its counts and the F1 and accuracy comparisons are ours, made up to show the arithmetic.
How Professor Turing helps
Professor Turing is a tutor for adults learning any subject, in college or on their own. It asks you questions instead of giving the final answer, does not grade a bare guess, and remembers what you got wrong. No account is needed to start.
Bring a topic you are studying, such as what precision and recall tell you about a model. Its first reply asks what you already know before it teaches anything. If you answer with a bare guess, such as a term, it asks how you got there instead of saying right or wrong, and when you stay stuck it changes its approach and makes the next step smaller instead of giving the final answer. Later in a session it can offer a short test without help, scored apart from the tutoring, so you can tell what you can do alone from what the tutor carried you through.
It does not read or mark a written answer, and it does not write your explanation for you, so the explanation has to be yours. You must be 18 or older, and guest conversations are deleted 7 days after the last activity.
FAQ
Which matters more, precision or recall? It depends on what each mistake costs. If a missed positive is the costly mistake, such as a missed spam message you would rather not see, recall matters more. If a false flag is the costly mistake, such as a real email sent to the spam folder, precision matters more.
What is the F1 score? The F1 score is 2 x precision x recall / (precision + recall). In our example the strict and loose settings both give 0.667 even though their precision and recall differ, so F1 on its own can hide which mistake a model makes.
Start with what you're working on
Tell the tutor which topic you are studying and let it ask you the questions.
Start learning No account needed
See also: all study guides