Confusion matrix calculator
Calculate accuracy, precision, recall, specificity and F1 for binary classification. Your inputs stay on your device.
Set up your task
Starting local processing
Ready. Processing stays in this browser.
2 Your result
Your result updates in this browser. Check your input if the result looks unexpected.
How to use Confusion matrix calculator
Calculate accuracy, precision, recall, specificity and F1 for binary classification. The pre-filled problem gives you a worked starting point. Compare the response with your own working before trying the self-check below.
- Check the example inputs: True positives, False positives, False negatives, True negatives.
- Change the inputs for your problem. Results update as you type, so finish entering the values before copying an answer.
- Use the working to check an intermediate value or assumption. Then change the example as suggested in the self-check and compare the result.
Supported inputs and limits
Use non-negative integer counts for the positive and negative outcomes. A metric with a denominator of zero is labelled undefined.
How it works
A binary confusion matrix separates predictions into true positives, false positives, false negatives and true negatives. Accuracy describes correct predictions overall. Precision asks how many predicted positives were real. Recall asks how many actual positives were detected. Specificity asks how many actual negatives were correctly rejected.
F1 is the harmonic balance of precision and recall, expressed from the raw counts. The scores answer different questions, especially when one class is rare. For example, accuracy can look high when the model mostly predicts a common negative class, even though it misses most positives.
Example
Run the pre-filled example. Its first result is “Accuracy: 0.85”.
- True positives
- 30
- False positives
- 10
- False negatives
- 5
- True negatives
- 55
Accuracy: 0.85 Precision: 0.75 · Recall: 0.857142857 Specificity: 0.846153846 · F1: 0.8 Precision conditions on predicted positives. Recall conditions on actual positives.
Questions about Confusion matrix calculator
Which class counts as positive?
Use whichever class the problem identifies as the target. Changing that designation swaps how precision, recall and specificity should be interpreted.
What if there are no predicted positives?
Precision is undefined because its denominator is zero. Recall is still defined when actual positive examples exist.
Set TP and FP to zero, FN to 5 and TN to 95.
Accuracy is 0.95 and recall is zero. The model is accurate overall because the negatives dominate this example.
Related tools
Last updated