F1 Score Calculator

The F1 score balances precision and recall in one number: their harmonic mean. It is the go-to single metric for imbalanced classification, where accuracy is misleading. Enter the four confusion-matrix counts and get F1, plus the precision and recall it combines.

Correctly predicted positives.

Predicted positive but actually negative.

Predicted negative but actually positive.

Correctly predicted negatives.

Result

Enter your values and press Calculate — the result appears here.

Worked examples

The classic trade-off

  • tp = 50
  • fp = 10
  • fn = 5
  • tn = 35

Result: F1 0.8696 (precision 0.8333, recall 0.9091)

Perfect and terrible

  • tp = 30
  • fp = 0
  • fn = 0
  • tn = 70

Result: F1 1.00 (perfect)

Zero positives predicted

  • tp = 0
  • fp = 0
  • fn = 15
  • tn = 85

Result: F1 undefined — no positive predictions

Frequently asked questions

What makes F1 better than accuracy?

On imbalanced data, a model that always predicts the majority class gets high accuracy but terrible recall. F1 combines precision and recall, so it only rewards a model that is both precise and complete — no free lunch from class imbalance.

Why is the harmonic mean used instead of a simple average?

The harmonic mean is dominated by the smaller of the two values: a model with precision 1.0 but recall 0.0 gets an F1 of 0, not 0.5. It punishes lopsided performance, which is what you want from a single summary metric.

When is F1 undefined?

F1 divides by (precision + recall). If the model never predicts positive (TP + FP = 0) or there are no actual positives (TP + FN = 0), both precision and recall are undefined and so is F1.

💬 Discuss on BestWordz Community

Join the conversation about Machine Learning, f1 score, f1 calculator on the BestWordz Community forum.

Visit Forum →
Copied!