Skip to content
Omnikalc

How good is your test or classifier?

Enter the true positives, false positives, false negatives and true negatives: get accuracy, precision, recall, specificity, F1, balanced accuracy, Youden's J and the Matthews correlation coefficient.

Updated on
Your inputs

Value out of range

Value out of range

Value out of range

Value out of range

Results

F1 score

84.2%

Matthews correlation coefficient (MCC)

0.704

Strong agreement between prediction and reality
Accuracy
85.0%
Precision (positive predictive value)
80.0%
Recall (sensitivity)
88.9%
Specificity
81.8%
Balanced accuracy
85.4%
Youden's J statistic
0.707
Prevalence of positives
45.0%

A confusion matrix compares what a test, a classifier or a model predicted with what really happened. It has four counts: true positives (correctly flagged), false positives (flagged by mistake), false negatives (missed) and true negatives (correctly cleared). Many quality measures are built from these four numbers. This calculator computes the main ones together, so you can see more than a single accuracy figure.

How the calculation works

  • Accuracy = (TP + TN) ÷ total
  • Precision = TP ÷ (TP + FP), recall = TP ÷ (TP + FN), specificity = TN ÷ (TN + FP)
  • F1 = 2 × precision × recall ÷ (precision + recall)
  • Balanced accuracy = (recall + specificity) ÷ 2
  • Youden’s J = recall + specificity − 1
  • MCC = (TP × TN − FP × FN) ÷ √((TP + FP)(TP + FN)(TN + FP)(TN + FN))

Example

A classifier finds 80 true positives and 90 true negatives, with 20 false positives and 10 false negatives, out of 200 cases. Accuracy is 85%, precision 80%, recall 88.9% and specificity 81.8%. The F1 score is 84.2%, the balanced accuracy 85.4%, Youden’s J 0.707 and the MCC 0.704, a strong agreement.

Choosing the right measure

When positives are rare, accuracy hides failures, so look at precision and recall. Precision matters when false alarms are costly, as with spam filters; recall matters when missing a case is costly, as with disease screening. F1 combines both for a single score, and the MCC is the most balanced, because it is high only if all four cells are good.

Cautions

These figures describe the data you counted. If the test cases are not representative, or if the prevalence differs in real use, precision and predictive values will change even if sensitivity and specificity stay the same. For a medical test, see how the predictive values depend on prevalence before using the result for decisions.

Frequently asked questions

What is a confusion matrix?

A 2 × 2 table comparing predicted and actual classes: true and false positives, true and false negatives.

When is accuracy misleading?

When one class is rare. A test that always says negative is 99% accurate if only 1% of cases are positive, which is why F1 and MCC are also used.

What is the MCC?

The Matthews correlation coefficient, from −1 to 1, is a balanced measure that uses all four cells and stays meaningful with unbalanced classes.

What is Youden's J?

Sensitivity + specificity − 1. It ranges from 0 (useless) to 1 (perfect) and is used to choose a test threshold.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.