What is the F1 score?
The harmonic mean of precision and recall: F1 = 2 · precision · recall / (precision + recall). It runs from 0 to 1, where 1 is best, and accuracy plays no part in it.
The harmonic mean of precision and recall: F1 = 2 · precision · recall / (precision + recall). It runs from 0 to 1, where 1 is best, and accuracy plays no part in it.
Card 1 of 263. Answer: The harmonic mean of precision and recall: F1 = 2 · precision · recall / (precision + recall). It runs from 0 to 1, where 1 is best, and accuracy plays no part in it.
About · Quizzes · History of AI · To suggest new questions or report an error send me a dm.
The F1 score is the harmonic mean of precision and recall: F1 = 2 · precision · recall / (precision + recall). It runs from 0 to 1, where 1 is best, and it is high only when both precision and recall are high. Accuracy is not part of the formula, whatever the trick question says.
The harmonic mean is used because it is dragged toward the smaller of the two numbers. A classifier with precision 1.0 and recall 0.1 has an arithmetic mean of 0.55 but an F1 of about 0.18, which matches how poorly it finds the positive class. Written with confusion matrix counts, F1 = 2TP / (2TP + FP + FN), so the true negatives never enter it.
Example: a fraud model flags 100 transactions, 60 of which are fraud, out of 120 frauds in total. Precision is 60 / 100 = 0.6, recall is 60 / 120 = 0.5, and F1 = 2 · 0.6 · 0.5 / 1.1 ≈ 0.55. The counts give the same answer: TP = 60, FP = 40 and FN = 60, so F1 = 120 / 220 ≈ 0.55.
An F1 of 1 means no false positives and no false negatives; an F1 of 0 means the model found no true positives at all. A model that never predicts the positive class scores 0, even at 99% accuracy. What counts as good depends on how rare positives are: labeling everything positive gives recall 1 and precision equal to the prevalence p, so F1 = 2p / (1 + p), about 0.67 at 50% prevalence and only 0.02 at 1%. An F1 of exactly 1 on a test set more often signals data leakage than a perfect model.
F1 is the usual choice on imbalanced data, where accuracy misleads, but it ignores true negatives and weights precision and recall equally. When they don't matter equally, use F-beta, which weights recall beta times as much as precision: F2 favors recall and F0.5 favors precision. For multi-class problems, macro-F1 averages the per-class scores so rare classes count as much as common ones, while micro-F1 pools every prediction first and, when each example has exactly one label, equals accuracy. F1 also moves with the decision threshold, so tune the threshold on validation data before comparing models by it.