ThisCalculator

Everyday

F1 Score Calculator: Precision, Recall and Formula

Updated · Standard formula, shown below

F1 score 0.727
Precision
0.800
Result
Recall
0.667
Result
True positives
40
You entered

F1 Score Calculator: Precision, Recall and Formula

An online F1 score calculator works out the harmonic mean of precision and recall, or calculates it directly from true positives, false positives, and false negatives. Enter the relevant counts or precision and recall, and it returns the F1 score on a scale from 0 to 1.

Formula

The F1 score is the harmonic mean of precision and recall. Using counts, the equivalent formula is:

F1 = 2TP / (2TP + FP + FN)

  • TP is the number of true positives: positive cases correctly identified.
  • FP is the number of false positives: cases incorrectly labeled positive.
  • FN is the number of false negatives: positive cases the model missed.

Precision = TP / (TP + FP), the share of predicted positives that are correct. Recall = TP / (TP + FN), the share of actual positives that are found. Both are proportions without units; multiply by 100 to express either as a percentage. The calculator displays the F1 score and the two component metrics to three decimal places.

Worked Example

Using the default inputs, TP = 40, FP = 10, and FN = 20:

  1. Precision = 40 / (40 + 10) = 0.800.
  2. Recall = 40 / (40 + 20) = 0.667 when rounded to three decimals.
  3. F1 = 2 × 40 / (2 × 40 + 10 + 20) = 80 / 110 = 0.727.

The result is an F1 score of 0.727, equivalent to about 72.7% before rounding to a whole percent. The direct count formula is evaluated without rounding the intermediate precision or recall values.

What the F1 Score Measures

F1 is a classification metric used when a system assigns items to categories, such as identifying spam messages or detecting objects in images. It combines precision and recall into one summary number. A high score requires both metrics to be high; a weak result on either one pulls the F1 score down.

The harmonic mean is used rather than the ordinary arithmetic mean because it penalizes imbalance. For example, precision of 1.00 and recall of 0.10 have an arithmetic mean of 0.55, but their F1 score is about 0.182. That lower figure better reflects that the system misses most relevant cases.

F1 does not count true negatives—the negative cases correctly rejected. Consequently, it is not a complete measure of performance when correct negative classifications matter, too. It also does not explain the practical cost of different types of errors.

When to Use It and How to Read the Result

F1 can be useful when both false alarms and missed positive cases matter, especially when the classes are unevenly represented. The score ranges from 0 to 1: 1 means perfect precision and recall, while 0 indicates no useful overlap under the usual nonzero-denominator conditions. A score of 0.8 is not automatically “good”; judge it against the task, baseline, data, and consequences of errors.

For instance, a search system may need to balance returning relevant results (precision) against finding as many relevant results as possible (recall). In a screening task, missing a positive case may be more costly than reviewing an extra false alarm. F1 gives both errors equal standing in its calculation, so it may not match that task’s priorities.

Compare scores only when the evaluation data, positive-class definition, and averaging method are comparable. A score measured on one dataset or threshold may not transfer to another. For a fair model comparison, calculate metrics on the same held-out evaluation cases and disclose how the score was aggregated.

Choosing Inputs and Avoiding Common Mistakes

Use counts from the same evaluation set and designate the positive class explicitly. Each evaluated item should be counted consistently as a true positive, false positive, false negative, or true negative. The F1 formula needs the first three counts; true negatives are not part of it.

  • Do not swap false positives and false negatives. They represent different errors, even though both appear in the denominator.
  • Do not enter percentages as counts. If you already have precision and recall, use an F1 formula that accepts those two proportions rather than treating them as TP and FP.
  • Avoid premature rounding. Keep full precision during calculation and round only the displayed answer.
  • Check for zero denominators. If there are no predicted positives, precision is undefined; if there are no actual positives, recall is undefined. A dataset with no positive cases can therefore make F1 undefined or dependent on a reporting convention.

For a multi-class problem, a single F1 score requires an averaging choice. Macro-F1 calculates each class’s F1 and averages the class scores equally. Weighted-F1 averages by each class’s support, or number of actual examples. Micro-F1 aggregates counts across classes before calculating the score. These can produce different results, so a simple three-count calculator should not be mistaken for a multi-class averaging tool.

Limits and Related Metrics

F1 does not incorporate true negatives, probability calibration, or the relative costs of errors. It also depends on the decision threshold used to convert model scores into positive or negative predictions. Changing that threshold can change TP, FP, FN, precision, recall, and F1.

Consider the confusion matrix alongside F1 to see the error counts. Depending on the goal, accuracy, specificity, precision, recall, or an F-beta score may answer a more relevant question. F-beta changes the balance between precision and recall: beta greater than 1 gives recall more weight, while beta below 1 gives precision more weight. The appropriate measure depends on what mistakes matter, not on which metric produces the largest number.

Frequently Asked Questions

What is a good F1 score?
There is no universal cutoff. A useful score depends on the problem, class balance, error costs, evaluation data, and comparison baseline. Report the evaluation conditions along with the number.

Can I calculate F1 from precision and recall?
Yes. Use F1 = 2 × precision × recall / (precision + recall), provided their sum is not zero. Use proportions or percentages consistently; the resulting F1 is on the same scale.

Why is F1 lower than the average of precision and recall?
F1 uses a harmonic mean, which is pulled toward the smaller value more strongly than an arithmetic mean. This makes an imbalance between precision and recall reduce the score.

Does F1 include true negatives?
No. The standard F1 formula uses TP, FP, and FN. If correct negative classifications are important, review other metrics or the full confusion matrix as well.

What happens if there are no positive predictions?
Precision has a zero denominator and is mathematically undefined. Software and reporting tools may handle this edge case differently, so state the convention used rather than assuming every tool returns the same value.

Related

Formula used
in tp | True positives | - | 40 | 0
in fp | False positives | - | 10 | 0
in fn | False negatives | - | 20 | 0
out f1 | F1 score | - | 2 * tp / (2 * tp + fp + fn) | 3
out p | Precision | - | tp / (tp + fp) | 3
out r | Recall | - | tp / (tp + fn) | 3

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.