Confusion Matrix Metrics Calculator
Check five binary-classification metrics from true and false positive and negative counts.
Classification metrics
Enter TP, FP, FN, and TN, then calculate.
- Precision
- —
- Recall (sensitivity)
- —
- Specificity
- —
- F1 score
- —
Undefined denominators stay undefined; they are never replaced with 0% or 100%.
How to use the confusion matrix calculator
Use counts from one binary classification result after deciding which class is positive. This page checks metrics; it does not train or run a model.
- Enter true positives (TP) and false positives (FP).
- Enter false negatives (FN) and true negatives (TN).
- Select Calculate to compute each metric from the four counts.
- Read any undefined message with its exact zero denominator.
- Edit a count to invalidate the old result, or choose Clear to remove all counts.
What the four counts mean
TP and TN are correct predictions for the positive and negative classes. FP predicts positive for an actually negative item; FN predicts negative for an actually positive item. Swapping which class is “positive” changes precision, recall, and specificity.
Metric formulas
Accuracy=(TP+TN)/(TP+FP+FN+TN). Precision=TP/(TP+FP), recall=TP/(TP+FN), specificity=TN/(TN+FP), and F1=2TP/(2TP+FP+FN). F1 is the harmonic balance of precision and recall when defined.
Undefined denominators
A nonempty matrix can still lack predicted positives, actual positives, or actual negatives. The affected ratio then has denominator 0. This calculator keeps that metric undefined instead of silently choosing a replacement value.
Scope and interpretation
- Counts must be nonnegative whole numbers.
- The tool handles one binary class definition, not multiclass averaging.
- Accuracy may look high on imbalanced data, so compare the class-specific metrics.
- No files are uploaded and no model is trained or medically interpreted.
Worked example
For TP=40, FP=10, FN=20, and TN=30, accuracy is 70%, precision 80%, recall 66.67%, specificity 75%, and F1 72.73%.
Frequently asked questions
Why is precision undefined?
There are no predicted positives, so TP+FP equals 0.
Why can recall be 0 but still defined?
If actual positives exist and none are found, TP=0 while TP+FN is positive, so recall is 0.
Does F1 include true negatives?
No. Binary F1 combines positive-class precision and recall.
Is this a medical test calculator?
No. It only checks arithmetic from supplied binary classification counts.