`
hereson
  • 浏览: 1427601 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

sklearn.metrics中的评估方法介绍

阅读更多

1. sklearn.metrics.roc_curve(true_y. pred_proba_score, pos_labal)

计算roc曲线,roc曲线有三个属性:fpr, tpr,和阈值,因此该函数返回这三个变量,l例如

 


 
  1. import numpy as np  
  2. from sklearn.metrics import roc_curve  
  3. y = np.array([1,1,2,2])  
  4. pred = np.array([0.10.40.350.8])  
  5. fpr, tpr, thresholds = roc_curve(y, pred, pos_label=2)  
  6. fpr      # array([ 0. ,  0.5,  0.5,  1. ])  
  7. tpr      # array([ 0.5,  0.5,  1. ,  1. ])  
  8. thresholds      #array([ 0.8 ,  0.4 ,  0.35,  0.1 ])  
  9. from sklearn.metrics import auc  
  10. metrics.auc(fpr, tpr)  
  11. 0.75  



 

2. sklearn.metrics.auc(x, y, reorder=False):

计算AUC值,其中x,y分别为数组形式,根据(xi, yi)在坐标上的点,生成的曲线,然后计算AUC值;

3. sklearn.metrics.roc_auc_score(true_y, pred_proba_y)

直接根据真实值(必须是二值)、预测值(可以是0/1, 也可以是proba值)计算出auc值,中间过程的roc计算省略

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics