daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top