Data Science
Accuracy and Loss: Things to Know about The Top 1 and Top 5 Accuracy
Measure the performance of our model

Let assume that we’re working on a simple classification problem using deep learning. We gave the picture (blueberry) as an input to the model and get our prediction results (with probability) as follows.
- cherry: 0.35
- raspberry: 0.25
- blueberry: 0.2
- strawberry: 0.1
- apple: 0.06
- orange: 0.04
How will you evaluate your model? Do you know about the difference between the top-1 and top-5 accuracy?
- Using top-1 accuracy, you count this output as
true, because it predicted a cherry. - Using top-5 accuracy, you count this output as
false, because blueberry is among the top-5 guesses.
We test the model on 5 images and get the following results.

Given this example, our model predicted correctly 2 images and the true label turns up 3 times in the top 5 predicted labels.
Accuracy
What is Accuracy?
It is one of the metrics to describe the accuracy of an algorithm on a classification task. Accuracy is the number of samples that are paired divided by the number of samples.
Accuracy = No of correct predictions / Total no of correcct predicitons
For example: If accuracy comes out to 91%, it means that 91 correct predictions out of 100 total examples.
Top-1 Accuracy
Top-1 accuracy is the conventional accuracy, model prediction (the one with the highest probability) must be exactly the expected answer.
It measures the proportion of examples for which the predictedlabel matches the single target label.
In our case, the top-1 accuracy = 2/5 = 0.4.
Top-5 Accuracy
Top-5 accuracy means any of our model’s top 5 highest probability answers match with the expected answer.
It considers a classification correct if any of the five predictions matches the target label.
In our case, the top-5 accuracy = 3/5 = 0.6.
Today, we have seen the difference between Top-1 Accuracy and Top-5 Accuracy. Keep in mind that: with N >= K then Top-N Accuracy >= Top-K Accuracy. In other words, with a higher the Top-N Accuracy can either get higher or remain the same.
Easy, right?






