Precision and recall are the twin compasses for judging a classification model: precision asks "of all my alarms, how many were justified?", while recall asks "of all the real cases, how many did I catch?". One measures purity, the other completeness.
Counting the errors
Everything rests on four cells: true positives (TP), false positives (FP), true negatives (TN) and false negatives (FN).
$$\text{Precision} = \frac{TP}{TP + FP} \qquad \text{Recall} = \frac{TP}{TP + FN}$$
Precision drops when the model cries "positive" too often (many FP). Recall drops when it lets real cases slip through (many FN).
A permanent trade-off
You can rarely maximize both. Lowering the decision threshold catches more cases (recall ) but multiplies false alarms (precision ), and vice versa.
| Context | Priority |
|---|---|
| Medical screening, fraud | Recall (miss nothing) |
| Spam filter, justice | Precision (avoid false accusations) |
The trade-off as a number: F1
To compress both into one figure, we use the harmonic mean, the F1 score:
$$F_1 = 2 \cdot \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}}$$
The harmonic mean punishes imbalance: a model with 99% precision but 2% recall earns a poor F1.
A high overall accuracy says nothing: on imbalanced data, it is the precision–recall pair that reveals what a model truly catches, and what it sacrifices.