F1 Score: Formula, Worked Example and What Counts as Good

ProductionEvaluationPublished By Simon Budziak

The F1 score is the harmonic mean of precision and recall, a single number from 0 to 1. It is high only when a classifier catches most real positives and raises few false alarms, which makes it the usual summary for imbalanced problems such as fraud, spam or document extraction.

How do you calculate the F1 score?

F1 combines precision and recall with a harmonic mean. F1 = 2 × precision × recall / (precision + recall), which simplifies to 2TP / (2TP + FP + FN) (Google Machine Learning Crash Course, last updated 12 January 2026). Precision is TP / (TP + FP), the share of flags that were real; recall is TP / (TP + FN), the share of real positives caught.

A worked example: 1,000 insurance claims, 50 of them fraudulent. The model flags 60, and 40 of those are fraud, so TP = 40, FP = 20, FN = 10. Precision is 40 / 60 = 0.67, recall is 40 / 50 = 0.80, and F1 is 80 / (80 + 20 + 10) = 0.73. The harmonic mean sits closer to the weaker of the two numbers, so a model cannot buy a high F1 with one strong metric and one poor one.

F1 score vs accuracy: which should you trust?

Accuracy rewards predicting the majority class and F1 does not, as three models on the same 1,000 claims show:

Model Accuracy Precision Recall F1
Flags nothing 0.95 undefined 0.00 0.00
Flags everything 0.05 0.05 1.00 0.10
The model above 0.97 0.67 0.80 0.73

Accuracy rates the useless first model at 95 percent because it gets every legitimate claim right. F1 ignores true negatives, so the majority class cannot inflate it. That is also its blind spot: F1 says nothing about how the model treats the negatives, so read the false positive rate next to it when wrongly flagged customers carry a cost.

What is a good F1 score?

There is no universal threshold; compare against the trivial baseline. A model that flags everything scores 2p / (1 + p), where p is the share of positives: about 0.10 when 5 percent of cases are positive, 0.67 on balanced data. So 0.6 can be a strong result on rare fraud and worse than guessing on a balanced classification task. Published results give a sense of scale: SQuAD reported an F1 of 51.0% for a logistic regression model against 86.8% for humans (Rajpurkar et al., read 16 November 2026). A good F1 beats the trivial baseline on data scored against trusted ground truth. When misses and false alarms cost different amounts, F-beta weights them: in scikit-learn, “beta = 2 makes recall twice as important as precision” (fbeta_score docs, read 16 November 2026).

How does F1 work for multiclass models and in sklearn?

f1_score in scikit-learn 1.9.1 defaults to average='binary', scoring only the positive label (f1_score docs, read 16 November 2026). For more than two classes you choose an average:

average How it combines classes Use it when
macro Unweighted mean of per-class F1 Rare classes matter as much as common ones
micro Global TP, FP and FN counts You want one overall rate
weighted Mean weighted by each class’s support You want class frequency reflected

Macro F1 exposes a model that ignores a rare class; micro F1 hides it. When a class has no predicted or true positives, the default zero_division='warn' returns 0 and raises a warning. Report the per-class scores next to the average, since one number can hide the class that fails.

This entry was drafted with AI assistance.

Frequently asked questions

Is an F1 score of 0.8 good?

Often, but only against a baseline. On data where 5 percent of cases are positive, flagging everything scores about 0.1, so 0.8 is a large lift; on balanced data the same trick scores 0.67, so 0.8 is a modest one.

What is the difference between F1 score and accuracy?

Accuracy counts every correct prediction, including the true negatives. F1 ignores true negatives and scores only how well the model finds the positive class, so it cannot be inflated by predicting the majority class.

Summarize this page with

Train your team to build this