Homeglossary

F1 Score

F1 score is a machine learning metric that combines precision and recall to evaluate how well a classification model identifies a target class. It is especially useful when false positives and false negatives both matter. Because it uses a harmonic mean, a low precision or recall score pulls the F1 score down sharply.

Build testable AI apps with Emergent.

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.

  1. Calculate precision: true positives divided by predicted positives.
  2. Calculate recall: true positives divided by actual positives.
  3. Apply F1 = 2 × precision × recall ÷ (precision + recall).
  4. 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.

MetricWhat it measuresBest use
F1 scoreBalance of precision and recall. It ignores true negatives.Rare or important positive classes, such as spam or unsafe content.
AccuracyAll 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.

VersionUse it when
Macro F1Every class matters equally, including rare classes.
Micro F1You want one score from all individual decisions combined.
Weighted F1You want class size to influence the average.
F2 scoreMissing 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.

Start Building
on Emergent today
Start Building