A high F1 score can hide a model that missed an entire class
The harmonic mean of precision and recall sits under a large share of classification leaderboards, and it never touches the one cell of the confusion matrix that would show a model ignoring the rare class.
Why this matters
You keep meeting the F1 score. It sits under reading-comprehension benchmarks, under spam filters and tumor detectors, under almost any claim that one model classifies something better than the last one did. It is a single number, and a single number is easy to take on trust. This lesson builds F1 from the counts up: precision, recall, and the harmonic mean that ties them together, and then the three things that one number quietly leaves out. By the end you will be able to read a state-of-the-art F1 and ask the three questions that decide whether it means anything: which class counted as positive, how the per-class scores were averaged, and how rare the positives were.
- 01
- SQuAD: a reading benchmark scored by F1, where machines passed the human line without learning to read.
- 02
- AUROC: another single-number verdict on a classifier, and what it stays silent about.
- 03
- Calibration error: what it means for a model's probabilities to be trustworthy, and how that is scored.
One number from four counts
The F1 score is a single number between 0 and 1, and it decides a large share of public claims about classifiers. Those are the systems that sort email into spam and not-spam, scans into tumor and clear, documents into relevant and not. Reading-comprehension benchmarks report it, and so does almost any paper announcing a state-of-the-art classifier. The number is old. It grew out of information retrieval, where C. J. van Rijsbergen defined the two quantities it combines and built a measure to weigh them together.1 Both quantities, and F1 itself, come from four counts you can read off a small table.
Precision and recall, from a table of four
Set a classifier loose on a batch and sort its verdicts against the truth. Every item lands in one of four boxes. It was positive and the system called it positive: a true positive. It was positive and the system missed it: a false negative. It was negative and the system falsely flagged it: a false positive. It was negative and the system correctly left it alone: a true negative. Take a search that returns 10 documents from a collection of 1,000, when 12 of those documents are actually relevant.
| Called positive | Called negative | |
|---|---|---|
| Actually positive | 8 | 4 |
| Actually negative | 2 | 986 |
Precision reads down the column of things the system called positive: of the 10 it returned, 8 were relevant, so precision is 0.8. Van Rijsbergen defined it as the chance that a returned item is relevant.1 Recall reads across the row of things that were actually positive: of the 12 relevant documents the system found 8, so recall is about 0.67, the chance that a relevant item gets returned.1 In counts, that is \mathrm{precision} = \mathrm{TP}/(\mathrm{TP}+\mathrm{FP}) and \mathrm{recall} = \mathrm{TP}/(\mathrm{TP}+\mathrm{FN}).2 Neither precision nor recall uses the box holding 986.
Why the mean is harmonic
Two numbers invite an average, and the obvious average is the arithmetic mean. F1 does not use it. F1 is the harmonic mean of precision and recall,3 and the harmonic mean has one property that matters here: it sits close to the smaller of the two numbers rather than halfway between them.
Watch it on a lopsided pair. A fingerprint system with precision 1.0 and recall 0.2 is almost useless. It is right whenever it speaks, but it stays silent on four cases in five. The arithmetic mean rewards it with 0.6. The harmonic mean gives it 0.33, which is about what a nearly useless system deserves.3 A lopsided pair cannot buy back a low recall with a high precision.
- Pprecision, the share of flagged items that were right.
- Rrecall, the share of real positives the system found.
The measure did not arrive with the name F. Van Rijsbergen wrote it as an effectiveness score to be minimized, fitted with a single dial that lets a user weight recall against precision.1 The evaluation community adopted it at the fourth Message Understanding Conference in 1992, wrote it in the form still used, and called it the F-measure. Its parameter β sets recall's importance relative to precision. β above 1 weights recall more, β below 1 weights precision more, and β equal to 1 gives the equal-weight case everyone now writes as F1.4 The letter itself was a mild accident, picked from a different F in van Rijsbergen's book.3
The cell F1 never reads
Look back at the four boxes. F1 uses three of them. True positives, false positives, and false negatives all appear in precision or recall. The fourth box, the true negatives, never enters the formula.5 In the search example that box held 986 documents, and F1 would read exactly the same if it held 986,000. David Powers put the general point plainly: the precision-recall-F family ignores how well a system handles the negatives, so a system that is genuinely worse can score higher.5
Three consequences follow, and each is a question to ask of any F1 you are handed.
Which class is positive? F1 is not symmetric. Swap the labels for positive and negative and the score changes, so the same predictions earn two different F1s depending on which class you decided to count.2
At what base rate? Because F1 turns on the positives, its best operating point moves with how common the positives are, and two F1 scores from datasets of different prevalence are not comparable.6 Push that to the limit and it gets worse: a classifier that knows nothing at all maximizes its F1 by labeling every single item positive.6 Recall climbs to 1, precision settles at the base rate, and the harmonic mean of the two can clear what an honest but cautious classifier manages.
Which averaging? F1 is defined for a two-class problem, so scoring three or more classes means averaging the per-class F1s, and there is more than one way to do it. Micro averaging pools the counts across all classes and takes one quotient; with every class included, that number is simply accuracy.7 Macro averaging takes the plain mean of the per-class scores, giving a rare class the same weight as a common one.7 Weighted averaging weights each class by its size and can land outside the range between precision and recall.7 Same predictions, three different numbers.
F1 crowns the wrong classifier
Davide Chicco and Giuseppe Jurman built the cleanest demonstration of the cost. They ran classifiers on skewed data and set F1 and accuracy against the Matthews correlation coefficient, or MCC. MCC uses all four boxes and reads as a correlation between prediction and truth, running from −1 through 0, a coin toss, up to +1.2
| Case | Class split | Negatives caught | Accuracy | F1 | MCC |
|---|---|---|---|---|---|
| A1 | 91% positive | 0 of 9 | 0.90 | 0.95 | −0.03 |
| B1 | 50 / 50 | 5 of 50 | 0.52 | 0.66 | +0.07 |
In the first case the data is 91% positive, and a classifier calls almost everything positive: it catches 90 of 91 positives and 0 of 9 negatives. Its F1 is 0.95 and its accuracy is 0.90, both excellent. Its MCC is −0.03, the score of a coin toss, because it never once got a negative right.2 The second case is balanced 50-50, and there F1 alone is fooled. It reads a passable 0.66 while the classifier finds only 5 of 50 negatives, and both accuracy at 0.52 and MCC at +0.07 report the coin toss that it is.2
The same reversal shows up on real data. On a colon-cancer gene-expression dataset of 62 patients, ranking classifiers by F1 crowns a k-nearest-neighbors model at 0.87, ahead of gradient boosting at 0.81. MCC reverses them: gradient boosting leads at +0.55 to k-NN's +0.48. The k-NN model wins on F1 by finding cancer well, catching 92% of the sick. But it clears only 52% of the healthy, barely better than a coin toss on the patients it should be reassuring.2 Rank by F1 and you ship the model that sends nearly half of the healthy patients on for more tests.
Even inside multi-class F1 the ranking is not safe. Two formulas both travel under the name macro F1: the plain mean of the per-class F1s, which scikit-learn computes by default, and the harmonic mean of the averaged precision and averaged recall, which some shared tasks use. Juri Opitz and Sebastian Burst showed the two can disagree by as much as 0.5 and, worse, can order two classifiers in opposite directions. On one pair of confusion matrices, moving from the first to the second raises the second formula from 0.50 to 0.55, an apparent improvement. The first formula does the opposite, falling from 0.49 to 0.48.8 A macro-F1 leaderboard has to say which macro F1 it means.
None of this makes F1 a bad measure. Van Rijsbergen built it for document retrieval, where the true negatives are every document you correctly ignored, an unbounded and uninformative mass.1 There, accuracy is the useless number. Label every document irrelevant and you score near-perfect while returning nothing, the same way Chicco's majority classifier scores the majority fraction by doing nothing.2 In a needle-in-a-haystack search, ignoring the true negatives is exactly right, because those negatives carry no news. Powers calls the same blindness to true negatives a bias, and whether it is a feature or a bias depends only on whether the negatives are worth counting.5 MCC is no free lunch either: it is undefined when a whole row or column of the table is empty, and Chicco resolves those cases only by convention.2
The takeaway
F1 is the harmonic mean of precision and recall, and the harmonic mean is what pulls it down toward whichever of the two is worse. That is its real strength: a model cannot coast on a high precision while its recall collapses. Its blind spot is the true negatives, the items it correctly left alone, which never enter the formula. When those matter and the classes are skewed, F1 can sit near the top while a model misses a whole class, and a score like MCC that uses all four counts will catch what F1 cannot. Macro F1, meanwhile, is not even one number. So the three questions are the thing to carry away: which class was positive, which averaging produced the score, and at what base rate. F1 is the right tool for the retrieval problems it was built for, where the true negatives are an uninformative mass, and the wrong one when those negatives carry the news.
- 01
- Chicco & Jurman, on MCC over F1: the full argument with all six synthetic cases and the colon-cancer table.
- 02
- Opitz & Burst, "Macro F1 and Macro F1": the proof that two macro-F1 formulas can reverse a ranking.
- 03
- Sasaki, "The truth of the F-measure": a short derivation of the F-measure and the accident behind its name.
Sources
- University of Glasgow · C. J. van Rijsbergen, Information Retrieval, Chapter 7 (1979)
- BMC Genomics · Chicco & Jurman, The advantages of the Matthews correlation coefficient over F1 score and accuracy (2020)
- Yutaka Sasaki · The truth of the F-measure (2007)
- ACL Anthology · Nancy Chinchor, MUC-4 Evaluation Metrics (1992)
- arXiv · David M. W. Powers, Evaluation: from precision, recall and F-measure to ROC, informedness, markedness and correlation (2011)
- arXiv · Lipton, Elkan & Naryanaswamy, Thresholding Classifiers to Maximize F1 Score (2014)
- scikit-learn · Metrics and scoring: quantifying the quality of predictions
- arXiv · Juri Opitz & Sebastian Burst, Macro F1 and Macro F1 (2019)