我有一个带有多个离散标签的数据集,比如4,5,6。在此我运行ExtraTreesClassifier(我也将在相同的数据上运行Multinomial logit afterword,这只是一个简短的例子),如下所示。 :
from sklearn.ensemble import ExtraTreesClassifier
from sklearn.metrics import roc_curve, auc
clf = ExtraTreesClassifier(n_estimators=200,random_state=0,criterion='gini',bootstrap=True,oob_score=1,compute_importances=True)
# Also tried entropy for the information gain
clf.fit(x_train, y_train)
#y_test is test data and y_predict is trained using ExtraTreesClassifier
y_predicted=clf.predict(x_test)
fpr, tpr, thresholds = roc_curve(y_test, y_predicted,pos_label=4) # recall my labels are 4,5 and 6
roc_auc = auc(fpr, tpr)
print("Area under the ROC curve : %f" % roc_auc)
问题是 - 是否存在类似于平均ROC曲线 - 基本上我可以将所有tpr& fpr单独为EACH标签值然后采取手段(顺便说一下是否有意义?) - 然后只需调用
# Would this be statistically correct, and would mean something worth interpreting?
roc_auc_avearge = auc(fpr_average, tpr_average)
print("Area under the ROC curve : %f" % roc_auc)
我假设,我会得到类似于这个后记的内容 - 但在这种情况下如何解释阈值? How to plot a ROC curve for a knn model
因此,请同时提及我是否可以/应该在这种情况下获得个别阈值,为什么一种方法比另一方更好(统计学上)?
到目前为止我尝试过的(除了平均值):
在改变pos_label = 4,然后5& 6并绘制roc曲线,我看到非常差的性能,甚至小于y = x(完全随机和tpr = fpr情况)我应该如何处理这个问题?
答案 0 :(得分:3)
Hand & Till in 2001提出了ROC曲线平均值。它们基本上计算所有比较对的ROC曲线(4对5,4对6和5对6)并对结果取平均值。
当您使用pos_label=4
计算ROC曲线时,您隐含地说其他标签是底片(5和6)。请注意,这与Hand& amp;提出的略有不同。为止。
一些注意事项:
pos_label=5
中说roc_curve
,并且您的分类器已经开始将5识别为4到6之间的中间值,那么您肯定会在这里没有任何用处