Machine LearningClassification Evaluation

What is the precision-recall trade-off?

The precision–recall trade-off means that changing a binary classifier's decision threshold often improves one metric at the expense of the other. Lowering the threshold usually finds more real positives (higher recall) but also raises more false alarms, potentially reducing precision.

Why does a threshold create a trade-off?

A classifier can output a score for how likely an example is positive. If its score is at least the threshold, predict the positive class.

  • Higher threshold: fewer positive predictions. This usually reduces false alarms but can miss real positives.
  • Lower threshold: more positive predictions. This catches more real positives but may also flag additional negatives.
Precision = TP / (TP + FP)
Recall    = TP / (TP + FN)

Important nuance: For a fixed set of scores, lowering the threshold cannot reduce recall (unless no actual positives exist, where recall is undefined). Precision is not guaranteed to decrease monotonically; its behavior depends on which examples cross the threshold.

Beginner-friendly numerical example: fraud detection

Imagine eight transactions, with four actual frauds and four legitimate transactions. Their model scores are:

  • Fraud (positive): 0.95, 0.80, 0.55, 0.40.
  • Legitimate (negative): 0.75, 0.45, 0.30, 0.10.

A transaction is flagged when its score is greater than or equal to the threshold.

At threshold 0.80:

  • Flagged: fraud at 0.95 and 0.80; no legitimate transactions.
  • TP=2, FP=0, FN=2.
  • Precision: 2/(2+0)=100%.
  • Recall: 2/(2+2)=50%.

At threshold 0.40:

  • Flagged: all four frauds, plus legitimate transactions at 0.75 and 0.45.
  • TP=4, FP=2, FN=0.
  • Precision: 4/(4+2)=66.7%.
  • Recall: 4/(4+0)=100%.

What changed? Lowering the threshold caught the two previously missed frauds, but also created two false alarms. Which threshold is preferable depends on the cost of missed fraud versus investigating legitimate transactions.

Verify with Python

PYTHON
from sklearn.metrics import precision_score, recall_score y_true = [1, 1, 1, 1, 0, 0, 0, 0] scores = [0.95, 0.80, 0.55, 0.40, 0.75, 0.45, 0.30, 0.10] for threshold in [0.80, 0.40]: predicted = [int(score >= threshold) for score in scores] precision = precision_score(y_true, predicted) recall = recall_score(y_true, predicted) print(f"{threshold:.2f}: precision={precision:.3f}, recall={recall:.3f}") # 0.80: precision=1.000, recall=0.500 # 0.40: precision=0.667, recall=1.000

How do you choose a threshold in practice?

  1. Identify the business cost of false positives and false negatives. Missing a serious condition may be worse than an extra review; incorrectly blocking legitimate customers may be expensive.
  2. Evaluate several thresholds on validation data with representative class frequencies.
  3. Choose a threshold that meets a practical constraint, such as recall at least 95%, while keeping false alarms manageable.
  4. Keep the test set untouched until final evaluation, and monitor performance after deployment if class prevalence changes.

A precision–recall curve visualizes results across thresholds. It is covered separately later in the curriculum.

Common misconception

A lower threshold does not improve the model's underlying ranking of examples. It changes the *decision rule* applied to existing model scores. Also, precision may increase at some thresholds even as recall increases, so do not assume a strict inverse relationship at every step.

In short: the precision–recall trade-off is a practical decision about how many missed positives versus false alarms you can accept, usually controlled by the classification threshold.

References

#precision recall tradeoff#precision recall threshold example#classification threshold false positive false negative#precision recall trade-off fraud detection#machine-learning#classification-evaluation#precision#recall#decision-threshold

Learning Sequence

Machine Learning Curriculum

78% Completed
Up NextMachine Learning

What is an ROC curve?

Explore Related Questions

Deepen your understanding across related Machine Learning topics.

Machinoai Logo
Machinoai

Your edge in the AI era. Deep dives into machine learning concepts, paper explainers, verified industry jobs, and developer tools.

© 2026 Machinoai. All rights reserved.