How to use the F1 Score Calculator
- 1. Choose your dataTwo classes with TP, FP, FN and TN, or a confusion matrix with any number of classes.
- 2. Enter the numbersType the counts, or paste the matrix with actual classes as rows and predicted as columns.
- 3. Read the metricsGet F1, precision, recall and more, with per-class results for matrices.
The formulas
Precision is the share of predicted positives that are right: TP ÷ (TP + FP). Recall is the share of actual positives you found: TP ÷ (TP + FN). F1 is their harmonic mean, 2 × P × R ÷ (P + R), so it's high only when both are high. F-beta weights recall β times as much as precision; F2 suits tasks where missing a positive is worse than a false alarm. For several classes, F1 is computed per class, then averaged: macro treats classes equally, weighted by support, and micro equals accuracy for single-label problems.
Worked example
The defaults are a fraud model with 80 true positives, 20 false positives, 40 false negatives and 860 true negatives. Precision = 80 ÷ 100 = 0.8000, recall = 80 ÷ 120 = 0.6667 and F1 = 0.7273, while F2 is 0.6897. Accuracy looks great at 0.9400, because most cases are easy negatives, but a third of the fraud is missed. For the 3-class matrix example (cat, dog, bird), macro F1 is 0.8719, weighted F1 0.8728 and accuracy 0.8733 over 150 samples.
Checked against scikit-learn
Our tests compare this calculator with scikit-learn's precision_recall_fscore_support, fbeta_score and accuracy_score on 40 random binary cases and 30 random multi-class matrices, and every value matches. Like scikit-learn's default, a class that's never predicted gets precision 0 in the averages.
Frequently asked questions
Which average should I report?
Macro F1 if every class matters equally (including rare ones); weighted F1 if you care about overall performance in proportion to class size. Say which one you used.
Why is F1 better than accuracy for imbalanced data?
F1 ignores true negatives, so a model can't look good just by predicting the majority class.
Is the F1 score calculator free?
Yes. You can open the F1 score calculator and enter all your numbers without signing up. When you calculate for the first time, we ask once for your name and WhatsApp number; after that it, and every other Uncodemy tool, opens straight away.