30
$\begingroup$

I'm reading a Scientific paper on image classification. In the experimental results they speak of top-1 and top-5 accuracy but i've never heard of the term, nor can find it using google.

Can someone give me a definition or point me somewhere? :)

$\endgroup$
1
  • 1
    $\begingroup$ For minute there I thought the question was asking about top 1% accuracy. My understanding there, and I could be wrong, is they take the toughest one percent of images from some thing like the image net, and they test against that and report the classification accuracy. $\endgroup$ Commented Dec 28, 2020 at 12:34

2 Answers 2

43
$\begingroup$

In top-5 accuracy you give yourself credit for having the right answer if the right answer appears in your top five guesses.

$\endgroup$
31
$\begingroup$

I found this explanation by one Nathan Yan on Quora

Top-N accuracy means that the correct class gets to be in the Top-N probabilities for it to count as “correct”. As an example, suppose I have a data set of images and the images are a:

  • Dog
  • Cat
  • Dog
  • Bird
  • Cat
  • Cat
  • Mouse
  • Penguin

For each of these input images, the model will predict a corresponding class.

  • Input image: Dog -- Predicted class: Dog ✔
  • Input image: Cat -- Predicted class: Bird ✘
  • Input image: Dog -- Predicted class: Dog ✔
  • Input image: Bird -- Predicted class: Bird ✔
  • Input image: Cat -- Predicted class: Cat ✔
  • Input image: Cat -- Predicted class: Cat ✔
  • Input image: Mouse -- Predicted class: Penguin ✘
  • Input image: Penguin -- Predicted class: Dog ✘

The Top-1 accuracy for this is (5 correct out of 8), 62.5%. Now suppose I also list the rest of the classes the model predicted, in descending order of their probabilities (the further right the class appears, the less likely the model thinks the image is that class)

- Dog => [Dog, Cat, Bird, Mouse, Penguin]
- Cat => [Bird, Mouse, Cat, Penguin, Dog]
- Dog => [Dog, Cat, Bird, Penguin, Mouse]
- Bird => [Bird, Cat, Mouse, Penguin, Dog]
- Cat => [Cat, Bird, Mouse, Dog, Penguin]
- Cat => [Cat, Mouse, Dog, Penguin, Bird]
- Mouse => [Penguin, Mouse, Cat, Dog, Bird]
- Penguin => [Dog, Mouse, Penguin, Cat, Bird]

If we take the top-3 accuracy for this, the correct class only needs to be in the top three predicted classes to count. As a result, despite the model not perfectly getting every problem, its top-3 accuracy is 100%!

$\endgroup$
2
  • 5
    $\begingroup$ You 've just "explained it to me like I am five". Thank you :) $\endgroup$ Commented Dec 26, 2020 at 16:19
  • 1
    $\begingroup$ Very great explanation $\endgroup$
    – ASLAN
    Commented Jul 18, 2021 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.