Score a yes/no classifier from its true and false positives and negatives: accuracy, balanced accuracy, precision, recall, F1 and the Matthews correlation coefficient, with a warning when accuracy flatters.
Accuracy = (TP + TN) ÷ total
Positive = the class you're trying to detect (spam, fraud, disease). Top row: predicted positive. Bottom row: predicted negative.
Classification accuracy is the share of all predictions a model gets right. It's the most natural score, and the most misleading when one outcome is much rarer than the other.
If 1% of transactions are fraudulent, a model that never flags anything is 99% accurate and completely useless. This is the accuracy paradox. For rare targets, you need metrics that focus on the positive class.
Precision asks how many flagged cases are real. Recall asks how many real cases were caught. F1 balances the two. The Matthews correlation coefficient (MCC) uses all four counts and stays honest even when classes are badly imbalanced.
As given in Powers (2011) and Chicco & Jurman (2020). See Sources.
MCC is the correlation between predicted and actual labels. It's only high when the model does well on both classes.
The model is slightly less accurate than doing nothing, yet it catches 40% of fraud. Accuracy can't see that trade-off. F1 and MCC show a modest model with room to improve.
| Situation | Focus on |
|---|---|
| Classes roughly balanced, errors equally costly | Accuracy |
| False alarms are expensive (spam filter, arrests) | Precision |
| Missing a case is dangerous (cancer screening) | Recall |
| Rare positive class, one summary number | F1 or MCC |
| Comparing models on imbalanced data | MCC or balanced accuracy |
It depends on the task and the base rate. Compare against a simple baseline and other models on the same data rather than a fixed threshold.
It’s only high when the model does well on positives and negatives, so it can’t be gamed by the majority class.
A metric divides by zero, for example precision when the model flagged nothing. Report it as undefined, not 0 or 100%.
Yes. Machine learning says recall; medicine says sensitivity.
Use the confusion matrix calculator, which gives per-class scores and macro and micro averages.
The average of recall and specificity. A model that always guesses one class scores 50%.
Lower the decision threshold. That usually lowers precision too; choose the trade-off that suits the costs.
No, it ignores true negatives. Swap which class you call positive and F1 changes; MCC doesn’t.
Related Tools
Classification metrics.
Diagnostic test accuracy.
Diagnostic test performance.
Updated diagnostic probability.
Risk ratio comparison.
Event probability.