F1 Score
What is an F1 score?
F1 score is a machine learning metric that combines precision and recall to measure how well a classification model identifies a target class. It ranges from 0 to 1, where 1 is perfect and 0 means no correct positive cases were found.
How to calculate F1 score from precision and recall
A true positive is a correct flag, a false positive is an incorrect flag, and a false negative is a missed item.
- Calculate precision: true positives divided by predicted positives.
- Calculate recall: true positives divided by actual positives.
- Apply F1 = 2 × precision × recall ÷ (precision + recall).
- If a bug classifier finds 8 bugs, flags 2 clean reports, and misses 2 bugs, precision, recall, and F1 are 0.80.
The harmonic mean prevents a strong result in one measure from masking a weak result in the other. The scikit-learn F1 documentation also gives the formula using true positives, false positives, and false negatives.
F1 score vs. accuracy: which metric is better?
Neither is always better. The right choice depends on the task.
| Metric | What it measures | Best use |
|---|---|---|
| F1 score | Balance of precision and recall. It ignores true negatives. | Rare or important positive classes, such as spam or unsafe content. |
| Accuracy | All correct predictions, including true negatives. | Balanced classes where every prediction has similar importance. |
Benefits of using F1 score
F1 is useful when both kinds of errors matter.
- Balances incorrect alerts and missed positive cases.
- Reveals uneven performance that accuracy can conceal in imbalanced data.
- Supports comparisons between classification models.
- Fits spam filters, fraud checks, bug triage, and AI content classifiers.
Practical limits of F1 score
An F1 score should not be the only release metric.
- It ignores true negatives, which may matter.
- It can hide whether precision or recall causes errors.
- It changes when the decision threshold changes.
- It does not show whether predicted probabilities are well calibrated.
Macro, micro, weighted, and F-beta F1 scores
For multiple labels or classes, averaging choices change what the score emphasizes.
| Version | Use it when |
|---|---|
| Macro F1 | Every class matters equally, including rare classes. |
| Micro F1 | You want one score from all individual decisions combined. |
| Weighted F1 | You want class size to influence the average. |
| F2 score | Missing a positive case matters more than an incorrect alert. |
How to interpret a reasonable F1 score
There is no universal good F1 score. Compare it with a baseline, inspect per-class scores, and review test cases. A low score can mean missed positives, false alerts, or both. Test quality and error costs determine whether a score is acceptable.
Using F1 score when building AI software with Emergent
When creating an AI feature, define what counts as positive, collect realistic examples, and review false positives and false negatives before adjusting a threshold. This helps during app design and development and when comparing AI agent builders. Emergent helps teams build, test, and iterate on AI-powered applications where F1 score can guide quality improvements.
on Emergent today


