首页 > 解决方案 > 绘制 ROC 曲线 ANN 模型

问题描述

我正在研究我的 ANN 模型并尝试制作结果的 ROC 图。

我对 ROC 代码的输入是 y_test 和预测。

Y_test 的外观:

[0.5875     0.48229167 0.58125    ... 0.54375    0.60729167 0.628125  ]

预测的样子:

[[0.63529354]
 [0.5447516 ]
 [0.5529088 ]
 ...
 [0.5529088 ]
 [0.5894695 ]
 [0.5880237 ]]

评估模型后的部分代码:

predictions = model.predict(X_test)

# Compute ROC curve and ROC area for each class
fpr = dict()
tpr = dict()
roc_auc = dict()

for i in range (len(Y_test)):
    fpr[i], tpr[i], _ = roc_curve(Y_test[i], predictions[:,i])
    roc_auc[i] = auc(fpr[i], tpr[i])

# Compute micro-average ROC curve and ROC area
fpr["micro"], tpr["micro"], _ = roc_curve(Y_test.ravel(), hist.ravel())
roc_auc["micro"] = auc(fpr["micro"], tpr["micro"])

当我尝试运行代码时,出现错误:

    raise ValueError("{0} format is not supported".format(y_type))
ValueError: continuous format is not supported

错误与行和元素 Y_test[i] 有关:

`    fpr[i], tpr[i], _ = roc_curve(Y_test[i], predictions[:,i])`

我的问题是什么?

标签: pythonneural-networkroc

解决方案


推荐阅读