difficulty 2/5
F1-score
The harmonic mean of precision and recall — one number that is only high when a model is both trustworthy when it fires and thorough in what it finds.
Intuition
Precision and recall can each be gamed on their own: flag almost nothing to win precision, flag everything to win recall. The obvious fix is to combine them, and the obvious combination — the average — does not work. A model with precision 1.0 and recall 0.0 averages to 0.5, which flatters a model that found nothing [3, §8.3].
F1 uses the harmonic mean instead, which is dragged down by whichever of the two is worse. That model scores 0. You cannot buy a good F1 by sacrificing one side.
Formal definition
How it works
Where it's used
Why & when
Worked example
Pitfalls
Check yourself
3 questions
The questions on this page come with access. They are graded on the server, so the answers stay there until you have given yours.
On the cheat sheet: Classification metrics →
Sources
- scikit-learn — sklearn.metrics.f1_scoredocs · retrieved 2026-08-30https://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html
- Machine Learning Crash Course — Classification: accuracy, recall, precision, and related metricscourse · retrieved 2026-10-06https://developers.google.com/machine-learning/crash-course/classification/accuracy-precision-recall
- Introduction to Information Retrieval (2008)bookhttps://nlp.stanford.edu/IR-book/html/htmledition/irbook.html