def compute_precision_mapping(pt):
thresh_all = []
prec_all = []
for jj in xrange(1000):
thresh = pt['details']['score'][:, jj]
prec = pt['details']['precision'][:, jj]
ind = np.argsort(thresh); # thresh, ind = torch.sort(thresh)
thresh = thresh[ind];
indexes = np.unique(thresh, return_index=True)[1]
indexes = np.sort(indexes);
thresh = thresh[indexes]
thresh = np.vstack((min(-1000, min(thresh) - 1), thresh[:, np.newaxis], max(1000, max(thresh) + 1)));
prec = prec[ind];
for i in xrange(1, len(prec)):
prec[i] = max(prec[i], prec[i - 1]);
prec = prec[indexes]
prec = np.vstack((prec[0], prec[:, np.newaxis], prec[-1]));
thresh_all.append(thresh)
prec_all.append(prec)
precision_score = {'thresh': thresh_all, "prec": prec_all}
return precision_score
评论列表
文章目录