What is top-k accuracy and when do you use it?
easyAnswer
- Top-k counts a prediction as correct if the true class is among the top-k predicted classes ranked by score.
- Common in image classification with many classes (ImageNet top-5), recommender systems (was the right item in the top-10 recommendations?), and retrieval-style tasks.
- Top-k relaxes the single-choice requirement — appropriate when downstream UX shows multiple candidates.
- Report both top-1 and top-k for calibration between raw and forgiving evaluation.
Check yourself — multiple choice
- Top-k means only k classes are used
- Correct if the true label is among the top-k predicted classes — useful for many-class or recommender tasks
- Same as accuracy
- Only for regression
Top-k = true class in top-k predictions. Useful when downstream UX shows a shortlist.
#metrics#classification#multiclass
Practise Supervised Learning
215 interview questions in this topic.
Related questions
- Macro vs micro vs weighted averaging in multi-class metrics — how do you choose?
- Precision vs recall — when do you optimize each?
- How do you read a confusion matrix and derive the key metrics?
- One-vs-Rest, One-vs-One, and softmax — how do you choose for multi-class?
- 'multinomial' vs 'ovr' setting in scikit-learn's LogisticRegression — what changes?
- Why is accuracy a bad primary metric for many real-world problems?