如何绘制带有2个输出神经元的softmax二进制分类器的ROC曲线?

问题描述 投票:0回答:1

如何绘制离散输出标签为2列的roc曲线?

使用roc_curve()给我一个错误:

ValueError:不支持multilabel-indicator格式

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)
python deep-learning classification roc softmax
1个回答
0
投票

根据文档,y_true和y_score应该为1-d。

https://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_curve.htmly_truearray,shape = [n_samples]

所以,只取标签而不是softmax输出。

在roc_curve()之前添加以下行

test_y = np.argmax(test_y, axis=-1) # getting the labels
y_prediction = np.argmax(y_prediction, axis=-1) # getting the confidence of postive class
© www.soinside.com 2019 - 2024. All rights reserved.