How this calculator works
The table crosses the classifier prediction with a reference class. Precision conditions on positive predictions; recall conditions on reference positives. Specificity conditions on reference negatives. F1 combines precision and recall through their harmonic mean. Matthews correlation incorporates all four cells. If a class or prediction group has no observations, the affected rate is reported as undefined rather than silently set to zero. Reference-label quality and the evaluation population affect interpretation.
Formula
Accuracy = (TP + TN)/N. Precision = TP/(TP + FP). Recall = TP/(TP + FN). Specificity = TN/(TN + FP). F1 = 2TP/(2TP + FP + FN). MCC = (TP×TN - FP×FN)/sqrt[(TP+FP)(TP+FN)(TN+FP)(TN+FN)].
Worked example
With TP = 2, TN = 4, FP = 1 and FN = 3, accuracy is 6/10, precision is 2/3, recall is 2/5, specificity is 4/5 and F1 is 4/8 = 0.5.
Advertisement
Frequently asked questions
Which direction does the table use?
Rows are reference classes and columns are predicted classes. Check labels when copying a table from software that uses the opposite layout.
Why is a rate undefined?
Its denominator is zero. For example, precision cannot be estimated if there are no positive predictions.
Can I compare classifiers using one score?
A single score can hide class imbalance or different error costs. Compare the relevant rates on a representative evaluation set.