Skip to content
Quantoros

Why does top-k accuracy require a score per class rather than only the predicted class label?

Classic MLLevel: IntermediateRanked class evaluation

Why does top-k accuracy require a score per class rather than only the predicted class label?

Hints
  • Recover the candidate ranking.
  • Column order is part of the metric input contract.

Answer

It checks whether the true class is among the k highest-ranked scores. One hard label loses the remaining ordering, and score columns must align with the stated class order.

Source and licence: scikit-learn 1.7.2 — model evaluation · BSD-3-Clause · answer: Quantoros editorial

Related questions