· Xiaojing Yang · Machine Learning · 2 min read

中文

Metrics Beyond Accuracy

Accuracy is easy to understand, but often wrong for imbalanced, ranked, or cost-sensitive tasks.

Core idea

A metric is a decision rule about what kinds of mistakes matter.

1. Why accuracy is not enough

Accuracy counts correct predictions. That is fine when classes are balanced and mistakes have similar costs. But many real tasks are imbalanced or cost-sensitive.

Confusion matrix view
TP
Correct positive
FP
False alarm
FN
Missed positive
TN
Correct negative

2. Common metrics

MetricBest when
Accuracybalanced classes, equal costs
Precisionfalse positives are expensive
Recallfalse negatives are expensive
F1need balance between precision and recall
ROC-AUCranking positives above negatives
PR-AUCrare positive class
Macro-F1each class should matter equally

3. sklearn example

from sklearn.metrics import classification_report, f1_score, roc_auc_score

print(classification_report(y_test, y_pred))
macro_f1 = f1_score(y_test, y_pred, average="macro")

4. AI/NLP connection

In NLP, accuracy can hide minority-language failures, rare-label failures, or safety-critical false negatives. In RAG, retrieval accuracy may not mean the answer is grounded. In MT, BLEU alone may hide terminology errors.

Metric choice

Choose based on task risk, class balance, and decision cost.

Research claim

Explain what the metric can and cannot support.

Takeaway

Metrics are not neutral. Choosing a metric is choosing what kind of success the model is allowed to claim.

Interview pattern

When this appears in an interview, I would answer in four layers:

  1. give the short definition;
  2. explain the intuition;
  3. name the common failure mode;
  4. connect it to a real evaluation or deployment decision.

References

Share:
Back to Blog

Related Posts

View All Posts »