Skip to content
FiftyCalc Free calculators for all 50 states

Confusion Matrix Calculator

Test cases replayed : 3 of 3 match · Methodology · No outside source listed

Enter the four cells of your confusion matrix to get the standard classification metrics.

Result

Sample figures

F1 score—

Precision (positive predictive value) TP ÷ (TP + FP) —

  • Recall (sensitivity) TP ÷ (TP + FN)—
  • Specificity TN ÷ (TN + FP)—
  • Negative predictive value TN ÷ (TN + FN)—
  • Accuracy (TP + TN) ÷ total—

Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.

Confusion Matrix Calculator

True positives (TP): enter 0 or more. Prefilled example: 85.

False positives (FP): enter 0 or more. Prefilled example: 10.

False negatives (FN): enter 0 or more. Prefilled example: 15.

True negatives (TN): enter 0 or more. Prefilled example: 890.

How to use this calculator

Fill in the fields in this order; each step takes you to its field.

  1. True positives (TP): enter 0 or more.
  2. False positives (FP): enter 0 or more.
  3. False negatives (FN): enter 0 or more.
  4. True negatives (TN): enter 0 or more.
  5. Read the result: F1 score; the panel also shows Precision (positive predictive value) TP ÷ (TP + FP), Recall (sensitivity) TP ÷ (TP + FN), Specificity TN ÷ (TN + FP), Negative predictive value TN ÷ (TN + FN) and Accuracy (TP + TN) ÷ total.

How this calculator works

Precision = TP ÷ (TP + FP); recall = TP ÷ (TP + FN); specificity = TN ÷ (TN + FP); negative predictive value = TN ÷ (TN + FN); accuracy = (TP + TN) ÷ total.

F1 score = 2 × precision × recall ÷ (precision + recall) = 2TP ÷ (2TP + FP + FN), the harmonic mean of precision and recall, between 0 and 1.

The formula

  1. F1=2×tp2×tp+fp+fn
Symbols used in the formula
SymbolMeaning
tpTrue positives (TP)
fpFalse positives (FP)
fnFalse negatives (FN)
F1F1 score

Worked example

True positives (TP)85
False positives (FP)10
False negatives (FN)15
True negatives (TN)890
Precision (positive predictive value) TP ÷ (TP + FP)89.47%
Recall (sensitivity) TP ÷ (TP + FN)85%
Specificity TN ÷ (TN + FP)98.89%
Negative predictive value TN ÷ (TN + FN)98.34%
Accuracy (TP + TN) ÷ total97.5%
  1. F1=2×852×85+10+15=0.871795

F1 score 0.8718

Each step uses the unrounded value of the step before it; figures on this page are rounded for display.

Frequently asked questions

What is the difference between precision and recall?

Precision is the share of predicted positives that are real; recall is the share of real positives that are found.

Why use the F1 score?

It balances precision and recall in one number and, unlike accuracy, is not inflated by a large number of true negatives.

Questions answered

Related calculators