ROC_AUC百分比计算给NAN
我正在尝试计算数据的ROC分数,但导致NAN。
代码:
scoring = 'roc_auc'
kfold= KFold(n_splits=10, random_state=42, shuffle=True)
model = LinearDiscriminantAnalysis()
results = cross_val_score(model, df_n, y, cv=kfold, scoring=scoring)
print("AUC: %.3f (%.3f)" % (results.mean(), results.std()))
df_n是来自归一化值的数组,我还尝试使用数据集的x数据值尝试。 Y是二进制值的数组。
DF_N形状:( 150,4) Y形:(150,)
我很难过,应该有效!
I am trying to calculate the ROC score for my data but it is resulting in nan.
The code:
scoring = 'roc_auc'
kfold= KFold(n_splits=10, random_state=42, shuffle=True)
model = LinearDiscriminantAnalysis()
results = cross_val_score(model, df_n, y, cv=kfold, scoring=scoring)
print("AUC: %.3f (%.3f)" % (results.mean(), results.std()))
df_n is an array from the normalised values, I also tried it just with the X data value from the dataset.
y is an array of binary values.
df_n shape: (150, 4)
y shape: (150,)
I am stumped, it should work!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题在于
roc_auc_score
期望在多类分类的情况下,而不是预测。但是,使用该代码,得分将获得预测
的输出。使用新得分手:
The problem is that
roc_auc_score
expects the probabilities and not the predictions in the case of multi-class classification. However, with that code the score is getting the output ofpredict
instead.Use a new scorer: