如何将离散输出标签作为两列绘制roc曲线
使用roc_曲线()会给我一个错误:
ValueError:不支持多标签指示器格式
y_prediction = model.predict(test_X)
y_prediction[1]
Out[27]: array([1.0000000e+00, 6.8178085e-12], dtype=float32)
y_prediction.shape
Out[23]: (514, 2)
test_y.shape
Out[24]: (514, 2)
fpr_roc, tpr_roc, thresholds_roc = roc_curve(test_y, y_prediction)
roc_auc = metrics.auc(fpr_roc, tpr_roc)
由于sklearn中的
roc_curve
函数只需要正类概率估计,因此可以使用与正类相关的输出维度例如:
preds[:, -1]
根据文档,y_真值和y_分数应为1-d
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_curve.html
y\u truearray,shape=[n\u示例]
因此,只需获取标签,而不是softmax输出
在roc_曲线()之前添加以下行
相关问题 更多 >
编程相关推荐