Guest User

Untitled

a guest
Jan 21st, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. from sklearn import metrics
  2. from scipy.optimize import brentq
  3. from scipy.interpolate import interp1d
  4. def cal_eer(score_true, score_false):
  5. """ 计算EER
  6.  
  7. Args:
  8. scores_true: 正样例的分数列表
  9. scores_false: 负样例的分数列表
  10.  
  11. Return:
  12. (EER, threshold)
  13. """
  14.  
  15. fpr, tpr, thresholds = metrics.roc_curve([1]*len(score_true)+[0]*len(score_false), score_true+score_false, pos_label=1)
  16.  
  17. eer = brentq(lambda x : 1. - x - interp1d(fpr, tpr)(x), 0., 1.)
  18. thresh = interp1d(fpr, thresholds)(eer)
  19. return eer, thresh
Add Comment
Please, Sign In to add comment