Explore Courses Blog Tutorials Interview Questions
+4 votes
in Machine Learning by (19k points)

I have come across a few (Machine learning-classification problem) journal papers mentioned evaluate the accuracy with the Top-N approach. Data was show that Top 1 accuracy = 42.5%, and Top-5 accuracy = 72.5% in the same training, testing condition. I wonder how to calculate this percentage of top-1 and top-5?

Can someone show me an example and steps to calculate this?



2 Answers

+6 votes
by (33.1k points)
edited by
Best answer

I’d try to answer in the simplest way that I can.

Top-1 accuracy is the conventional accuracy, which means that the model answer (the one with the highest probability) must be exactly the expected answer.

Top-5 accuracy means that any of your model that gives 5 highest probability answers that must match the expected answer.

Let's say you're applying a machine learning algorithm for object recognition using a neural network. A picture of a cat is shown, and these are the outputs of your neural network:

  • Tiger: 0.4

  • Dog: 0.3

  • Cat: 0.1

  • Lynx: 0.09

  • Lion: 0.08

  • Bird: 0.02

  • Bear: 0.01

In the above-mentioned probabilities:

Using top-1 accuracy, you will count this output as wrong, because it predicted a tiger.

Using top-5 accuracy, you count this output as correct, because the cat is among the top-5 guesses.

I hope this explanation would help you to understand.

If you want to know the real-world applications of Machine Learning then you can go through this video:

To Learn the application of machine learning, and types of machine learning go through this machine learning tutorial.

by (19.7k points)
It worked for me!
by (29.5k points)
well explained!
by (19.9k points)
Thanks for the easy to understand explanation.
Thanks a lot for this answer. According to you, is Top-5 really a good metric, or is it just a way to exaggerate the true capabilities of a neural network?
by (19k points)
Thanks for this clear demonstration.
by (44.4k points)
I think the top-5 metric is pretty useful because a picture can have more details than one object.
by (47.2k points)
top-5 accuracy will always be higher than Top-1 accuracy
by (32.1k points)
Thanks for a nice explanation
by (41.4k points)
Pretty good explaination.
+2 votes
by (108k points)

The complement of the accuracy is the error:

The top-1 error:- The percentage of time that the classifier did not give the correct class the highest probability score.
The top-5 error:- The percentage of time that the classifier did not involve the correct class among the top 5 probabilities or guesses.

by (29.5k points)
Nice explanation..taking error instead of accuracy really puts things into perspective!
by (29.3k points)
Thanks for this explanation. Which is easy to understand the answer.

Browse Categories