根据我的理解,将cv参数设置为10的cross_val_predict,将创建10个独立的数据集,使用一个作为测试集,另一个作为训练集,并执行此操作,直到所有10个集都被用作测试数据 . 返回值是一个组合数据集,包含具有置信度的数据的所有预测 .

我想要的是像一个包含十个预测数组的数组,所以我可以计算一个平均分数,我知道cross_val_score返回这个,但我试图比较ROC AUC指标,所以需要使用'predict_proba'方法,下面是用于创建我收到的当前输出的代码 .

Here is the output :

from sklearn.preprocessing import label_binarize
y_bin = label_binarize(y, classes=['label1','label2'])
#import module to calculate roc_auc score
from sklearn.metrics import roc_auc_score
#Import the cross-validation prediction module
from sklearn.model_selection import cross_val_predict
#using the loops to change parameters again
NNmodel = MLPClassifier(hidden_layer_sizes=(10,),activation='logistic')
proba = cross_val_predict(NNmodel, X, y, cv=10, method='predict_proba')
auc = roc_auc_score(y_bin,proba[:,1])
print ("Hidden Neurons set to 10", "ROC AUC Score = %",auc*100)

我更愿意报告每个测试集的平均得分,而不仅仅是我目前可以产生的单个结果 .