Confusion matrix metrics

Compare accuracy, precision, recall, specificity, F1 and MCC from binary classification counts.

The example value has been entered. Check it immediately or change the value.

Input is processed in the browser. Refreshing returns a sample value.

Result

Instructions and example

accuracy=(TP+TN)/N; F1=2TP/(2TP+FP+FN); MCC=(TP·TN−FP·FN)/√((TP+FP)(TP+FN)(TN+FP)(TN+FN))

TP=30, FP=10, FN=5, TN=55 give accuracy 0.85, precision 0.75 and F1 0.8.

Each count is an integer from 0 to 1,000,000,000 and the total must be positive. Zero-denominator metrics are undefined, not replaced with 0. Floating-point results display at most 12 significant digits.

Frequently asked questions

How are TP and FP distinguished?

Among predicted positives, TP are actually positive and FP are actually negative. Define the positive class first.

What is precision with no positive predictions?

When TP+FP is 0, precision is undefined. A high accuracy alone does not establish useful recall.

Calculation criteria and reference materials

Verification of calculation criteria: · Calculation·verification principles · Report errors