F1 score
Also known as: F-score, F-measure
One number that blends precision and recall, so it stays low unless a model both finds the real cases and avoids wrong flags.
Draft - this entry has not been reviewed yet.
Formal
Two times precision times recall, divided by precision plus recall, a balanced average that is pulled down by whichever of the two is lower, computed for one class.
In plain English
Like judging a goalkeeper on both saves and clean kicks, where being perfect at one and hopeless at the other still earns a poor mark.
In practice
The IT operations lead at an accounting firm compares two spam filters, one with 95% precision and 40% recall, the other with 80% and 78%; their F1 scores, about 56% against 79%, make the second the clear choice.
Why it matters
It gives one fair number for comparing models on rare classes, where accuracy misleads, though it hides which of the two errors is growing.
Technical deep dive
F1 is the harmonic mean of precision P and recall R: F1 = 2PR / (P + R), which in confusion-matrix terms is 2TP / (2TP + FP + FN). True negatives do not appear at all, which is why F1 suits retrieval and rare-class detection and why it says nothing about how well the negative class is handled. The general form Fβ = (1 + β²)PR / (β²P + R) weights recall β times as much as precision; F2 is common where misses are expensive and F0.5 where false alarms are. The measure descends from van Rijsbergen's effectiveness measure E in information retrieval (1979), of which F is the complement.
The harmonic mean is dominated by the smaller operand: P = 1.0 and R = 0.1 give F1 ≈ 0.18, whereas the arithmetic mean would be 0.55. For multiclass and multilabel problems the per-class scores must be aggregated, and the choice changes the number: macro-F1 averages per-class F1 equally (so rare classes count as much as common ones), micro-F1 pools TP, FP and FN across classes (and for single-label multiclass equals accuracy), weighted-F1 weights by class support. Even "macro-F1" has two definitions in the literature (the mean of per-class F1 versus the F1 of mean precision and mean recall), and they can differ noticeably (Opitz & Burst, 2019). When a class has no predicted and no true positives F1 is undefined; scikit-learn exposes this through its zero_division parameter.
F1 is threshold-dependent and not maximised at 0.5. Lipton, Elkan and Narayanaswamy (2014) showed that for calibrated probabilities the F1-optimal threshold equals half the achievable maximum F1, so a model capable of F1 = 0.6 should be thresholded near 0.3; the threshold is tuned on the validation set, never the test set. F1 is also non-decomposable: averaging per-fold or per-batch F1 is not the same as computing F1 on pooled counts (Forman & Scholz, 2010), and it cannot be optimised directly by per-example losses, so training typically uses cross-entropy with thresholding afterwards.
Critics note that F1 changes if the positive class is relabelled, depends on prevalence, and fixes an arbitrary equal weighting of the two error types; Hand and Christen (2018) argued it is ill-suited to comparing record-linkage methods, and the Matthews correlation coefficient is often recommended when both classes matter. Task-specific variants abound: entity-level F1 in named-entity recognition counts a prediction correct only with exact span and type, while SQuAD-style F1 measures token overlap between predicted and reference answers.
What to learn first
Everything this builds on, foundations first.
Relationships
- Part of
- Model evaluation (evals)
- Don't confuse with
- Accuracy
Sources & further reading
Official documentation
Reference works
Textbooks
Where this data comes from
This entry was drafted by an AI from the sources above and has not yet been checked by a person. Treat it as a starting point, and check anything important against the sources.
See the review queueSuggest a correction on GitHubThis term as JSON
Check yourself
Loading…