我要对图像进行分类,它大约是7个分类器,并且我想绘制ROC曲线以测量模型的性能
它是不平衡的,所以我尝试通过使用过的数据扩充来平衡火车组,我想用几种工具来衡量性能
enter code here
fpr = dict()
tpr = dict()
roc_auc = dict()
for i in range(num_classes):
fpr[i], tpr[i], _ = roc_curve(y_test[:, i], pred_test[:,i])
roc_auc[i] = auc(fpr[i], tpr[i])
# Plot of a ROC curve for a specific class
for i in range(num_classes):
plt.figure()
plt.plot(fpr[i], tpr[i], label='ROC curve (area = %0.2f)' % roc_auc[i])
plt.plot([0, 1], [0, 1], 'k--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver operating characteristic example')
plt.legend(loc="lower right")
plt.show()
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-51-b620aaf312da> in <module>
8 roc_auc = dict()
9 for i in range(num_classes):
---> 10 fpr[i], tpr[i], _ = roc_curve(y_test[:, i], pred_test[:,i])
11 roc_auc[i] = auc(fpr[i], tpr[i])
12
IndexError: too many indices for array
错误显示索引过多 y_test.shape 给我(1103,7) pred_test.shape 给我(1103,) 我该如何解决每个班级绘制Roc曲线的问题