def optimize_threshold_with_f1(f1c, thresholds, criterion='max'):
#f1c[np.isnan(f1c)] = 0
if criterion == 'max':
ti = np.nanargmax(f1c)
else:
ti = np.nanargmin(np.abs(thresholds-0.5*f1c))
#assert(np.all(thresholds>=0))
#idx = (thresholds>=f1c*0.5-mp) & (thresholds<=f1c*0.5+mp)
#assert(np.any(idx))
#ti = np.where(idx)[0][f1c[idx].argmax()]
return thresholds[ti], ti
评论列表
文章目录