About F1 Score Calculator
This F1 score calculator computes the harmonic mean of precision and recall from your confusion matrix and writes out each step, so you can verify it by hand. It is free, needs no sign-up and runs in your browser, so nothing you enter is uploaded.
F1 uses the harmonic mean rather than the ordinary average because the harmonic mean is dragged toward the smaller of the two numbers. A model with precision 1.0 and recall 0.1 has an F1 of only 0.18, not 0.55, which is the right verdict for a model that finds almost nothing.
F1 ignores true negatives. That is useful when negatives are plentiful and uninteresting, and a drawback when they matter; in that case look at MCC or balanced accuracy as well.
How to use F1 Score Calculator
- Choose "Matrix counts" and set the number of classes, or choose "Actual and predicted labels" and paste the two lists.
- In matrix mode, rows are the actual class and columns the predicted class. Edit the cells and the class names.
- Pick the headline metric: accuracy, precision, recall, specificity, F1, F-beta, MCC, kappa or balanced accuracy.
- For precision, recall and F-scores, choose which class counts as positive. With two classes the first class is the positive one.
- Read the headline value and its explanation, then scroll to the per-class table, the averages and the worked steps.
- Use the copy button to take the metrics into your notes or report.
Features
- Binary and multi-class matrices up to 8 classes, or up to 12 classes built from pasted labels.
- Accuracy, precision, recall, specificity, F1, F-beta, MCC, Cohen's kappa and balanced accuracy in one place.
- Per-class true positive, false positive, false negative and true negative counts.
- Macro, micro and weighted averages for multi-class problems, so you can see how each differs.
- Worked steps with your numbers substituted into every formula, and the formulas rendered in LaTeX.
- A ratio with a zero denominator is shown as n/a instead of a misleading 0.
- Plain-English reading of the headline metric, including a warning about accuracy on imbalanced data.
- Editable class names, so the output reads like your own problem.
F1 formula
F1 is the harmonic mean of precision (P) and recall (R). In terms of counts it is also 2TP over 2TP plus FP plus FN.
F1 = 2 P R / (P + R) = 2 TP / (2 TP + FP + FN)Worked examples
TP 30, FN 20, FP 10, TN 40 gives precision 0.75, recall 0.6, F1 0.6667
Precision is 30 / 40 = 0.75 and recall is 30 / 50 = 0.6. The harmonic mean is 2 x 0.75 x 0.6 / 1.35 = 0.667.
Privacy: how it works
- The matrix and labels you enter are processed by code running in your browser tab. They are not sent to Ulkaa or anyone else.
Tips
- Do not rely on accuracy alone when one class is much rarer than the others. Check recall for that class and the MCC.
- Precision and recall trade against each other. Moving a classifier's decision threshold raises one and lowers the other; the ROC and AUC calculator shows the whole trade-off.
- F1 gives equal weight to precision and recall. Use F-beta with beta above 1 when missing a positive is worse than a false alarm, and below 1 when the reverse is true.
- A metric with an empty denominator, such as precision for a class never predicted, is shown as n/a and left out of macro averages.
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your matrix and labels are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your matrix and labels are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
What is a good F1 score?
It depends on the task. As a rough guide, above 0.9 is excellent, 0.7 to 0.9 is good and below 0.5 is poor, but always compare with a simple baseline on the same data.
Why is F1 a harmonic mean?
The harmonic mean punishes a big gap between precision and recall. Averaging 1.0 and 0.1 normally gives 0.55, but the harmonic mean gives 0.18, which better reflects a model that is lopsided.
What is the difference between macro, micro and weighted F1?
Macro averages the F1 of each class equally, micro pools all counts and equals accuracy for single-label problems, and weighted averages by class size.
More Confusion Matrix Calculator pages
- Confusion Matrix CalculatorEnter a confusion matrix, or paste actual and predicted labels, and get every classification metric with the working.
- Precision and Recall CalculatorEnter your confusion matrix to get precision and recall with the formula worked through.
- Classification Accuracy CalculatorWork out accuracy from a confusion matrix and see when it misleads.
- MCC Calculator (Matthews Correlation Coefficient)Compute the MCC of a classifier from its confusion matrix, with the formula substituted.
- Cohen's Kappa CalculatorMeasure agreement beyond chance between two raters or between a model and the truth.
- Sensitivity and Specificity CalculatorEnter a test's counts to get sensitivity (recall) and specificity, with the working shown.
- F-beta Score CalculatorChoose beta to weight recall or precision more, and get the F-beta score with its working.
- Balanced Accuracy CalculatorAverage the recall of every class so a rare class counts as much as a common one.
- Multi-class Confusion Matrix CalculatorScore a classifier with three or more classes, class by class and on average.
- Confusion Matrix From Actual and Predicted LabelsPaste the true labels and the predictions and get the matrix and its metrics.