%3C/text%3E%3C/svg%3E">
💻
💻 Tech & IT

Confusion Matrix Metrics Calculator (precision, recall, F1, MCC)

Results update as you type.

Your numbers

Understanding the confusion matrix metrics calculator — concept and principle

A confusion matrix counts how a binary classifier's predictions line up with the truth: true positives (TP), false positives (FP), false negatives (FN) and true negatives (TN). These four counts give every common quality metric for spam filters, screening tests and machine-learning models. This calculator returns F1, accuracy, precision, recall, specificity, balanced accuracy and the Matthews correlation coefficient (MCC).

Confusion matrix with TP 85, FP 10, FN 15, TN 890Recall reads across the actual-positive row (85 of 100 = 85%); precision reads down the predicted-positive column (85 of 95 = 89.47%). Accuracy is 97.5%, F1 0.872 and MCC 0.858.1,000 cases sorted into four boxesPredictedpositivenegativeActualpos.neg.TP85FN15FP10TN890Recall85/100= 85%Precision (column) 85 ÷ 95 = 89.47%97.5%accuracy0.872F10.858MCC890 easy negatives inflate accuracy
Recall uses the actual-positive row, precision the predicted-positive column.

How it is calculated

The principle

Each metric answers a different question. Accuracy is easy to inflate when one class dominates: if only 1% of cases are positive, predicting "negative" every time scores 99%. Precision and recall focus on the positive class, and the harmonic mean in F1 punishes a model that is strong on one but weak on the other. MCC is the Pearson correlation between predicted and actual labels, so it uses all four cells and is high only when the model does well on both classes.

Worked example

  1. Counts: TP = 85, FP = 10, FN = 15, TN = 890 (1,000 cases).
  2. Precision = 85 ÷ 95 = 89.47%; recall = 85 ÷ 100 = 85%; specificity = 890 ÷ 900 = 98.89%.
  3. Accuracy = 975 ÷ 1,000 = 97.5%.
  4. F1 = 2 × 0.8947 × 0.85 ÷ 1.7447 = 0.8718.
  5. Balanced accuracy = (0.85 + 0.9889) ÷ 2 = 91.94%.
  6. MCC = (85×890 − 10×15) ÷ √(95×100×900×905) = 75,500 ÷ 87,965 = 0.8583.
How F1 score changes with True positivesHow F1 score changes with True positives0.60.70.80.9121.242.563.885106128170Example: 0.8717948718True positives
Each point is the calculator re-run with only “True positives” changed; the gold point is the default example. Change the inputs above and this chart follows your numbers.
True positivesF1 score
21.20.6296296296
42.50.7727272727
63.80.8360655738
850.8717948718
1060.8947368421
1280.9107142857
1700.9315068493

How to read the result

Here accuracy (97.5%) looks better than F1 (0.87) because negatives outnumber positives nine to one. F1 and MCC range up to 1; MCC runs from −1 (always wrong) through 0 (no better than chance) to +1 (perfect). Choose the metric by cost: when missing a case is costly, watch recall; when false alarms are costly, watch precision.

Common mistakes

Keep in mind: All of these metrics depend on the chosen decision threshold and on the class balance of the test set. For medical tests they describe test performance, not a diagnosis for any individual.

Frequently asked questions

Is recall the same as sensitivity?

Yes, recall, sensitivity and true positive rate are the same quantity.

What is a good F1 score?

It depends on the task and baseline. Compare it with a simple baseline on the same data.

Why is MCC sometimes undefined?

If any row or column of the matrix sums to zero, the denominator is zero; many tools then report 0.

Sources: B. W. Matthews, Comparison of the predicted and observed secondary structure of T4 phage lysozyme, Biochimica et Biophysica Acta, 1975 · D. Chicco and G. Jurman, The advantages of the Matthews correlation coefficient (MCC) over F1 score and accuracy, BMC Genomics, 2020

Checked 8 Nov 2026. Standard formulas and RFC/IEEE definitions, computed locally in your browser — nothing you type is sent anywhere.

💻 All tech & IT tools →🌍 Calculators by country →