AIExplainer
Machine Learning Mathematics Intermediate 2 min read

What is top-k accuracy?

A metric used to evaluate the performance of a model by measuring the proportion of times the correct answer is among the top k predictions

Top-k accuracy is a way to measure how well a model is doing by checking if the correct answer is in the model's top k guesses. For example, if k is 5, the model is considered correct if the actual answer is among its top 5 predictions.

Imagine you're trying to guess the name of a movie. Top-k accuracy is like checking if the correct movie title is in your list of top k guesses. If it is, you get a point, even if it's not your number one guess.

In a self-driving car, the model might use top-k accuracy to recognize street signs. If the model thinks the top 3 possibilities are 'stop', 'yield', and 'merge', and the actual sign is 'stop', the model gets credit for being correct, even if 'stop' wasn't its number one guess.

Top-k accuracy is often used in image and speech recognition tasks, where the model may produce a list of possible answers. It's a more lenient metric than exact accuracy, which requires the model to get the answer exactly right.

One common misconception is that top-k accuracy is always a better metric than exact accuracy. However, this depends on the specific task and what's being measured. In some cases, exact accuracy may be more important.

Top-k accuracy has been used in machine learning for many years, particularly in tasks where the model produces a probability distribution over multiple possible answers.

top-k score k-accuracy accuracy at k

Three products for different needs — explore what’s relevant to you.