· 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.
Correct positive
False alarm
Missed positive
Correct negative
2. Common metrics
| Metric | Best when |
|---|---|
| Accuracy | balanced classes, equal costs |
| Precision | false positives are expensive |
| Recall | false negatives are expensive |
| F1 | need balance between precision and recall |
| ROC-AUC | ranking positives above negatives |
| PR-AUC | rare positive class |
| Macro-F1 | each 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:
- give the short definition;
- explain the intuition;
- name the common failure mode;
- connect it to a real evaluation or deployment decision.