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.
⚙ Input Values
📊 Results
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> ⚖ Scenario Comparison
What This Means For You
Saved Calculations
No saved calculations yet.
Click "Save" to bookmark your current result.
📐 Formula
💡 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.