我有一个包含多个离散标签的数据集,比如 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)
我假设,我会得到类似于这个后记的东西——但在这种情况下我如何解释阈值? 如何为 knn 模型绘制 ROC 曲线
因此,还请提及在这种情况下我是否可以/应该获得单独的阈值,以及为什么一种方法(统计上)优于另一种方法?
到目前为止我尝试过的(除了平均):
在更改 pos_label = 4 ,然后 5 & 6 并绘制 roc 曲线时,我发现性能非常差,甚至低于 y=x (完全随机且 tpr=fpr 情况)我应该如何解决这个问题?