📐

Machine Learning Confusion Matrix & Classification Metrics Calculator

Math Free Instant Private
Math

### Statistical & Machine Learning Evaluation: The 2x2 Confusion Matrix A confusion matrix tabulates the performance of a supervised binary classification algorithm against known ground-truth.

Reviewed by Miss Saima · MA Mathematics
Last updated:
Editorial Guidelines

⚙ Input Values

📊 Results

Accuracy, F1-Score & Sensitivity/Precision Summary
--
Overall Accuracy
--
F1-Score (Harmonic Mean of Precision & Recall)
--
Sensitivity / Recall / TPR (TP / [TP + FN])
--
Specificity / Selectivity / TNR (TN / [TN + FP])
--
Precision / Positive Predictive Value (PPV)
--
Negative Predictive Value (NPV)
--
Matthews Correlation Coefficient (MCC)
--
Balanced Accuracy & Youden's J-Index
--
✦ Machine Learning Model Evaluation & Error Profile
--
Embed on Your Website

Copy and paste this code into your website.

<iframe src="https://calcusolve.com/calculator/confusion-matrix-calculator?embed=true" width="100%" height="600" frameborder="0" loading="lazy" title="Machine Learning Confusion Matrix & Classification Metrics Calculator"></iframe>

📐 Formula

Machine Learning Confusion Matrix Classification equations:
Accuracy = (TP + TN ÷ TP + TN + FP + FN)
Sensitivity (Recall, TPR) = (TP ÷ TP + FN), Specificity (TNR) = (TN ÷ TN + FP)
Precision (PPV) = (TP ÷ TP + FP), Negative Predictive Value (NPV) = (TN ÷ TN + FN)
F1-Score = 2 × Precision × RecallPrecision + Recall = (2TP ÷ 2TP + FP + FN)
Matthews Correlation Coefficient (MCC) = ((TP × TN) - (FP × FN) ÷ √((TP + FP)(TP + FN)(TN + FP)(TN + FN)))
Balanced Accuracy = Sensitivity + Specificity2, Youden's J = Sensitivity + Specificity - 1

💡 Practical Example

✅

For example, evaluating a medical diagnostic test or ML binary classifier with \, \, \, and \): Overall Accuracy is \. Sensitivity (Recall) is \. Specificity is \. Precision (PPV) is \. The F1-Score is \, and MCC is \(\mathbf{0.8174}\).

📖 About Machine Learning Confusion Matrix & Classification Metrics Calculator

Statistical & Machine Learning Evaluation: The 2x2 Confusion Matrix

A confusion matrix tabulates the performance of a supervised binary classification algorithm against known ground-truth labels:

  • The Four Fundamental Quadrants:
  • True Positives (TP): Actual positive events correctly predicted as positive.
  • True Negatives (TN): Actual negative events correctly predicted as negative.
  • False Positives (FP - Type I Error): Negative events incorrectly predicted as positive (false alarm).
  • False Negatives (FN - Type II Error): Positive events incorrectly predicted as negative (missed detection).
  • The Accuracy Paradox: In imbalanced datasets (e.g. 99% non-fraud, 1% fraud), a trivial model predicting 'no fraud' always achieves 99% accuracy while having 0% sensitivity. F1-Score, Balanced Accuracy, and MCC must be used instead of accuracy on skewed classes.
  • Precision vs. Recall Trade-Off: High Precision is crucial when False Positives are expensive (spam filters), while high Recall is paramount when False Negatives are dangerous (cancer screening, disease detection).
  • Matthews Correlation Coefficient (MCC): Widely considered by statisticians as the single most informative metric because it produces high scores only if the model performs well across all four quadrants.

How to Use This Calculator

Enter your True Positives (TP) (e.g. 85 (Correctly identified positive cases)), False Positives (FP - Type I Error) (e.g. 15 (Negative cases incorrectly called positive)), False Negatives (FN - Type II Error) (e.g. 10 (Positive cases missed / called negative)), and True Negatives (TN) (e.g. 190 (Correctly identified negative cases)). Results update instantly as you type — adjust any value to compare scenarios.

The Formula

Machine Learning Confusion Matrix Classification equations:

Accuracy = (TP + TN) / (TP + TN + FP + FN)

Sensitivity (Recall, TPR) = (TP) / (TP + FN), Specificity (TNR) = (TN) / (TN + FP)

Precision (PPV) = (TP) / (TP + FP), Negative Predictive Value (NPV) = (TN) / (TN + FN)

F1-Score = 2 × (Precision × Recall) / (Precision + Recall) = (2TP) / (2TP + FP + FN)

Matthews Correlation Coefficient (MCC) = ((TP × TN) - (FP × FN)) / (√((TP + FP)(TP + FN)(TN + FP)(TN + FN)))

Balanced Accuracy = (Sensitivity + Specificity) / (2), Youden's J = Sensitivity + Specificity - 1

Worked Example

For example, evaluating a medical diagnostic test or ML binary classifier with and : Overall Accuracy is . Sensitivity (Recall) is . Specificity is . Precision (PPV) is . The F1-Score is and MCC is 0.

8174.

Understanding Your Result

Evaluate your result in the context of your specific use case and relevant industry standards or reference values. A single calculated result is a starting point — test two to three scenarios to understand how sensitive the outcome is to your key input assumptions. For high-stakes decisions, verify your result against a secondary source or subject-matter expert before acting.

💡 Mathematical Rigor & Applied Context

  • This calculator applies exact mathematical definitions following conventions established by NIST and international standards bodies.
  • Rounding errors accumulate across multi-step calculations. For precision-critical work, maintain extra significant figures through all intermediate steps.
  • Many mathematical concepts have multiple valid formulations — if a result seems unexpected, verify which convention or definition applies to your context.
  • Dimensional analysis (unit tracking) is the fastest way to catch formula errors. Every term in an equation must have consistent, compatible units.
  • Numerical methods used in digital calculators introduce floating-point precision limits (~15 significant digits for IEEE 754 double precision).
  • For statistical and probabilistic calculations, always specify whether you are working with population parameters or sample statistics — formulas differ.
  • Visualizing a problem geometrically or testing with known boundary values (zero, infinity, negative) reveals hidden errors faster than algebraic checking.
  • When in doubt, validate your result against a simplified hand calculation or a published worked example from a textbook or standards document.

Results are for informational and educational purposes only. Always verify critical decisions with a qualified professional.

❓ Frequently Asked Questions

What is a confusion matrix?

A confusion matrix is a table that summarizes the prediction results of a classification model, comparing predicted labels against actual ground truth across True Positives, True Negatives, False Positives, and False Negatives.

What is the difference between Precision and Recall?

Precision measures what percentage of positive predictions were correct, while Recall (Sensitivity) measures what percentage of actual positive cases were successfully caught.

What is the F1-Score and when should it be used?

The F1-Score is the harmonic mean of Precision and Recall. It should be used when you need a balanced measure between precision and recall, especially on imbalanced datasets.

Why is Matthews Correlation Coefficient (MCC) superior to accuracy?

MCC takes into account all four cells of the confusion matrix and remains unbiased even when one class is vastly more frequent than the other.

What is Type I error vs. Type II error?

Type I error is a False Positive, while Type II error is a False Negative.

Try Other Calculators