mpre = np.concatenate(([0.], prec, [0.]))
// compute the precision envelope
for i in six.moves.range(mpre.size - 1, 0, -1):
mpre[i - 1] = np.maximum(mpre[i - 1], mpre[i])
// to calculate area under PR curve, look for points
// where X axis (recall) changes value
After Change
mrec = np.concatenate(([0.], rec, [1.]))
mpre = np.concatenate(([0.], prec, [0.]))
mpre = np.maximum.accumulate(mpre[::-1])[::-1]
// to calculate area under PR curve, look for points
// where X axis (recall) changes value
i = np.where(mrec[1:] != mrec[:-1])[0]