Confusion Matrix calculator

Build a confusion matrix from true positives, false positives, true negatives and false negatives. Get sensitivity, specificity, precision, recall, PPV, NPV, accuracy, F1 and Youden's J, each explained in plain terms.

What it does

Sorts every case into one of four boxes — correctly flagged, wrongly flagged, correctly cleared, wrongly cleared — for one chosen cutoff, and derives every performance measure from those four numbers.

When to use it

Whenever you are going to act on a classifier at a particular threshold. AUC tells you how well a score ranks cases; only the confusion matrix tells you what a decision actually costs.

Worked example

A screening test flags 45 of the 60 people who really have the condition (missing 15), and wrongly flags 30 of the 440 who do not. Sensitivity is 75% and specificity 93% — but of the 75 people it flagged, only 45 truly have it, so precision is 60%. Two in five people told they might be ill are not. That gap is invisible in an AUC.

Cautions

Alternatives

How to read the output

Sensitivity (recall, TPR)
Of everyone who truly has the condition, the share the test flags. TP / (TP + FN). A sensitive test is good at ruling OUT: a negative from a highly sensitive test is reassuring.
Specificity (TNR)
Of everyone who truly does not, the share the test clears. TN / (TN + FP). A specific test is good at ruling IN: a positive from a highly specific test is convincing.
Precision (PPV)
Of everyone the test flagged, the share who truly have it. TP / (TP + FP). This is the number a flagged patient actually cares about — and the one that collapses when the condition is rare.
NPV
Of everyone the test cleared, the share who truly are clear. TN / (TN + FN).
F1 score
The harmonic mean of precision and recall — one number when both matter and you cannot favour either. It ignores true negatives entirely, so it says nothing about how the test treats healthy people.
Youden's J
Sensitivity + specificity − 1. Zero is useless, one is perfect; commonly used to pick a cutoff. It weights the two error types equally, which is rarely true in practice — a missed cancer is not equivalent to a needless recall.

How this calculator is validated · Which statistical test should I use?