F1 Score Calculator

F1, precision, recall, and accuracy from a binary confusion matrix.

Technology and NetUpdated 2026-10-202 min read
F1 Score Calculator
Positive cases the model found.
Negative cases the model called positive.
Positive cases the model missed.
Negative cases correctly left as negative.
F1 score
...
Precision...
Recall...
Accuracy...

What it does

The F1 score combines precision and recall into one number for a binary classifier. Precision asks how many predicted positives are real; recall asks how many real positives were found.

The four counts in a confusion matrix drive the result. True positives and false positives set precision, true positives and false negatives set recall, and the harmonic mean gives F1. Accuracy uses all four cells but counts true negatives.

The defaults describe 200 predictions: 80 true positives, 20 false positives, 10 false negatives, and 90 true negatives. Precision is 80.0%, recall is 88.9%, F1 is 0.842, and accuracy is 85.0%.

F1 is useful when the positive class is the one you care about and true negatives are plentiful or unimportant. It is a poor headline metric when both classes matter equally or when the cost of a false positive differs sharply from the cost of a false negative.

How to use

  1. Enter true positives, the positive cases the model found.
  2. Enter false positives, the negative cases the model labeled positive.
  3. Enter false negatives, the positive cases the model missed.
  4. Enter true negatives, the negative cases the model labeled negative.
  5. Press Calculate to see precision, recall, F1, and accuracy.
  6. Read F1 with the threshold and the class balance that produced it.

Formula

Precision = TP / (TP + FP). Recall = TP / (TP + FN). F1 = 2 x TP / (2 x TP + FP + FN). Accuracy = (TP + TN) / (TP + FP + FN + TN).
TP
True positives, positive cases correctly predicted.
FP
False positives, negative cases predicted positive.
FN
False negatives, positive cases predicted negative.
TN
True negatives, negative cases correctly predicted.
F1
Harmonic mean of precision and recall.

F1 is undefined when TP, FP, and FN are all zero because there is no positive prediction and no positive case to evaluate. The tool returns an error in that case. A model that predicts only negatives has an F1 of 0 even if its accuracy is high.

Worked example

Example: 80 true positives and 90 true negatives

Defaults: TP = 80, FP = 20, FN = 10, TN = 90.

  1. Precision: 80 / (80 + 20) = 80 / 100 = 80.0 %.
  2. Recall: 80 / (80 + 10) = 80 / 90 = 88.9 %.
  3. F1: 2 x 80 / (2 x 80 + 20 + 10) = 160 / 190 = 0.842.
  4. Accuracy: (80 + 90) / 200 = 170 / 200 = 85.0 %.
  5. The F1 value sits between precision and recall, closer to the lower one.
  6. True negatives affect accuracy but not F1.

Reference table

The four measures from the example
MeasureFormulaValue
PrecisionTP / (TP + FP)80.0 %
RecallTP / (TP + FN)88.9 %
F12TP / (2TP + FP + FN)0.842
Accuracy(TP + TN) / all cases85.0 %

Limits

  • Handles binary classification only, not multiclass averages.
  • Ignores true negatives, so it can look strong on a rare-positive task while missing many negatives.
  • Treats precision and recall as equally important.
  • Depends on the decision threshold and the class distribution in the test set.

Common mistakes

  • Comparing F1 scores from test sets with different class balance.
  • Reporting F1 without precision and recall.
  • Using F1 when false positives and false negatives have very different costs.
  • Forgetting that a model predicting all negatives has F1 of 0.
  • Tuning the threshold on the test set and then reporting that score as new performance.

Try it yourself

Quick checks. Answers sit tucked under each question.

What are precision, recall, and F1 for TP = 40, FP = 10, FN = 10, TN = 40?

Precision 80.0 %, recall 80.0 %, F1 0.800, and accuracy 80.0 %.

What happens with TP = 10, FP = 0, FN = 5, TN = 85?

Precision is 100.0 %, recall is 66.7 %, F1 is 0.800, and accuracy is 95.0 %.

There are no true positives, false positives, or false negatives. What does the tool do?

It returns an error because F1 has no positive prediction or positive case to evaluate.

Questions

What is a good F1 score?

It depends on the task. Compare against a baseline and against the precision and recall you need, not against a universal cutoff.

Why does F1 ignore true negatives?

It is built for the positive class. True negatives can be enormous and would make a weak positive classifier look strong.

Is F1 the same as accuracy?

No. Accuracy counts every correct prediction, including true negatives. F1 balances precision and recall.

Can F1 be high when recall is low?

Not very high. F1 is the harmonic mean, so a low recall pulls it down even if precision is perfect.

Which threshold should I use?

Choose it from validation data using the cost of false positives and false negatives, then report F1 at that threshold.

Does this handle multiclass models?

No. This page is for a single positive class. Multiclass F1 needs macro, micro, or weighted averaging.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.