What This Calculator Does
This tool evaluates the performance of a binary classification model by computing three core metrics: precision, recall, and the F1 score. You provide the raw counts from your confusion matrix — true positives (TP), false positives (FP), and false negatives (FN) — and it returns each metric as a percentage. These metrics are universal in machine learning, information retrieval, medical testing, and any field where you classify items into positive and negative categories.
How to Use It
Enter the number of true positives (correctly predicted positives), false positives (negatives wrongly predicted as positive), and false negatives (positives the model missed). Click calculate to see precision, recall, and F1. True negatives are not needed for these particular metrics.
The Formula Explained
\(\text{Precision} = \text{TP} / (\text{TP} + \text{FP})\) answers: "Of everything I flagged as positive, how much was correct?" High precision means few false alarms.
\(\text{Recall} = \text{TP} / (\text{TP} + \text{FN})\) answers: "Of everything that was actually positive, how much did I catch?" High recall means few misses.
The F1 score is the harmonic mean of the two: $$\text{F1} = 2 \cdot \frac{\text{Precision} \cdot \text{Recall}}{\text{Precision} + \text{Recall}}$$. It balances both, useful when classes are imbalanced.
Worked Example
Suppose a spam filter flags 100 emails as spam. Of these, 80 are truly spam (TP) and 20 are not (FP). It also misses 10 real spam emails (FN). $$\text{Precision} = \frac{80}{80 + 20} = 0.80 = 80\%$$ $$\text{Recall} = \frac{80}{80 + 10} = 0.889 = 88.89\%$$ $$\text{F1} = 2 \cdot \frac{0.80 \cdot 0.889}{0.80 + 0.889} = 84.21\%$$
FAQ
When should I favor precision over recall? Favor precision when false positives are costly (e.g., flagging legitimate email as spam). Favor recall when missing positives is costly (e.g., cancer screening).
Why use the F1 score? Accuracy can be misleading with imbalanced data. F1 combines precision and recall into a single balanced number.
What if a denominator is zero? If \(\text{TP}+\text{FP}\) or \(\text{TP}+\text{FN}\) is zero, the metric is undefined; this calculator reports 0% in that case.