F1 Score, Precision and Recall Calculator
Written by Thierno Sadou Diallo, formula verified per our methodology • Last checked on 12/5/2026
F1 = 2 × precision × recall ÷ (precision + recall), i.e. 2 TP ÷ (2 TP + FP + FN). With 80 true positives, 20 false positives and 10 false negatives: precision 80%, recall 88.9%, F1 score 84.2%.
Explanation
To evaluate a model that sorts items into two categories, whether a spam detector, a screening test or a machine learning model, you start with the confusion matrix. It counts true positives (TP), correctly detected, false positives (FP), wrongly detected, false negatives (FN), missed positives, and true negatives (TN). Two complementary questions follow. Precision, TP ÷ (TP + FP), answers "when the model says yes, is it right?". Recall, TP ÷ (TP + FN), also called sensitivity, answers "of all the real cases, how many does it find?". The two often pull in opposite directions: a very strict filter gains precision but misses cases, a very broad one the reverse. The F1 score sums them up in a single number, their harmonic mean, which stays low as soon as either is weak. Accuracy, the share of all correct answers, seems more intuitive but misleads as soon as classes are imbalanced. In the third example, a model that finds only half of the 60 positive cases and is wrong half the time when it flags a case still reaches 94% accuracy, thanks to the 910 easy negatives; its 50% F1 reflects its limits far better. If no case is predicted positive or there are no real positives, some indicators are undefined and stay empty. Depending on the use, you will favor recall (miss nothing) or precision (avoid false alarms). To reason about the probability that a positive result is true given how common the phenomenon is, use the Bayes' theorem calculator; for basic probabilities, the simple probability calculator.
Example: a spam filter on 1,000 emails
Inputs
TP = 80, FP = 20, FN = 10, TN = 890.
Calculation
Precision = 80 ÷ (80 + 20) = 80%. Recall = 80 ÷ (80 + 10) = 88.9%. F1 = 2 × 80 ÷ (160 + 20 + 10) = 84.2%. Accuracy = (80 + 890) ÷ 1,000 = 97%.
Result
The filter catches 89% of spam, but 20% of what it blocks are real messages; its F1 is 84.2%.
Frequently asked questions
Why a harmonic mean rather than a simple average?
The harmonic mean penalizes imbalance: with 100% precision and 10% recall, a simple average would give 55%, while F1 drops to about 18%, which better reflects a model that misses 90% of cases.
Is recall the same as sensitivity?
Yes, it's the same formula. "Recall" is the usual term in machine learning and information retrieval, "sensitivity" the one used in medicine and epidemiology.
Are there variants of F1?
Yes, the Fβ score gives more weight to recall (β > 1) or to precision (β < 1). For several classes, an F1 is computed per class, then averaged, either simply or weighted by class size.