Skip to main content
v2026.11,858 entries · CC-BY 4.0

F1 Score Formula: How to Calculate It and What Is Good

F1 score formula with every symbol explained, a worked example, macro/micro averaging rules and an honest answer on what counts as a good F1.

Written and maintained by CASRAI Editorial Board

Last updated

The F1 score is 2 × precision × recall / (precision + recall), the harmonic mean of precision and recall, and it equals 2TP / (2TP + FP + FN) when written with raw counts. It runs from 0 (worst) to 1 (best). This guide gives both forms, a worked example with the arithmetic shown, the averaging rules for multi-class problems, and a direct answer to what counts as a good F1 score.

What is the F1 score? (definition)

The F1 score is a single number that summarises how well a classifier finds the positive cases (recall) without raising too many false alarms (precision). The scikit-learn User Guide describes the F-measure as a weighted harmonic mean of precision and recall, with its best value at 1 and its worst at 0; with beta = 1 the two are weighted equally, which is what makes it “F1”. The score uses only three cells of the confusion matrix (true positives, false positives and false negatives). True negatives never enter the calculation.

F1 score formula, with every symbol explained

Start from the confusion-matrix counts:

  • TP (true positives): positive cases the classifier labelled positive.
  • FP (false positives): negative cases the classifier labelled positive.
  • FN (false negatives): positive cases the classifier labelled negative.

Precision is TP / (TP + FP). Recall is TP / (TP + FN); it is the same quantity that clinical and epidemiological work calls sensitivity (see sensitivity vs specificity). Then:

F1 = 2 × P × R / (P + R) = 2TP / (2TP + FP + FN)

The general form is Fβ = (1 + β²) × P × R / (β² × P + R). Setting β = 1 gives F1; a larger β weights recall more heavily and a smaller β weights precision more heavily.

Because it is a harmonic mean, F1 is pulled toward the lower of the two inputs. A classifier cannot buy a high F1 by maximising one of them while the other collapses, which an ordinary arithmetic mean would allow. For other kinds of average see the geometric mean guide.

Worked example with the arithmetic shown

Suppose a screening classifier is run on 1,000 records and produces TP = 40, FP = 10, FN = 20 and TN = 930 (an illustrative calculation, not data from a study).

  1. Precision = 40 / (40 + 10) = 40 / 50 = 0.800
  2. Recall = 40 / (40 + 20) = 40 / 60 = 0.667
  3. F1 from the harmonic mean = 2 × 0.800 × 0.667 / (0.800 + 0.667) = 1.0667 / 1.4667 = 0.727
  4. F1 from the counts = 2 × 40 / (2 × 40 + 10 + 20) = 80 / 110 = 0.727

Both routes agree. Accuracy for the same table is (40 + 930) / 1,000 = 0.970. The gap between 0.970 and 0.727 appears because the 930 true negatives inflate accuracy but are invisible to F1. Google’s Machine Learning Crash Course notes that F1 is preferable to accuracy for class-imbalanced datasets for this reason.

What is a good F1 score? (interpretation)

There is no universal threshold, and no defensible cut-off such as “0.7 is good”. What the documentation establishes is that F1 ranges from 0 to 1 and that higher is better. Whether a given value is good depends on three things you can check yourself:

  • The baseline. Compare against a trivial model (for example, predicting the positive class for every case) and against the best prior method on the same data.
  • The class balance. The same F1 means something different when positives are 1% of cases than when they are 50%.
  • The relative cost of FP and FN. Google’s Crash Course advises favouring recall when false negatives are costlier and precision when positive predictions must be accurate; F1 treats them as equal.

The table below is computed from the formula, to show how F1 behaves. It is not a grading scale.

Precision Recall F1 What it shows
0.90 0.90 0.900 Equal inputs: F1 equals both
0.80 0.667 0.727 The worked example above
0.90 0.50 0.643 F1 sits closer to the lower value
1.00 0.10 0.182 Perfect precision cannot rescue very low recall

