Confusion Matrix Calculator
Test cases replayed : 3 of 3 match · Methodology · No outside source listed
Enter the four cells of your confusion matrix to get the standard classification metrics.
Result
F1 score
Precision (positive predictive value) TP ÷ (TP + FP)
- Recall (sensitivity) TP ÷ (TP + FN)
- Specificity TN ÷ (TN + FP)
- Negative predictive value TN ÷ (TN + FN)
- Accuracy (TP + TN) ÷ total
Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.
This browser did not allow copying. The sentence is in the box below, already selected: copy it with your keyboard or the menu.
How to use this calculator
Fill in the fields in this order; each step takes you to its field.
- True positives (TP): enter 0 or more.
- False positives (FP): enter 0 or more.
- False negatives (FN): enter 0 or more.
- True negatives (TN): enter 0 or more.
- Read the result: F1 score; the panel also shows Precision (positive predictive value) TP ÷ (TP + FP), Recall (sensitivity) TP ÷ (TP + FN), Specificity TN ÷ (TN + FP), Negative predictive value TN ÷ (TN + FN) and Accuracy (TP + TN) ÷ total.
How this calculator works
Precision = TP ÷ (TP + FP); recall = TP ÷ (TP + FN); specificity = TN ÷ (TN + FP); negative predictive value = TN ÷ (TN + FN); accuracy = (TP + TN) ÷ total.
F1 score = 2 × precision × recall ÷ (precision + recall) = 2TP ÷ (2TP + FP + FN), the harmonic mean of precision and recall, between 0 and 1.
The formula
| Symbol | Meaning |
|---|---|
| True positives (TP) | |
| False positives (FP) | |
| False negatives (FN) | |
| F1 score |
Worked example
| True positives (TP) | 85 |
|---|---|
| False positives (FP) | 10 |
| False negatives (FN) | 15 |
| True negatives (TN) | 890 |
| Precision (positive predictive value) TP ÷ (TP + FP) | 89.47% |
|---|---|
| Recall (sensitivity) TP ÷ (TP + FN) | 85% |
| Specificity TN ÷ (TN + FP) | 98.89% |
| Negative predictive value TN ÷ (TN + FN) | 98.34% |
| Accuracy (TP + TN) ÷ total | 97.5% |
F1 score 0.8718
Each step uses the unrounded value of the step before it; figures on this page are rounded for display.
Frequently asked questions
What is the difference between precision and recall?
Precision is the share of predicted positives that are real; recall is the share of real positives that are found.
Why use the F1 score?
It balances precision and recall in one number and, unlike accuracy, is not inflated by a large number of true negatives.