Evaluation & Calculate Top-N Accuracy: Top 1 and Top 5

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

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

For instance, let's say you're applying machine learning to 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

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

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


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