Confusion Matrix Calculator

Four Numbers That Describe Every Classifier

A binary classifier's entire performance can be summarized in four counts: predictions it got right on the positive class, predictions it got right on the negative class, and the two kinds of mistakes in between. Every other classification metric — accuracy, precision, recall, specificity, F1 — is just a different ratio built from those same four numbers.

The Formula

Accuracy = (TP + TN) / Total × 100
Precision = TP / (TP + FP) × 100
Recall (Sensitivity) = TP / (TP + FN) × 100
Specificity = TN / (TN + FP) × 100
F1 Score = 2 × (Precision × Recall) / (Precision + Recall)

Where This Matters

  • Model evaluation — comparing classifiers on more than just accuracy, which can be misleading on imbalanced data.
  • Threshold tuning — recomputing the matrix at different decision thresholds to trade precision against recall.
  • Medical and fraud detection — fields where false negatives and false positives carry very different real-world costs, making the full matrix more informative than a single accuracy figure.

Worked Example

Metrics computed from TP=80, FP=20, FN=10, TN=90 (Total=200)
MetricFormula result
Accuracy85.00%
Precision80.00%
Recall (Sensitivity)88.89%
Specificity81.82%
F1 Score84.21%

Values computed directly from the formulas above with TP=80, FP=20, FN=10, TN=90.

How to Use This Calculator

  1. Enter True Positives (TP) — correctly predicted positive cases.
  2. Enter False Positives (FP) — negative cases incorrectly predicted positive.
  3. Enter False Negatives (FN) — positive cases incorrectly predicted negative.
  4. Enter True Negatives (TN) — correctly predicted negative cases.
  5. Select Calculate to get accuracy, precision, recall, specificity, and F1 score.

Related Calculations

Focus on just precision and recall with the Precision Recall Calculator, or dig into the combined F1 metric with the F1 Score Calculator.