Confusion Matrix & Machine Learning Metrics Calculator
Interactive 2x2 grid to calculate Accuracy, Precision, Recall (Sensitivity), Specificity, F1-Score, and Matthews Correlation Coefficient (MCC) with step-by-step formula substitutions and copyable Chapter 4 tables.
How to Calculate Machine Learning Metrics in 3 Steps
Enter your 2x2 counts: True Positives (TP), True Negatives (TN), False Positives (FP), and False Negatives (FN), or pick a benchmark preset.
Review real-time metrics including Accuracy, Precision, Recall, Specificity, F1-Score, and Matthews Correlation Coefficient (MCC).
Examine step-by-step mathematical derivations with values substituted, then copy the APA Chapter 4 model evaluation table.
Benchmark Classification Presets
Select a realistic academic capstone scenario or enter your model's test set evaluation counts below.
2×2 Interactive Confusion Matrix
Rows represent the Actual (True) Class; columns represent the Predicted Class.
Overall proportion of correct predictions across all classes.
Of all positive predictions, the proportion that were actually positive.
Of all actual positive cases, the proportion correctly detected by the model.
Balanced balance between Precision and Recall. Best for skewed classes.
Advanced Epidemiological & Capstone Metrics Derived from 2×2 contingency matrix
Step-by-Step Formula Arithmetic Substitutions
Show these exact calculations in Chapter 4 of your thesis to substantiate the credibility of your machine learning algorithms.
Formula: (TP + TN) / (TP + TN + FP + FN)
Substitution: ( + ) / ( + + + )
= / = (%)
Formula: TP / (TP + FP)
Substitution: / ( + )
= / = (%)
Formula: TP / (TP + FN)
Substitution: / ( + )
= / = (%)
Formula: 2 × (Precision × Recall) / (Precision + Recall)
Substitution: 2 × ( × ) / ( + )
= (%)
Chapter 4 Classification Performance Table & APA Narrative
Pre-formatted table and empirical summary ready for your IT, Computer Science, or Data Science capstone report.
| Performance Metric | Mathematical Formula | Decimal Value | Percentage | Evaluation Interpretation |
|---|---|---|---|---|
| Overall Accuracy | (TP + TN) / N | |||
| Precision (PPV) | TP / (TP + FP) | |||
| Recall / Sensitivity | TP / (TP + FN) | |||
| Specificity (TNR) | TN / (TN + FP) | |||
| F1-Score | 2PR / (P + R) | |||
| Matthews Corr (MCC) | (TP×TN - FP×FN) / √V | - |
How to Compute Accuracy, Precision, Recall, and F1-Score from a Confusion Matrix
A definitive methodological guide for Computer Science, Information Technology, and Engineering undergraduate and graduate researchers.
1. What is a Confusion Matrix in Machine Learning?
When training predictive models such as Convolutional Neural Networks (CNNs), Support Vector Machines (SVMs), Random Forests, or Logistic Regression classifiers, reporting a single aggregated percentage is rarely adequate. A Confusion Matrix is a specific 2 × 2 contingency table that maps the algorithmic predictions against the empirical ground-truth benchmark across a testing dataset (N).
The matrix breaks classification predictions into four distinct quadrants:
- True Positives (TP): Positive events correctly identified by the algorithm (e.g., patient with dengue fever flagged as positive).
- True Negatives (TN): Negative events correctly identified as healthy/normal (e.g., healthy patient flagged as negative).
- False Positives (FP / Type I Error): Negative cases incorrectly flagged as positive (e.g., benign email classified as spam).
- False Negatives (FN / Type II Error): Positive cases missed by the algorithm and flagged as negative (e.g., malignant tumor classified as normal).
2. Fundamental Formulas & Step-by-Step Mathematical Derivations
Proportion of all test samples that were correctly classified.
Measures reliability of affirmative predictions. Minimizes false alarms.
Measures coverage of actual positives. Vital when false negatives carry lethal consequences.
Harmonic average penalizing extreme disparity between Precision and Recall.
3. The Accuracy Paradox & Class Imbalance in Capstone Research
A common methodological trap in Philippine IT and CS thesis defense panels is relying solely on Accuracy. If a researcher tests a credit card fraud detection model on a dataset containing 9,900 legitimate transactions and 100 fraudulent transactions (a 99:1 class ratio), a dummy classifier that unconditionally outputs "Legitimate" will score an impressive 99.0% Accuracy.
However, its Recall for fraud is exactly 0.0% because every single financial breach was missed (FN = 100). In scenarios with skewed target prevalences, researchers must report the F1-Score and the Matthews Correlation Coefficient (MCC). MCC factors all four quadrants simultaneously and remains invariant to class ratios, returning 0 for any trivial majority-class guessing strategy.
4. Choosing Between Precision and Recall in Domain Projects
When to Prioritize Recall (Minimize FN):
- Medical Diagnoses: Cancer detection, pneumonia X-ray screening, tuberculosis smear tests.
- Disaster Management: Structural earthquake fault detection, flood warnings.
- Rationale: The cost of missing an actual case (FN) is catastrophic compared to running a secondary confirmatory test for an FP.
When to Prioritize Precision (Minimize FP):
- Spam Filters: Email filtering, SMS phishing blocklists.
- Automated Bans: Academic integrity proctoring flags, automated account suspensions.
- Rationale: Misclassifying a critical legitimate email or innocent student (FP) destroys system trust.
5. How to Format Chapter 4 Results for Thesis Defense
According to APA 7th edition and standard ACM/IEEE guidelines, researchers must display both the absolute integer counts in a matrix table and the normalized decimal ratios. When writing the narrative, state the total testing partition size (N), identify which class constitutes the positive target, state the benchmark thresholds, and explain the trade-offs observed between Precision and Recall.