Classification Metrics: 5 to Know and When to Use

Accuracy, precision, recall, F1, ROC-AUC — new machine learning practitioners often report whichever metric their code prints first, without asking whether it is the right one. Choosing the wrong classification metrics can make a useless model look great, or a strong model look broken. This guide is a practical map of the main classification metrics: what each measures, when to use it, and a simple decision process for picking the right one.

classification metrics comparison chart

📌
In one line. Every metric here is a ratio of the four cells of a confusion matrix. Understand that table and you understand all of them.

The five classification metrics at a glance

MetricFormulaAnswersBest when
Accuracy(TP+TN)/allOverall share correctClasses are balanced
PrecisionTP/(TP+FP)Are positive predictions trustworthy?False alarms are costly
RecallTP/(TP+FN)Did we catch the positives?Misses are costly
F12PR/(P+R)Balance of precision & recallImbalanced, one number needed
ROC-AUCArea under ROCRanking quality across thresholdsComparing models, balanced data

Accuracy: the tempting trap

Accuracy = (TP + TN) / total. It is intuitive and fine when your classes are roughly balanced. But on imbalanced data it lies: if 99% of cases are negative, a model that always predicts “negative” scores 99% accuracy while catching nothing.

⚠️
The accuracy paradox. A high accuracy number on imbalanced data is the single most common way beginners fool themselves. It is why every metric below exists.

Precision and recall: the workhorses

Precision and recall split “being correct” into two questions. Precision asks whether your positive predictions can be trusted (hurt by false positives). Recall asks whether you caught all the real positives (hurt by false negatives). They trade off as you move the decision threshold:

  • Recall-first: disease screening, fraud, security — a miss is dangerous.
  • Precision-first: spam filtering, content flagging — a false alarm is expensive or annoying.

F1: one number when both matter

When false positives and false negatives are roughly equally bad and you need a single score, use the F1 score — the harmonic mean of precision and recall. It only rewards models good at both, which is why it is the default for imbalanced classification. If the two errors are not equally costly, use the weighted F-beta variant.

ROC-AUC: the threshold-free view

All the metrics above are computed at one fixed threshold. ROC-AUC steps back and measures how well the model ranks positives above negatives across every threshold, as a single number from 0.5 to 1.0. Ideal for comparing models — but on very imbalanced data, prefer PR-AUC, which focuses on the rare positive class.

A simple decision process for classification metrics

🧭
Pick your metric in four questions.
1. Balanced classes? If yes, accuracy is a reasonable headline. If no, skip it.
2. One error much costlier? Missing positives worse → optimise recall. False alarms worse → optimise precision.
3. Need one balanced score? Use F1 (or F-beta to tilt).
4. Comparing models / choosing a threshold later? Use ROC-AUC (or PR-AUC if positives are rare).

See them together in Python

from sklearn.metrics import classification_report, roc_auc_score

print(classification_report(y_true, y_pred))   # precision, recall, F1 per class
print("ROC-AUC:", roc_auc_score(y_true, y_score))

The scikit-learn model evaluation documentation lists every metric and its options.

Frequently asked questions

What is the most important classification metric?
There is no single answer — it depends on class balance and the real-world cost of false positives versus false negatives. The decision process above points you to the right one.
Can I just report accuracy?
Only on balanced data with equal error costs. On imbalanced problems, report precision, recall and F1 (and often ROC-AUC) instead.
Why report several classification metrics at once?
Each metric hides something. Precision ignores misses, recall ignores false alarms, F1 ignores true negatives, and AUC abstracts away the threshold. Reporting a few classification metrics together gives an honest picture.
Do classification metrics differ for multi-class problems?
The same classification metrics apply, but precision, recall and F1 are computed per class and then averaged (macro, micro or weighted). Accuracy and ROC-AUC generalise too, though AUC is usually reported one-vs-rest.

Master the building blocks

Scroll to Top