F1 score
F1 score is the harmonic mean of precision and recall for a specified positive class and decision threshold.
For binary predictions, F1 = 2TP / (2TP + FP + FN). True negatives do not enter this formula. If TP, FP and FN are all zero, it is undefined, so the zero-division convention must be reported. F1 is neither recall nor accuracy, and multiclass or multilabel results must state the averaging rule. [1] Separately averaged or median precision and recall do not generally reconstruct an averaged or median F1. [2]
The best threshold depends on the score scale. For calibrated probabilities, the F1-maximizing rule predicts positive when the probability is at least half the best achievable F1. A classifier that gives every case the same score is optimized by predicting all cases positive, which yields precision equal to the base rate b and F1 = 2b/(1 + b), about 0.18 at a 10% base rate. [3]
Because true negatives are ignored, a high value can hide failure on the other class. In one constructed set with 91 positives and 9 negatives, TP = 90, FN = 1, FP = 9 and TN = 0 gave F1 = 0.95 and accuracy 0.90, while the Matthews correlation coefficient was -0.03. [4]
Relations
- related
- Precision, Recall, False positive rate, Class prevalence, Average precision, Temporal validation, Matthews correlation coefficient, Brier score
Advantages
- Precision and recall enter as one number that stays low unless both are reasonably high, which suits tasks where the positive class is rare. [3]
Limitations
- A single F1 value does not state how many healthy drives trigger alerts or the operational cost of false alarms. Retain precision, recall, prevalence and the counting unit. [2]
Citations
- scikit-learn: f1_score, binary formula, averaging and zero-division conventions.
- scikit-learn: precision, recall and F-measures; aggregation and metric denominators.
- Lipton, Elkan and Naryanaswamy. Thresholding Classifiers to Maximize F1 Score. ECML PKDD 2014, arXiv 1402.1892, sections 3 and 4.
- Chicco and Jurman. The advantages of the Matthews correlation coefficient over F1 score and accuracy. BMC Genomics 21, 6 (2020), use case A1.
Sources & caveats
- f1-threshold read 2026-10-23, sections 3 and 4, for the threshold relation and the uninformative-classifier result.
- mcc-advantages read 2026-10-23, use case A1, for the confusion matrix and the three scores.
- sklearn-f1 and sklearn-metrics carry the formula and averaging conventions.