F1 Score Calculator
Calculate the F1 score, the harmonic mean of precision and recall, from either those metrics or raw TP/FP/FN counts.
Inputs
F1 Score
0.8421
Precision
0.80%
Recall
0.89%
Step by step
Precision: TP / (TP + FP)
80 ÷ (80 + 20)
= 0.8000
Recall: TP / (TP + FN)
80 ÷ (80 + 10)
= 0.8889
F1 score: 2 × (precision × recall) / (precision + recall)
2 × (0.8000 × 0.8889) ÷ (0.8000 + 0.8889)
= 0.8421
How it works
The F1 score is the harmonic mean of precision and recall: F1 = 2 × (precision × recall) / (precision + recall). It's computed here directly from true positives (TP), false positives (FP), and false negatives (FN), where precision = TP / (TP + FP) measures how many predicted positives were correct, and recall = TP / (TP + FN) measures how many actual positives were found. The harmonic mean penalizes imbalance between precision and recall more than a simple average would, so F1 is high only when both metrics are reasonably strong — making it a popular single-number summary for classifiers, especially on imbalanced datasets.
Formula
F1 = 2 * (precision * recall) / (precision + recall)
- P
- Precision = TP / (TP + FP)
- R
- Recall = TP / (TP + FN)
Frequently Asked Questions
Why use the harmonic mean instead of the arithmetic mean?
The harmonic mean is much more sensitive to low values, so a classifier with high precision but very low recall (or vice versa) gets a low F1 score, whereas an arithmetic mean would hide that imbalance.
When is F1 more useful than accuracy?
F1 is especially valuable on imbalanced datasets where accuracy can be misleadingly high just by predicting the majority class; F1 forces a balance between catching positives (recall) and avoiding false alarms (precision).
What does an F1 score of 1.0 mean?
A perfect F1 score of 1.0 means both precision and recall are 1.0 — every predicted positive was correct, and every actual positive was found, with no false positives or false negatives.
What's the difference between F1 and F-beta score?
F1 weighs precision and recall equally, while the more general F-beta score lets you weight recall beta times more heavily than precision (beta > 1) or vice versa (beta < 1), useful when one error type matters more than the other.