# Precision and recall

> Canonical: https://skillalmanac.com/glossary/precision-and-recall | Last verified: 2026-11-24 | Index status: index-eligible

Precision and recall are two ways to score a classifier. Precision is the share of items it labelled positive that really are positive. Recall is the share of all real positives that it found.

Also called: precision recall, precision vs recall, recall machine learning, precision and recall in machine learning, precision versus recall.

## In plain language

Suppose a spam filter flags 10 emails and 8 of them really are spam. Its precision is 8 out of 10. If your inbox held 16 spam emails in total, it found 8 of them, so its recall is 8 out of 16. Precision asks, when it raises an alarm, is it right. Recall asks, of everything it should have caught, how much did it catch. Raising one often lowers the other, so the right balance depends on which mistake costs more: missing a real problem or raising a false alarm. A single accuracy figure can hide this.

## Technical definition

For a specified positive class, precision is TP/(TP+FP) and recall is TP/(TP+FN). State the decision threshold and label convention. A zero denominator makes the corresponding ratio undefined; software may return a configured value. Multiclass or multilabel reports require per-label values or an averaging convention. A precision-recall tradeoff is common, not a universal constraint.

## How it shows up when you use agents

Precision and recall appear whenever an agent or a model has to find something: flag risky code, route a ticket, spot a policy violation, retrieve the right documents. If a review agent flags 20 problems in a pull request and 15 are real, its precision is 15 out of 20. If the pull request held 30 real problems, its recall is 15 out of 30. The two numbers answer different questions, and an agent can look good on one and poor on the other.

What breaks when they are misunderstood: a team reports a high accuracy on a task where positives are rare, and a filter that flags nothing would score almost as well. Ask for both numbers, and ask which error is worse for the task. Missed security issues push you toward recall. Alert fatigue from false alarms pushes you toward precision.

A next step: build a small labelled set of real cases with [LLM eval test sets](/skills/skill-almanac/llm-eval-test-sets), count true positives, false positives and false negatives by hand, and compute both metrics before you trust an agent's own claim. The same pair of terms is used for retrieval in [retrieval-augmented generation](/glossary/retrieval-augmented-generation), where recall asks whether the right passage was fetched.

## Worked example (illustrative)

Use a constructed binary evaluation with TP=6, FP=9 and FN=4. Precision is 6/15=0.4 and recall is 6/10=0.6. If no items were predicted positive, precision would instead have a zero denominator and need an explicit software convention. The displayed counts are invented for explanation and were checked with scikit-learn, not measured from an agent or deployed classifier.

## Common confusions

- **Precision versus recall.** Precision looks at the items the model flagged. Recall looks at the real positives that exist. Their denominators differ.
- **Precision versus accuracy.** Accuracy counts all correct calls, including negatives. It can look high when positives are rare. Precision and recall focus on the positive class.
- **Recall versus sensitivity.** The scikit-learn guide notes recall is sometimes called sensitivity. For binary classification they name the same quantity.
- **Myth: improving one must always worsen the other.** A better model can improve both, and precision need not move monotonically as a threshold changes. State the task, scores and operating threshold before comparing results.

## Worked examples in this catalogue

### [llm-eval-test-sets](https://skillalmanac.com/skills/skill-almanac/llm-eval-test-sets)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Builds and validates an eval dataset for any LLM feature, with a checker for duplicates, missing graders, imbalance and leakage.

Why it exercises the concept: The skill prepares labelled evaluation cases and checks balance. Precision and recall depend on the task's true positives, false positives and false negatives; preparing the dataset does not compute those metrics.

### [split-leakage-check](https://skillalmanac.com/skills/skill-almanac/split-leakage-check)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Checks train, validation and test files for duplicates, shared groups, time and label leakage; prints JSON.

Why it exercises the concept: Leakage can inflate precision and recall on a test set. This skill checks the evaluation data for leakage rather than computing the metrics.

### [sample-size-calculator](https://skillalmanac.com/skills/skill-almanac/sample-size-calculator)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Computes the minimum number of subjects per group for a planned comparison of two proportions, two means, or one mean, using the normal approximation in a stdlib script.

Why it exercises the concept: A precision or recall figure from a small test set is noisy. Sample size planning is the nearby question of how many examples you need before comparing.

### [data-analysis-eda](https://skillalmanac.com/skills/skill-almanac/data-analysis-eda)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A fixed exploratory-analysis procedure and CSV profiler that keeps findings descriptive, evidenced and caveated.

Why it exercises the concept: Profiling a labelled CSV shows how rare the positive class is, which affects how hard each of the two numbers is to move.

## Related terms

- [Classification](https://skillalmanac.com/glossary/classification.md)
- [Machine learning (ML)](https://skillalmanac.com/glossary/machine-learning.md)
- [Supervised learning](https://skillalmanac.com/glossary/supervised-learning.md)
- [Ground truth](https://skillalmanac.com/glossary/ground-truth.md)
- [LLM benchmark](https://skillalmanac.com/glossary/llm-benchmark.md)
- [Anomaly detection](https://skillalmanac.com/glossary/anomaly-detection.md)

## Sources

- [Classification: Accuracy, recall, precision, and related metrics](https://developers.google.com/machine-learning/crash-course/classification/accuracy-precision-recall), Google for Developers (Machine Learning Crash Course) (accessed 2026-11-24)
- [Metrics and scoring: quantifying the quality of predictions](https://scikit-learn.org/stable/modules/model_evaluation.html), scikit-learn documentation (accessed 2026-11-24)
- [Precision: positive class, averaging and undefined cases](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_score.html), scikit-learn (accessed 2026-11-24)
- [Recall: positive class, averaging and undefined cases](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.recall_score.html), scikit-learn (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-24. [Glossary index](https://skillalmanac.com/glossary.md).