Assumptions and common mistakes

It ignores true negatives

Two classifiers with the same TP, FP and FN have the same F1 however many true negatives they have. Powers (2011) argues that recall, precision, F-measure and Rand accuracy are biased measures, and that a system that is worse on informedness can appear to perform better. If true negatives matter to your question, report specificity or a chance-corrected measure alongside F1, and consider threshold-free summaries such as the ROC curve and AUC.

Macro, micro and weighted averaging

For multi-class or multi-label problems the scikit-learn documentation defines the options as follows:

  • Micro: counts true positives, false negatives and false positives globally across all classes. In a single-label multi-class setting, micro-averaged precision, recall and F1 are all identical to accuracy.
  • Macro: the unweighted arithmetic mean of the per-class F1 scores. It does not take label imbalance into account, and it is not the harmonic mean of the averaged precision and recall.
  • Weighted: the mean weighted by class support. It can produce an F-score that is not between precision and recall.

Always state which average you used; a bare “F1 = .81” for a multi-class model is ambiguous.

Undefined cases

When there are no true positives, no false positives and no false negatives, the denominator is zero. scikit-learn returns 0.0 by default and raises a warning; the zero_division parameter controls this, and since version 1.3 it also accepts np.nan, which excludes such values from the average.

One number hides the trade-off

Report precision and recall as well as F1 so readers can see where the errors fall. If your labels come from human raters, also report agreement; see choosing an inter-rater reliability coefficient and the broader reliability in research measurement guide.

How to report it (APA example)

State the data, the decision threshold, the averaging method and all three values. In APA style, statistics that cannot exceed 1 are written without a leading zero. Example:

On the held-out test set (n = 1,000), the classifier achieved a precision of .80, a recall of .67 and an F1 score of .73 for the positive class.

For a multi-class model add the averaging method, for example “macro-averaged F1 = .73”.

How to calculate the F1 score in Excel, R or Python

Excel

With TP in B1, FP in B2 and FN in B3:

=2*B1/(2*B1+B2+B3)

With the example values (40, 10, 20) this returns 0.7273.

R

tp <- 40; fp <- 10; fn <- 20
precision <- tp / (tp + fp)
recall    <- tp / (tp + fn)
f1 <- 2 * precision * recall / (precision + recall)
round(f1, 3)   # 0.727

Python

from sklearn.metrics import f1_score

y_true = [0, 1, 0, 1]
y_pred = [0, 1, 0, 0]
f1_score(y_true, y_pred)   # 0.6667 (precision 1.0, recall 0.5)

# multi-class: choose the average explicitly
# f1_score(y_true, y_pred, average='macro')

Here TP = 1, FP = 0 and FN = 1, so precision is 1.0, recall is 0.5 and F1 = 2 × 1.0 × 0.5 / 1.5 = 0.667 (equivalently 2 / (2 + 0 + 1)).

FAQ

What is the F1 score?

It is the harmonic mean of precision and recall, ranging from 0 to 1, calculated as 2TP / (2TP + FP + FN). It rewards classifiers that are good at both finding positives and avoiding false alarms.

What is a good F1 score?

There is no universal threshold. Judge it against a trivial baseline, the class prevalence and the relative cost of false positives and false negatives. A value that is excellent for a hard, rare-event task may be poor for an easy balanced one.

Why use F1 instead of accuracy?

Accuracy counts true negatives, so on imbalanced data a model can score high accuracy while missing most positives. F1 uses only TP, FP and FN.

Is F1 the same as the F-measure?

F1 is the special case of the F-beta measure where β = 1 and precision and recall are weighted equally.

Sources

Date checked: 2026-10-29.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about F1 Score Formula: How to Calculate It and What Is Good

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Ask CASRAI · Regulatory Radar

Research-admin question? Get an answer that links its sources.

An AI assistant specialized in research administration. Every answer links its sources to check before you act. 2 questions free, no account. $29/month after.

  • Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.
  • Every answer numbers its sources and links each one, so you can check the source yourself.