Percentages and Math

Confusion Matrix Calculator

Enter the four counts of a confusion matrix to get every common classification measure.

Your numbers

Predicted positive and actually positive. Example counts.

Predicted positive but actually negative.

Predicted negative but actually positive.

Predicted negative and actually negative.

More options

Beta above 1 favors recall, below 1 favors precision.

Result

Accuracy

92.33%

300 cases: precision 86.00%, recall 90.53%.

Accuracy
92.33%
Precision
86.00%
Recall
90.53%
Specificity
93.17%
F1 score
0.8821
Matthews correlation
0.8259

All measures

MeasureValueHow it is found
Accuracy92.33%(TP + TN) / all
Precision (positive predictive value)86.00%TP / (TP + FP)
Recall (sensitivity, true positive rate)90.53%TP / (TP + FN)
Specificity (true negative rate)93.17%TN / (TN + FP)
Negative predictive value95.50%TN / (TN + FN)
False positive rate6.83%FP / (FP + TN)
False negative rate9.47%FN / (FN + TP)
F1 score0.88212 TP / (2 TP + FP + FN)
F-beta score (beta 2)0.8958(1 + b^2) TP / ((1 + b^2) TP + b^2 FN + FP)
Balanced accuracy91.85%(recall + specificity) / 2
Matthews correlation coefficient0.8259(TP TN - FP FN) / sqrt of the four sums
Cohen's kappa0.8253(observed - chance) / (1 - chance)
Positive likelihood ratio13.2556recall / false positive rate
Negative likelihood ratio0.1017false negative rate / specificity
Youden's J0.8370recall + specificity - 1
Prevalence in this data31.67%(TP + FN) / all
How this was calculated
  1. Total cases = 86 + 14 + 9 + 191 = 300. Accuracy = (86 + 191) / 300 = 0.923333.
  2. Precision = 86 / (86 + 14) and recall = 86 / (86 + 9); F1 is their harmonic mean.
  3. The Matthews coefficient and Cohen's kappa use all four cells, so they stay informative when one class is much rarer than the other.
  • These measures describe how a classifier or test performed on the counts you entered. Precision and the predictive values change with how common the positive class is, so they do not carry over to a group with a different mix. This is not medical advice.

Calculated using SumPanda.com · https://sumpanda.com/confusion-matrix-metrics-calculator/

Results are estimates for general information. Verify important figures before relying on them.

Next step

How to use the confusion matrix calculator

  1. Enter the number of true positives, false positives, false negatives and true negatives. The examples show the layout.
  2. Open the options to change beta for the F-beta score. Beta above 1 favors recall and below 1 favors precision.
  3. Read the headline accuracy and the key measures above the table.
  4. Use the table of all measures, with the formula for each, to find the one you need.

Formula

accuracy = (TP + TN) / all, precision = TP / (TP + FP), recall = TP / (TP + FN), specificity = TN / (TN + FP)

F1 = 2 TP / (2 TP + FP + FN), F-beta = (1 + b^2) TP / ((1 + b^2) TP + b^2 FN + FP)

MCC = (TP TN - FP FN) / sqrt((TP + FP)(TP + FN)(TN + FP)(TN + FN))

kappa = (observed agreement - chance agreement) / (1 - chance agreement), Youden's J = recall + specificity - 1

A measure is shown as not defined when its denominator is zero, for example precision when nothing was predicted positive.

A classifier tested on 300 cases

Suppose TP = 86, FP = 14, FN = 9 and TN = 191. Accuracy is 277 / 300 = 92.33%. Precision is 86 / 100 = 86.00%, recall is 86 / 95 = 90.53% and specificity is 191 / 205 = 93.17%. The F1 score is 0.8821 and the F2 score is 0.8958.

The Matthews correlation coefficient is 0.8259 and Cohen's kappa is 0.8253. The negative predictive value is 95.5%, the prevalence in this data is 31.67%, the positive likelihood ratio is 13.26 and the negative likelihood ratio is 0.1017.

Why more than one measure

Accuracy can look good when one class is rare: a model that always says negative is 95% accurate when only 5% of cases are positive. Precision and recall show how well the positive class is handled, F1 combines them, and the Matthews correlation and kappa use all four cells, so they stay informative when the classes are unbalanced.

Precision and the predictive values depend on how common positives are in the group tested, so they do not carry over to a group with a different mix. Sensitivity and specificity are properties of the test itself. To go from them to the chance that a result is right in a given group, use the Bayes Theorem Calculator.

Limits

These measures describe how a classifier or test performed on the counts you enter. They do not carry intervals, and small counts make every measure uncertain. This page is for evaluating models and tests, and it is not medical advice.

More statistics tools

For related statistical tests and measures, try the Test Item Analysis Calculator, Mann-Whitney U Test Calculator and Fisher Exact Test Calculator.

Assumptions and limits

  • The four counts come from one set of cases, each counted in exactly one cell.
  • Positive means the class of interest, and the labels are known.
  • Counts are whole numbers; the example counts are shown until you replace them.
  • Percentages are shown to two decimals and ratios to four.

Formulas reviewed October 10, 2026. See the calculation methodology for how SumPanda rounds, tests and sources its formulas.

Frequently asked questions

What is the difference between precision and recall?

Precision is the share of predicted positives that are really positive. Recall is the share of real positives that were found. A strict model can have high precision and low recall, and the reverse.

What is the F1 score?

It is the harmonic mean of precision and recall, 2 TP divided by 2 TP plus FP plus FN. It is high only when both are high.

When should I use the Matthews correlation coefficient?

Use it when the classes are unbalanced, because it uses all four cells and gives a low value to a model that only predicts the common class.

Why is a measure shown as not defined?

Its formula would divide by zero. For example, precision cannot be worked out when the model never predicts positive.