Confusion Matrix Calculator
Calculate confusion matrix using your data.
Loading calculator…
What this tool does
Calculate confusion matrix using your data. Accuracy alone misleads on imbalanced data — a model that never flags a 1%-prevalence condition is 99% accurate and useless. Read precision, recall and specificity together.
How to use the Confusion Matrix Calculator
- Enter or select true positives (tp).
- Enter or select false positives (fp).
- Enter or select false negatives (fn).
- Enter or select true negatives (tn).
- Read the calculated result; change any measurement to compare alternatives.
Formula
accuracy = (TP+TN)/total; precision = TP/(TP+FP); recall/sensitivity = TP/(TP+FN); specificity = TN/(TN+FP); F1 = 2·precision·recall/(precision+recall)
- tp
- True positives (TP)
- fp
- False positives (FP)
- fn
- False negatives (FN)
- tn
- True negatives (TN)
Accuracy alone misleads on imbalanced data — a model that never flags a 1%-prevalence condition is 99% accurate and useless. Read precision, recall and specificity together.
Worked example
For confusion matrix calculator, the following measurements illustrate the exact method: True positives (TP): 80; False positives (FP): 10; False negatives (FN): 20; True negatives (TN): 90.
Inputs
- True positives (TP)80
- False positives (FP)10
- False negatives (FN)20
- True negatives (TN)90
Result
- Accuracy (%)85
- Precision (%)88.89
- Recall / sensitivity (%)80
- Specificity (%)90
- F1 score0.84
- Negative predictive value (%)81.82
- False positive rate (%)10
- Balanced accuracy (%)85
- Total cases200
Results explained
- Accuracy (%)
- Accuracy (%) from the formula above. Accuracy alone misleads on imbalanced data — a model that never flags a 1%-prevalence condition is 99% accurate and useless. Read precision, recall and specificity together.
- Precision (%)
- Precision (%) from the formula above. Accuracy alone misleads on imbalanced data — a model that never flags a 1%-prevalence condition is 99% accurate and useless. Read precision, recall and specificity together.
- Recall / sensitivity (%)
- Recall / sensitivity (%) from the formula above. Accuracy alone misleads on imbalanced data — a model that never flags a 1%-prevalence condition is 99% accurate and useless. Read precision, recall and specificity together.
- Specificity (%)
- Specificity (%) from the formula above. Accuracy alone misleads on imbalanced data — a model that never flags a 1%-prevalence condition is 99% accurate and useless. Read precision, recall and specificity together.
- F1 score
- F1 score from the formula above. Accuracy alone misleads on imbalanced data — a model that never flags a 1%-prevalence condition is 99% accurate and useless. Read precision, recall and specificity together.
- Negative predictive value (%)
- Negative predictive value (%) from the formula above. Accuracy alone misleads on imbalanced data — a model that never flags a 1%-prevalence condition is 99% accurate and useless. Read precision, recall and specificity together.
- False positive rate (%)
- False positive rate (%) from the formula above. Accuracy alone misleads on imbalanced data — a model that never flags a 1%-prevalence condition is 99% accurate and useless. Read precision, recall and specificity together.
- Balanced accuracy (%)
- Balanced accuracy (%) from the formula above. Accuracy alone misleads on imbalanced data — a model that never flags a 1%-prevalence condition is 99% accurate and useless. Read precision, recall and specificity together.
- Total cases
- Total cases from the formula above. Accuracy alone misleads on imbalanced data — a model that never flags a 1%-prevalence condition is 99% accurate and useless. Read precision, recall and specificity together.
Frequently asked questions
accuracy = (TP+TN)/total; precision = TP/(TP+FP); recall/sensitivity = TP/(TP+FN); specificity = TN/(TN+FP); F1 = 2·precision·recall/(precision+recall)
Accuracy alone misleads on imbalanced data — a model that never flags a 1%-prevalence condition is 99% accurate and useless. Read precision, recall and specificity together.
Enter numbers only, in the units and format each label describes. Remove missing values rather than substituting zero, unless zero is a real observation.
No. Results describe the numbers you entered. Statistical inference also depends on sampling design, independence, model fit and interpretation; a p-value is not the probability that a hypothesis is true.
No. Every calculation, including the distribution algorithms, runs entirely in your browser.