F1 Score Calculator
Enter your TP, FP, and FN below (or precision and recall). The F1-Score, precision, recall, and 19 other metrics update instantly.
Understanding the F1 Score
What Is the F1 Score?
F1-Score is the harmonic mean of precision and recall, a single number that only stays high when both are high. A simple average of a great precision and a terrible recall still looks decent, but the harmonic mean punishes the imbalance and drags the score down toward the weaker of the two. That's the whole reason to use it: one strong number can't hide one weak one.
F1 Score Formula
The standard form, from precision and recall:
| F1-Score | 2 · Precision · Recall / (Precision + Recall) |
Or directly from the confusion matrix counts, skipping precision and recall as separate steps. The two are algebraically identical:
| F1-Score | 2·TP / (2·TP + FP + FN) |
F-beta: Weighting Precision vs. Recall
F1 treats precision and recall as equally important, but plenty of problems don't. The general form, F-beta, lets you tilt the balance:
- F0.5: weights precision higher. Use it when a false positive is the costlier mistake, such as flagging a legitimate transaction as fraud.
- F1: the balanced case, precision and recall weighted equally.
- F2: weights recall higher. Use it when a false negative is the costlier mistake, such as missing an actual disease case in screening.
The formula: Fβ = (1+β²)·Precision·Recall / (β²·Precision + Recall). Set β=1 and it collapses to the plain F1 formula above.
Worked Example: A Search Engine's Results
A search returns 50 documents for a query. 40 of them are relevant (TP=40) and 10 aren't (FP=10, noise in the results). Across the whole corpus there are 60 relevant documents total, so the 20 relevant ones the search missed are false negatives (FN=20):
| Metric | Formula | Calculation | Result |
|---|---|---|---|
| Precision | TP / (TP+FP) | 40 / 50 | 80% |
| Recall | TP / (TP+FN) | 40 / 60 | 66.67% |
| F1-Score | 2·P·R / (P+R) | 2(.80)(.6667) / (.80+.6667) | 72.73% |
| F0.5 | (1+.25)PR / (.25P+R) | weights precision higher | 76.92% |
| F2 | (1+4)PR / (4P+R) | weights recall higher | 68.97% |
F0.5, F1, and F2 all describe the exact same search results. They just disagree on how much to penalize the 20 relevant documents that got missed versus the 10 irrelevant ones that got shown. Neither is "more correct." Which one matters depends on whether missing results or noisy results costs you more. Try your own counts in the calculator above, or see how F1 fits alongside all 22 metrics in the complete formula reference.
Frequently Asked Questions
What is a good F1 score?
There's no fixed cutoff. It depends on class balance and the cost of each error type. On a balanced task, 0.8+ is generally considered strong and 0.9+ excellent, but the more reliable approach is comparing F1 against a baseline model on your own data instead of a number pulled from nowhere.
How is F1 score different from accuracy?
Accuracy counts every correct prediction, including true negatives. F1 ignores true negatives entirely and only balances precision against recall. On an imbalanced dataset, a model can score high accuracy by mostly predicting the majority class while scoring a low F1, because it's failing on the minority class, which is usually the class that matters.
What is F2 score and how is it different from F1?
F2 is F1's generalization (F-beta) with β=2, which weights recall twice as heavily as precision. Useful when missing a positive case is costlier than a false alarm, like disease screening. F0.5 does the reverse, weighting precision higher, for cases where a false positive is the more expensive mistake.
Can the F1 score be negative or above 1?
No. F1 is the harmonic mean of precision and recall, both proportions between 0 and 1, so F1 always falls in that same range. A score of 1 means perfect precision and perfect recall. 0 means at least one of them is 0.
How do I calculate F1 score from a confusion matrix instead of from precision and recall?
Directly from the counts: F1 = 2·TP / (2·TP + FP + FN). This is algebraically identical to 2·(Precision·Recall)/(Precision+Recall), just without computing precision and recall as separate steps. See the TP/TN/FP/FN definitions if those counts aren't familiar yet.