1. 程式人生 > >[更新ing]sklearn(八):quantifying the quality of predictions

[更新ing]sklearn(八):quantifying the quality of predictions

評估模型預測效果的方法

1、利用模型自帶的score method來評估擬合model的預測效果; 2、利用cross validation來評估擬合model的預測效果,可以通過選用不同的scoring parameter來評估不同型別模型的預測效果; 3、利用metric functions來評估不用型別model的預測效果;

不同型別模型預測效果的評估方法

classification metrics

  • ROC曲線,PR曲線
sklearn.metrics.precision_recall_curve(y_true,probas_pred,pos_label=None,sample_weight=
None) #適用於二分類問題; #以某一threshold判斷決策函式對某一sample的預測概率為p時,該sample是否為positive,如果P>threshold,則為positive,否則為negative;每一個threshold可以得到一個recall,一個precision,根據一系列threshold可以得到一系列的recall,precision,從而可以繪製PR曲線; #該函式返回一系列threshod,recall,precision; sklearn.metrics.roc_curve(y_true,y_score,pos_label=None,sample_weight=
None,drop_intermediate=True) #適用於二分類問題; #返回threshold,tpr,fpr,根據這三個值可作出ROC曲線; sklearn.metrics.balanced_accuracy_score(y_true,y_pred,sample_weight=None,adjusted=False) #適用於二分類和多分類問題; #主要用於處理imbalanced datasets。對於某一imbalanced datasets,如果其大部分label均為1,則即便模型均預測為1,其accuracy依然很高,這顯然不能很好的反應該model的預測效果。balanced accuracy函式很好的克服了這點,能夠更為有效的評估在imbalanced datasets下模型的預測效果,it is defined as
the average of recall obtained on each class.
  • cohen_kappa
sklearn.metrics.cohen_kappa_score(y1,y2,labels=None,weights=None,sample_weight=None)
#返回cohen_kappa係數
#用於評估不同的註釋者對於同一個dataset進行標記的一致性;