Machine Learning

F1 Score

The harmonic mean of precision and recall — the default single number for classification, and it encodes a decision nobody made.

Reviewed July 12, 2026Stable
Reading level: Curious
Pick your depth ↓

When not to use it

  • When your error costs are asymmetric. Which is nearly always. Use F-beta and state the ratio.
  • To decide what to deploy. It's a comparison scalar, not a decision.
  • Micro-averaged, on single-label multi-class. That's accuracy with a fancier name.
  • When the negative class matters. F1 ignores true negatives entirely.

Reach for something else instead

  • F-beta — the same metric with the weighting stated. F2 for recall, F0.5 for precision.
  • Cost-weighted error — the confusion matrix times what each mistake costs. The honest version.
  • Macro-F1 — if you must have one number on imbalanced multi-class, this is the one that notices the rare class.
  • Precision and recall, separately — two numbers, no hidden assumption.

Macro and micro can differ by tens of points. Same model, same predictions.

Micro-F1 (= accuracy here)0.00every prediction pooled
Macro-F10.00each class weighted equally
33%
88%

Three classes; you control how rare the third one is and how badly the model does on it. Micro-F1 pools every prediction into one count, so a class with 2% of the examples contributes 2% of the score — the model can fail it completely and micro barely moves. Macro-F1 averages the three per-class scores, so the rare class counts one third regardless of its size. Every number is computed live from the confusion counts shown. Neither is wrong; they answer different questions. Reporting one without saying which is the actual mistake — and on single-label multi-class, micro-F1 equals accuracy, so quoting it as “F1” dresses accuracy in a more rigorous-sounding name.

Worked example

F1 is the harmonic mean of precision and recall — and the harmonic mean is the point, because it punishes imbalance. Take the spam filter above: precision 0.81, recall 0.88.

F1 = 2 × (precision × recall) / (precision + recall)
F1 = 2 × (0.81 × 0.88) / (0.81 + 0.88)
F1 = 2 × 0.713 / 1.69 = 0.84

Why not just average them? Watch what the harmonic mean does to a lopsided model — say precision 0.95 but recall 0.10 (it almost never flags spam, but is right when it does):

plain average = (0.95 + 0.10) / 2 = 0.53 ← flattering
F1 = 2 × (0.95 × 0.10) / (0.95 + 0.10) = 0.18 ← honest

The plain average calls a nearly-useless model "okay." F1 collapses toward the worse of the two, so it can only be high when precision and recall are both decent. That's why F1 is the standard single number for imbalanced classification.

The full account

Why is it a harmonic mean, and why is β one?

F1 is the harmonic mean of precision and recall. Two questions follow that almost nobody asks, and both have uncomfortable answers.

The harmonic mean is chosen because it punishes imbalance. The arithmetic mean of precision 1.0 and recall 0.0 is 0.5, which would let a classifier that flags exactly one case and gets it right look mediocre rather than useless. The harmonic mean of 1.0 and 0.0 is 0. That is a defensible design choice and it is the strongest part of the metric.

The subscript is the problem. F1 is the β=1 member of a family, and β sets how much more you care about recall than precision. β=1 asserts they matter equally. That is not a mathematical fact — it is a claim about your costs, and it is almost always false. In cancer screening a false negative is a death and a false positive is an anxious afternoon; those are not equal. In spam filtering a false positive is a lost job offer and a false negative is a nuisance; also not equal. Every F1 you have ever reported encodes a value judgement you did not make and probably would not endorse if it were stated out loud.

Van Rijsbergen, who introduced the measure in 1979, was explicit that β was a parameter for the user to set from their own preferences. The field fixed it at 1 and stopped mentioning it.

The cell that isn't there

The structural fact about F1 is easiest to see in the confusion matrix. There are four cells: true positives, false positives, false negatives, true negatives. Precision uses TP and FP. Recall uses TP and FN. F1 combines them.

No part of F1 touches the true negatives. All the cases your model correctly identified as negative — usually the overwhelming majority of the data — contribute nothing to the score. This is sometimes defended as a feature, because in information retrieval the true negatives are every document you didn't return, and counting them is meaningless. That defence holds in search. It does not hold when you're classifying patients, transactions or images, where getting the negatives right is the entire job most of the time.

It also means F1 is not symmetric: swap the labels of your two classes and the score changes. A metric whose value depends on which class you decided to call "positive" is measuring something about your naming convention.

Hand's argument, made twice, ignored twice

David Hand published a paper in 2009 arguing that AUC is not merely imprecise but incoherent: averaging across thresholds implicitly weights the cost of false positives against false negatives, those implied weights depend on the classifier's own score distribution, so comparing two models by AUC compares them under different cost assumptions for each model.

In 2018, with Peter Christen, he made the same argument about the F-measure. They show F can be rewritten as a weighted sum of precision and recall — and the weights depend on the classification method being evaluated. Their conclusion is stated plainly: the relative importance assigned to precision and recall should be an aspect of the problem and of the researcher, not of the particular method being used. It is the identical structural flaw, in the field's other default metric, nine years later, from the same author.

Both papers are well cited. Both metrics remain the default. The most interesting thing on this page is that the field has been told twice, by the same person, in clear language, and has not changed — because the alternative to a single convenient number is a conversation about costs, and nobody wants to have it before a leaderboard.

Uses TPFPFNTNWeights areSymmetric under label swap
Precisionno
Recallno
F1classifier-dependent (Hand & Christen)no
MCCfixedyes
Expected costyours, statedyes

Macro or micro is a bigger decision than the metric

The figure above computes the part that catches people in production. With multiple classes you must average the per-class F1 scores, and there are two standard ways.

Micro pools every prediction across all classes and computes one F1 from the totals. Every example counts equally, so your large classes decide the number.

Macro computes F1 per class and averages the results. Every class counts equally, so a rare class with fifty examples has exactly as much say as a common one with fifty thousand.

Drag the rare class in the figure and watch macro fall to 0.64 while micro sits at 0.90 — same model, same predictions, same confusion matrix, two numbers 26 points apart. Neither is wrong. They answer different questions: micro asks how often you're right, macro asks whether you work for everyone. If the rare class is fraud, or a rare disease, or a minority dialect, macro is the number that matters and micro is the number that gets reported.

Papers frequently report "F1" without saying which. When you see a suspiciously high F1 on an imbalanced dataset, that is the first thing to check.

What to do

Report precision and recall separately. They are two numbers, both interpretable, and collapsing them into one throws away the only thing a reader needs to judge your model against their own costs.

If you must have one number, state β and justify it, or use MCC — it uses all four cells, it is symmetric under label swap, and it does not have the weighting flaw.

If you know your cost ratio, compute expected cost. This is what every one of these metrics is a proxy for, and it is the only one where the value judgement is yours and visible.

And always say macro or micro. On imbalanced data the gap between them is the finding, not a footnote.

Further reading

  • van Rijsbergen (1979), Information Retrieval — where the F-measure comes from, and it was parameterised by β from the start. The β got dropped, not the concept.
  • Hand & Christen (2018), A Note on Using the F-Measure for Evaluating Record Linkage Algorithms — F1 applies different implicit cost ratios to different classifiers.
  • Powers (2011), Evaluation: From Precision, Recall and F-Measure to ROC, Informedness, Markedness & Correlation — what F1 discards, catalogued.
  • Chicco & Jurman (2020), The Advantages of the Matthews Correlation Coefficient (MCC) over F1 Score and Accuracy in Binary Classification Evaluation — BMC Genomics; the alternative that uses all four cells.
  • Hand (2009), Measuring Classifier Performance: A Coherent Alternative to the Area Under the ROC Curve — the same incoherence argument, aimed at AUC nine years earlier.

Primary sources, listed so you can check the claims on this page rather than take them on trust.

Where people go wrong

  • Reporting F1 without being able to justify equal weighting. It's a default, not a decision.
  • Not saying which averaging you used. Macro and micro can differ by tens of points.
  • Reporting micro-F1 on single-label multi-class as if it weren't accuracy.
  • Forgetting F1 ignores true negatives, then using it on a heavily imbalanced problem.

At a glance

FieldMachine Learning
What it isharmonic mean of precision and recall
The hidden assumptionthey're equally important
The fixF-beta, which makes you state the ratio
Ignorestrue negatives, entirely
Micro-F1 on single-label multi-classis accuracy
DifficultyBeginner
Flashcards for this concept · study, save or share them →
Question
Answer
1 / 4

Often compared with

F1 vs. F-beta — the same formula, but F-beta makes you state how much more recall matters than precision. F1 makes that choice silently and calls it neutral.

Where this sits

A destination. 4 concepts lead here, and nothing in the corpus depends on it.

4Levelsteps in
4Needs firstconcepts
0Opens upnothing further
1Areastays here
Learn these firstPrecision and Recall
LEARN FIRST Precision and Recall F1 Score
F1 Score sits after Precision and Recall, and nothing further depends on it.

Computed from the prerequisite graph, not assigned. How this works