【发布时间】:2014-02-17 21:45:16
【问题描述】:
我有一个包含多个离散标签的数据集,比如 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,然后采取手段(顺便说一下,这是否有意义?) - 然后调用
# 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 情况)我应该如何解决这个问题?
【问题讨论】:
-
发现这篇论文描述了解决类似问题的多个用例ccrma.stanford.edu/workshops/mir2009/references/ROCintro.pdf“ROC 图简介:Tom Fawcett”
-
另一种可能性是网格搜索来计算阈值,从而给出最大 tpr 和最小 fpr。更多信息,stackoverflow.com/questions/13370570/… 和 docs.scipy.org/doc/scipy/reference/generated/…
标签: python-2.7 scikit-learn roc auc