将以下代码:

from sklearn.linear_model import LogisticRegression
clf = LogisticRegression(multi_class='multinomial', solver='lbfgs')
fpr, tpr, thresholds = roc_curve(y_train, model.predict(X_train).flatten())
roc_auc = auc(fpr, tpr)

修改为:

fpr, tpr, thresholds = roc_curve(y_train, y_pred)
roc_auc = auc(fpr, tpr)

原因是因为报错提示“multiclass format is not supported”,说明模型对多分类的ROC曲线不支持,而这里的模型是二分类的,因此可以直接使用预测值y_pred来绘制ROC曲线,不需要引入LogisticRegression进行分类。

以下代码在运行绘制ROC曲线时报错报错为:ValueError multiclass format is not supported请修复代码;这个代码为:import numpy as npimport pandas as pdfrom kerasmodels import Sequentialfrom keraslayers import Dense LSTM Dropoutfrom skle

原文地址: https://www.cveoy.top/t/topic/bcgU 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录