【发布时间】:2021-03-27 05:36:37
【问题描述】:
我有一个不平衡的多类数据集,当我尝试计算 roc_auc_score 时出现此错误:ValueError: Number of classes in y_true not equal to the number of columns in 'y_score'。
代码如下:
model = svm.SVC(kernel='linear', probability=True)
model.fit(X_train, y_train)
y_prob = model.predict_proba(X_test)
macro_roc_auc_ovr = roc_auc_score(y_test, y_prob, multi_class="ovr",
average="macro")
任何解决此问题的建议。
谢谢
【问题讨论】:
-
stackoverflow.com/help/how-to-ask 是关于如何提出好问题的绝佳指南。特别是stackoverflow.com/help/minimal-reproducible-example 有数据代码和你发现的错误是什么
-
欢迎您!
y_test和y_prob的尺寸是多少?如果它们是numpy数组,您应该可以调用y_test.shape和y_prob.shape。 -
y_test.shape = (3661, 38) 和 y_prob.shape = (3661, 40)
-
我也有同样的问题。 @nesrine-bn 找到任何解决方案了吗?
-
没有@Daniel Vilas-Boas,还没有
标签: python roc multiclass-classification imbalanced-data