AI GLOSSARY · AI CONCEPTS
F1 score
Definition
The F1 score is a single number that combines a classifier's precision and recall as their harmonic mean. It is at best 1 and at worst 0, and it gives precision and recall equal weight.
Also called: F1, F-score, F-measure, f1-score, f1 score formula, f1 score machine learning.
In plain language
A classifier can fail in two ways: it can miss real cases, or it can raise false alarms. Recall tracks the first, precision the second. The F1 score blends them into one number so you can compare models quickly. Think of a spam filter: if it flags almost everything it catches all the spam but buries good mail, and F1 reflects that cost. The limits: one number hides which of the two mistakes is happening, it treats both as equally important when yours may not be, and its formula contains no count of correctly rejected cases. When TP, FP and FN are all zero, F1 is undefined; scikit-learn’s zero_division setting controls the returned value.
Technical definition
For a specified class, F1 is 2TP/(2TP+FP+FN), equivalent to the harmonic mean of precision and recall when the ratios are defined. True negatives do not enter. Micro F1 pools counts; macro and support-weighted F1 average per-label F1 values; samples averaging applies per instance in multilabel tasks. Report label selection and undefined-case handling.
Worked examples in this catalogue
Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.
Skill by Skill Almanac · Illustrative, not executed
split-leakage-check 53/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- A check of train, validation and test files for duplicates, shared groups, time and label leakage, printed as JSON.
- Why it exercises the concept
- Check the labelled evaluation data for leakage before computing F1. This skill checks the data; a separate metric implementation computes the score.
Skill by Skill Almanac · Illustrative, not executed
llm-eval-test-sets 57/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- The skill builds and validates an eval dataset for any LLM feature, with a checker for duplicates, missing graders, imbalance and leakage.
- Why it exercises the concept
- F1 is computed against labelled examples. If an LLM feature assigns labels, this skill helps build and check that labelled set. It does not compute F1 itself.
Skill by Skill Almanac · Illustrative, not executed
sample-size-calculator 41/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- Computes the minimum number of subjects per group for a planned comparison of two proportions, two means, or one mean, using the normal approximation.
- Why it exercises the concept
- A contrast case: it plans how many subjects a comparison needs, while F1 scores a classifier on a test set. It does not give the size of a test set needed to trust an F1 figure.
Coding tool · Illustrative, not executed
Claude Code
- What you see
- Claude Code's overview page describes it as an agentic coding tool that reads your codebase, edits files, runs commands, and integrates with your development tools.
- Why it exercises the concept
- A coding agent can call scikit-learn's f1_score on small label lists and show how the average option changes the result on multiclass data.
How it shows up when you use agents
F1 shows up when you ask an agent to evaluate a classifier and it prints a short report: precision, recall, F1. Google's crash course gives precision as TP over TP plus FP, recall as TP over TP plus FN, and F1 as 2 times precision times recall over their sum. An agent may also report several F1 values, which can confuse people.
What breaks when it is misunderstood. With more than two classes, scikit-learn offers micro, macro and weighted averages, and they can give different answers on the same predictions. Its documentation notes that a weighted average can produce a score not between precision and recall. If a report says only "F1" without the average, the number is hard to interpret. See Classification and Ground truth.
Next actions. Ask which average was used and which class counts as positive. Print precision and recall beside F1. Check the test split with split-leakage-check before trusting any of them.
Worked example (illustrative)
For actual labels [0,0,0,1] and predictions [0,0,1,1], scikit-learn gives macro F1 about 0.7333. The harmonic mean of macro precision and macro recall is instead about 0.7895. Macro F1 averages the per-class F1 values; it is not generally computed from the already-averaged precision and recall. These are calculated synthetic labels, not a model-quality result.
Common confusions
- F1 versus accuracy. Accuracy counts all correct predictions, including true negatives. The F1 formula has no true-negative term.
- F1 versus the F-beta family. F1 weights precision and recall equally. Other beta values weight them differently.
- Micro versus macro averaging. Macro is the unweighted mean of per-class F1 scores, giving each included class equal weight. Micro counts totals globally. scikit-learn notes that micro-averaging over all labels in multiclass gives the same value as accuracy.
- Myth. A score of 0 means the model is broken. scikit-learn also returns 0.0 by default when the score is undefined, for example when a class is absent from both labels and predictions.
Related terms
More in AI concepts
Sources
- sklearn.metrics.f1_score, scikit-learn (accessed 2026-11-24)
- Classification: Accuracy, recall, precision and related metrics, Google for Developers (Machine Learning Crash Course) (accessed 2026-11-24)
- 3.4. Metrics and scoring: quantifying the quality of predictions (F-measure), scikit-learn (accessed 2026-11-24)
Definitions are written by Skill Almanac from these sources and were checked against them on 2026-11-24. Wikipedia is never the only source.
Review record
Last verified
Drafted by Claude (original draft) and Codex (automated revisions); sources and example targets checked by Independent automated source review (OpenAI Codex); not human peer review on 2026-11-24. Last verified .
Change log (5)
- : Independent automated factual/example review completed. Cached US query estimate aligned to receipt; no traffic promise. Final technical gate recorded separately; publication disabled. Relevant topic demand only; definition intent unconfirmed.
- : First version.
- : Verifier pass: applied reviewer corrections to unsupported or misattributed claims.
- : Metric and evaluation conventions corrected; independent exact-version review pending.
- : Automated review completed; approved for the staged public release. Search indexing is controlled by the release configuration.