Confusion Matrix Calculator

This calculator turns the four raw counts behind any binary classification model - true positives, false positives, false negatives and true negatives - into every standard performance metric analysts and machine learning practitioners rely on. You enter TP, FP, FN and TN from your model's test results (or use the worked defaults of 50, 10, 5 and 35), and the tool builds a live matrix visualisation showing predicted versus actual outcomes alongside the total observations, predicted positives and negatives, and actual positives and negatives. From those counts it instantly returns accuracy, precision, recall (sensitivity), specificity, F1 score and the Matthews correlation coefficient (MCC), plus a fuller breakdown covering false positive rate, false negative rate and negative predictive value. A plain-language verdict summarises what the numbers mean and flags whether performance is strong, moderate or weak based on the MCC. Use it to check a model quickly during development, to compare two classifiers on the same test set, or to understand which trade-off - precision against recall - matters most for your problem. Because accuracy alone can be misleading on imbalanced datasets, pay close attention to the F1 score and MCC alongside it, since both weigh false positives and false negatives more evenly. The calculator applies standard formulas for two-class problems only; multi-class classification needs an extended confusion matrix with macro or micro-averaged metrics instead.

Calculate.co.nz is proud to be partnered with Premium Homes, a recognised leader in eco-friendly, sustainable, and energy-efficient homebuilding. With a dedicated team and award-winning experience, they create homes that prioritise health, comfort, and long-term performance. Their founders, Andrew and Kelly, set out to raise the standard of residential construction in New Zealand by combining practical building expertise with a clear commitment to doing things better for homeowners.
Calculate.co.nz partner: Premium Homes
Standard formulas  Based on standard binary classification evaluation metrics used in statistics and machine learning.

1. Enter Confusion Matrix Values

Please enter valid non-negative numbers (total must be greater than zero).

2. Matrix Visualisation

Predicted → / Actual ↓

Predicted Positive
Predicted Negative
Actual Positive
TP
50
FN
5
Actual Negative
FP
10
TN
35
Total observations: 100

Classification Performance Metrics

Accuracy
85.00%
(TP + TN) / Total
Precision
83.33%
TP / (TP + FP)
Recall (Sensitivity)
90.91%
TP / (TP + FN)
Specificity
77.78%
TN / (TN + FP)
F1 Score
86.96%
Harmonic mean of P & R
MCC
0.698
Matthews Correlation Coeff.

Full Metric Breakdown

True Positives (TP)50
False Positives (FP)10
False Negatives (FN)5
True Negatives (TN)35
Total observations100
Predicted positives60
Predicted negatives40
Actual positives55
Actual negatives45

Derived Metrics

Accuracy85.00%
Precision (PPV)83.33%
Recall / Sensitivity (TPR)90.91%
Specificity (TNR)77.78%
F1 Score86.96%
MCC0.698
False Positive Rate (FPR)22.22%
False Negative Rate (FNR)9.09%
Negative Predictive Value (NPV)87.50%
Summary: Enter your values above to see a performance summary.

Understanding Confusion Matrix Metrics

A confusion matrix is the starting point for evaluating any binary classification model. It records four counts that describe how well a model separates the positive class from the negative class, and from those four numbers every standard classification metric can be derived.

The Four Core Counts

TermSymbolMeaning
True PositivesTPThe model predicted positive and the actual label is positive. Correct positive predictions.
False PositivesFPThe model predicted positive but the actual label is negative. Also called Type I errors or false alarms.
False NegativesFNThe model predicted negative but the actual label is positive. Also called Type II errors or misses.
True NegativesTNThe model predicted negative and the actual label is negative. Correct negative predictions.

Formulas Used in This Calculator

MetricFormulaInterpretation
Accuracy(TP + TN) / (TP + FP + FN + TN)Proportion of all predictions that are correct.
Precision (PPV)TP / (TP + FP)Of all predicted positives, what fraction are actually positive.
Recall / Sensitivity (TPR)TP / (TP + FN)Of all actual positives, what fraction did the model detect.
Specificity (TNR)TN / (TN + FP)Of all actual negatives, what fraction did the model correctly reject.
F1 Score2 * (Precision * Recall) / (Precision + Recall)Harmonic mean of precision and recall. Balances both metrics into one.
MCC(TP*TN - FP*FN) / sqrt((TP+FP)(TP+FN)(TN+FP)(TN+FN))A balanced measure even for imbalanced classes. Ranges from -1 to +1.
False Positive Rate (FPR)FP / (FP + TN)Proportion of actual negatives that are incorrectly classified as positive.
False Negative Rate (FNR)FN / (FN + TP)Proportion of actual positives that are incorrectly classified as negative.
Negative Predictive Value (NPV)TN / (TN + FN)Of all predicted negatives, what fraction are actually negative.

Worked Example

Using the calculator defaults: TP = 50, FP = 10, FN = 5, TN = 35 (total = 100 observations).

Choosing the Right Metric

Accuracy is intuitive but misleading when classes are imbalanced. For example, if 95% of samples are negative, a model that always predicts negative achieves 95% accuracy while being entirely useless for detecting positives.

Precision is critical when false positives are costly (for example, a spam filter that mistakenly blocks legitimate emails). Recall matters more when false negatives are costly (for example, a cancer screening test that misses actual cases). The F1 score balances the two. The MCC is widely considered the most reliable single-value summary for binary classification because it takes all four quadrants of the confusion matrix into account symmetrically.

Related Calculators

Sources and method: Formulas sourced from Fawcett T. (2006), "An introduction to ROC analysis", Pattern Recognition Letters 27(8):861-874; Powers D.M.W. (2011), "Evaluation: From Precision, Recall and F-Measure to ROC, Informedness, Markedness and Correlation", Journal of Machine Learning Technologies 2(1):37-63. MCC formula as defined by Matthews B.W. (1975), Biochimica et Biophysica Acta 405(2):442-451.

This calculator applies standard binary classification evaluation formulas to the values you enter. Results are valid for two-class (binary) problems only. For multi-class classification, an extended confusion matrix and macro/micro-averaged metrics are required.