python - 绘制 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])`
我的问题是什么?
解决方案
推荐阅读
- excel - bat 文件的过程调用或参数无效
- amazon-web-services - 如何在 AWS lightsail 的网络接口上分配公共 IP
- api - ETHERSCAN API 在本地工作,但在生产中不工作
- r - 恢复最小值以在 R 中应用转换
- routes - 使用 Auth0,withAuthenticationRequired 登录不显示在 Gatsby
- google-analytics-api - GA4 Admin API properties.webDataStreams.getEnhancedMeasurementSettings 似乎已损坏
- flutter - Flutter - 我想在屏幕截图后立即将其显示在屏幕上而不是文件上
- pytorch - init_hidden中出现pytorch数据并行错误
- javascript - 无法从处理 python 脚本的 nodejs 项目中的 JavaScript 函数返回 json 对象?
- asp.net - Kafka是不是一个分区一个通道,一个通道对应一个线程的处理?