是否可以使用 GridSearchCV 同时计算准确率和 ROC-AUC 分数?

Is it possible to calculate accuracy and ROC-AUC score at the same time with GridSearchCV?

rf = RandomForestClassifier(random_state=0)
parameters = {'bootstrap': [True, False], 'min_samples_split':[2,3,4], 
'criterion':['entropy', 'gini'], 'n_estimators':[100, 200]             }
grid_search = GridSearchCV(estimator=rf, param_grid=parameters, 
scoring='accuracy', cv=10, n_jobs=-1)

我的代码目前使用 GridSearchCV 执行网格搜索,根据准确度对预测进行评分。如何在不使用 for 循环的情况下也计算 ROC-AUC 分数?

根据 docs,您可以传递 list 个字符串。在这种特定情况下,scoring=['accuracy', 'roc_auc'] 就是您想要的。