Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sklearn import metrics
- from scipy.optimize import brentq
- from scipy.interpolate import interp1d
- def cal_eer(score_true, score_false):
- """ 计算EER
- Args:
- scores_true: 正样例的分数列表
- scores_false: 负样例的分数列表
- Return:
- (EER, threshold)
- """
- fpr, tpr, thresholds = metrics.roc_curve([1]*len(score_true)+[0]*len(score_false), score_true+score_false, pos_label=1)
- eer = brentq(lambda x : 1. - x - interp1d(fpr, tpr)(x), 0., 1.)
- thresh = interp1d(fpr, thresholds)(eer)
- return eer, thresh
Add Comment
Please, Sign In to add comment