# How to calculate the percentage of correct answers for the top 5 individuals?

How to calculate the percentage of correct answers for the top 5 individuals?
I made object recognition model using CNN and it worked.
Already succeeded print top-5 answer but want more thing.
I want to print their percentage individually.
Please teach me how to calculate the percentage of correct answers for the top 5 individuals.

from PIL import Image

import numpy as np

import time

def imshow(input):

input = input.numpy().transpose((1, 2, 0))

mean = np.array([0.485, 0.456, 0.406])

std = np.array([0.229, 0.224, 0.225])

input = std * input + mean

input = np.clip(input, 0, 1)

plt.imshow(input)

plt.show()

image = Image.open(‘0008.jpg’)

image = transform_resnet(image).unsqueeze(0).to(DEVICE)

outputs = resnet34_3(image)

indices = torch.topk(outputs, 5).indices

#for x in indices[0]: print(x.item())

#_, preds = torch.topk(outputs, 5)

print('prediction: ')

for x in indices[0]:

print(class_names[x.item()])

imshow(image.cpu().data[0])