Spaces:
Runtime error
Runtime error
File size: 327 Bytes
e22b55b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import numpy as np
def calc_ranked(preds, labels):
rank1=0
rank5=0
for p,l in zip(preds, labels):
p= np.argsort(p)[::-1]
if l in p[:5]:
rank5+=1
if l==p[0]:
rank1+=1
rank1= float(rank1/len(preds))
rank5= float(rank5/len(preds))
return rank1, rank5 |