我的 ROC 曲线的尺寸不正确
我对机器学习非常陌生,我的任务是创建 ROC 曲线。我收到错误 ValueError: 发现样本数量不一致的输入变量: [200, 400]。 这是我的 ROC 曲线代码的图片。
import sklearn.metrics as metrics
from sklearn.metrics import roc_curve, auc
y_pred = basic_model.predict(X_test).ravel()
nn_fpr_keras, nn_tpr_keras, nn_thresholds_keras = roc_curve(y_test, y_pred)
auc_keras = auc(nn_fpr_keras, nn_tpr_keras)
plt.plot(nn_fpr_keras, nn_tpr_keras, marker='.', label='Neural Network (auc = %0.3f)' % auc_keras)
我实际上知道问题是什么,我正在使用“sparse_categorical_crossentropy”来损失。(我的顾问说我必须使用它)。基本上他们还告诉我,现在我所要做的就是将我的 X_test 从 2D 数组更改为 1D 数组。我尝试使用 .flatten() 但这没有帮助?关于我应该做什么或我可以学习的任何资源有什么想法吗?
im really new to machine learning and was tasked with creating a ROC curve. I get the error ValueError: Found input variables with inconsistent numbers of samples: [200, 400].
Here is a picture of my code for the ROC curve.
import sklearn.metrics as metrics
from sklearn.metrics import roc_curve, auc
y_pred = basic_model.predict(X_test).ravel()
nn_fpr_keras, nn_tpr_keras, nn_thresholds_keras = roc_curve(y_test, y_pred)
auc_keras = auc(nn_fpr_keras, nn_tpr_keras)
plt.plot(nn_fpr_keras, nn_tpr_keras, marker='.', label='Neural Network (auc = %0.3f)' % auc_keras)
I actually know what the problem is I am using 'sparse_categorical_crossentropy' for loss.(My advisor said I had to use it). Basically They also told me that now all I have to do is to change my X_test go from a 2D array to a 1D array. I have tried to use .flatten() but that didn't help? Any ideas on what I should do or any resources that I could study?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只需要设置 X_train=X_train[;,0]
Ravel() 似乎不起作用。
I just needed to set X_train=X_train[;,0]
Ravel() seems to not work.