F1 Score Calculator

F1 score, precision, recall, F-beta, accuracy and MCC from a confusion matrix.

F1 = 2 × precision × recall ÷ (precision + recall) = 2TP ÷ (2TP + FP + FN). With TP = 80, FP = 20 and FN = 40, precision = 0.80, recall = 0.667 and F1 = 0.727.

Free, runs in your browser. Nothing you enter is uploaded.

How to use it

  1. Enter TP, FP and FN from your confusion matrix (TN is optional).
  2. Set beta if recall or precision matters more.
  3. Read precision, recall, F1, F-beta, accuracy and MCC.

What you enter

What you get

Formula

Precision = TP/(TP+FP) | Recall = TP/(TP+FN) | F1 = 2PR/(P+R) | Fβ = (1+β²)PR/(β²P+R)

Worked example

Input: TP 80, FP 20, FN 40

Result: Precision 0.800, recall 0.667, F1 0.727

The model misses a third of real positives; recall is the weak side.

Questions

How do you calculate the F1 score?

F1 is the harmonic mean of precision and recall: 2PR ÷ (P + R). From counts, F1 = 2TP ÷ (2TP + FP + FN).

What is a good F1 score?

It depends on the task and the class balance. Compare against a baseline model; an F1 of 0.7 can be strong for a rare-event problem and weak for an easy one.

Why use F1 instead of accuracy?

With imbalanced classes, a model that always predicts the majority class can score high accuracy but has an F1 of 0 for the minority class.

What does beta do in the F-beta score?

Beta above 1 weights recall more (F2 for screening, where missing cases is costly); beta below 1 weights precision more.

Limitations

References

Related reading

More Statistics

All free tools · By Dr. Zubair Khalid, DVM, MS, PhD.