Classification Accuracy and Confusion Matrix Calculator
Compute accuracy, precision, recall, specificity and F1 from binary confusion-matrix counts.
Formula
N=TP+TN+FP+FN; accuracy=(TP+TN)/N; precision=TP/(TP+FP); recall=TP/(TP+FN); specificity=TN/(TN+FP); F1=2TP/(2TP+FP+FN). Rates ×100%; MCC∈[−1,1]. FNR=FN/(TP+FN); FPR=FP/(TN+FP); FDR=FP/(TP+FP); MCC=(TP·TN−FP·FN)/√((TP+FP)(TP+FN)(TN+FP)(TN+FN)).
Accuracy ≈ 100×((40)+(50))÷(100) · Error rate ≈ 100×((5)+(5))÷(100) · Precision ≈ 100×(40)÷max((40)+(5),1) · Recall / sensitivity ≈ 100×(40)÷max((40)+(5),1) · Specificity ≈ 100×(50)÷max((50)+(5),1) · F1 score ≈ 200×(40)÷max(2×(40)+(5)+(5),1) · False negative rate ≈ 100×(5)÷max((40)+(5),1) · False positive rate ≈ 100×(5)÷max((50)+(5),1) · False discovery rate ≈ 100×(5)÷max((40)+(5),1) · Matthews correlation ≈ ((40)×(50)-(5)×(5))÷sqrt(max(((40)+(5))×((40)+(5))×((50)+(5))×((50)+(5)),1))
How to use
- Enter true-positive and true-negative counts.
- Enter false-positive and false-negative counts.
- Compare the classification metrics as percentages.
Examples
- 40 TP, 50 TN, 5 FP and 5 FN give 90% accuracy.
Frequently asked questions
What do the counts mean?
TP and TN are correct positive and negative predictions; FP and FN are incorrect positive and negative predictions.
How are zero denominators handled?
At least one case is required. Any undefined metric, including MCC, is reported as 0 by convention.
Is accuracy enough?
No. With imbalanced classes, compare precision and recall as well; a model can have high accuracy while missing rare positives.
Sources
Updated: