Step by Step
F
The formula — 2 × (P × R) / (P + R)
F1 combines precision and recall into a single number using the harmonic mean: 2 times (precision times recall), divided by (precision plus recall).
Example: with precision=0.8 and recall=0.8, F1 comes out to 0.8 as well, reflecting balanced strong performance on both.
1
No free pass — perfect at one while failing the other still fails
If precision=1.0 (perfect) but recall=0.0 (complete failure), F1 comes out to exactly 0 — there's no partial credit for excelling at one metric while completely failing the other.
Example: a cancer model with 100% precision but 0% recall (it never predicts cancer at all, so every single prediction it does make happens to be correct) would score F1=0, correctly reflecting its complete uselessness.
⚠
The classic trap it catches — the always-negative model
A model that always predicts "no cancer" for every single patient gets exactly 0% recall (catching zero actual cancer cases), and raw accuracy might still look deceptively fine on an imbalanced dataset — but F1 immediately catches this failure.
Example: on a dataset where only 2% of patients actually have cancer, a model predicting "no cancer" for everyone gets 98% accuracy but 0% recall and therefore F1=0, correctly exposing its complete failure at the actual task.
Applied Walkthrough
1
A cancer screening model achieves 100% precision but 0% recall, meaning it never predicts "cancer" for anyone at all — every prediction it does make (all zero of them) is technically "correct."
2
Ask: does this model deserve partial credit for its perfect precision? No — F1 gives zero credit for being perfect at one metric while completely failing at the other; F1 = 0 in this case.
3
This directly illustrates the harmonic mean's key property: it punishes extreme imbalance rather than averaging the two values in a way that could mask a complete failure.
4
This is exactly why F1 is preferred over raw accuracy in this scenario — accuracy might look deceptively fine on an imbalanced dataset, while F1 immediately exposes the model's complete failure at the actual task.
Exam Application
Exams test whether you understand F1's harmonic mean property specifically catches the edge case of a model excelling at one metric while completely failing the other — a classic exam scenario involves a model that always predicts the negative class, achieving high accuracy but F1=0.
⚠ Common Trap
The most common trap is assuming a model with impressively high precision (or recall) alone must be a good model overall. F1 specifically exists to catch cases where one metric looks great while the other has completely failed — always check both, or check F1 directly, rather than trusting one metric in isolation.
✓ Quick Self-Check
1. What is the F1 score if precision=1.0 and recall=0.0?
F1 = 0 — there's no partial credit for excelling at one metric while completely failing the other.
Tap to reveal / hide
2. What kind of model does the F1 score specifically catch that raw accuracy might miss?
A model that always predicts the negative class, which can achieve high accuracy on imbalanced data despite 0% recall.
Tap to reveal / hide
3. What is the formula for F1 score?
2 × (Precision × Recall) / (Precision + Recall).
Tap to reveal / hide
4. Why is F1 described as punishing "extreme imbalance"?
Because the harmonic mean is disproportionately dragged down when one of precision or recall is very low, unlike a simple average.
Tap to reveal / hide
5. Should you trust a model based on a single very high metric (precision or recall) alone?
No — always check both precision and recall (or F1 directly), since a model can excel at one while completely failing the other.
Tap to reveal / hide