Start with the four counts
| Predicted positive | Predicted negative |
|---|
| Actually positive | True positive (TP) | False negative (FN) |
| Actually negative | False positive (FP) | True negative (TN) |
Precision = TP / (TP + FP)
Recall = TP / (TP + FN)
Precision asks: of the cases flagged, how many were truly positive? False positives lower it. Recall asks: of all true positives, how many were found? False negatives lower it.
For example, if a system flags 100 cases and 80 are truly positive, precision is 80%. If there are 200 actual positive cases overall, recall is 80/200 = 40%. The first rate uses predicted positives as its denominator; the second uses actual positives.
Move the threshold
A classifier often assigns each case a score. Lowering the threshold usually labels more cases positive: recall tends to rise, while precision may fall as more false alarms enter the flagged set. Raising the threshold usually makes predictions more selective: precision may rise while recall falls. The exact changes depend on the scores and data.
- Set Threshold to 0.10 and observe the positive predictions and both metrics.
- Raise it to 0.90. The model scores stay fixed; only the cutoff changes. Compare the additional misses with the reduction in false alarms.
Choose a threshold using validation data, not the test set. A threshold that performs well on one sample can be too optimistic if it was selected using the same data.
When to prioritise each measure
Recall matters when missing a positive case is costly, such as in an initial safety screen. Precision matters when each alert triggers expensive review or disruptive action. Many systems need both, with an explicit minimum for one and an optimisation target for the other.
F1 is the harmonic mean of precision and recall:
F1 = 2 × precision × recall / (precision + recall)
If precision is 1.0 and recall is 0.01, the arithmetic mean is 0.505, but F1 is about 0.020. The harmonic mean stays closer to the smaller value, so F1 is high only when both measures are reasonably high. F1 weights precision and recall equally. Fβ changes that balance, weighting recall more when β is above 1 and precision more when β is below 1.
F1 ignores true negatives and does not encode the real-world cost of errors. Accuracy can also mislead when classes are imbalanced: if only 1% of cases are positive, always predicting negative gives 99% accuracy and zero recall. Review the confusion matrix and class imbalance alongside the metric.