GridSearchCV 没有在 cv_results 词典中获得标准分数?

GridSearchCV not getting std scores on the cv_results dictionary?

直到最近,我一直在使用 GridSearchCV 通过在 here

中指出的方式获得交叉验证的标准分数

所以基本上是这样做的

grid_search.cv_results_['std_test_score'][grid_search.best_index_]

但现在我收到一个密钥错误,告诉我 'std_test_score' 不是密钥。

这就是我调用 GridSearchCV 函数的方式

splitter = StratifiedKFold(n_splits=5, shuffle=True, random_state=11)


scoring_functions = {'mcc': make_scorer(matthews_corrcoef), 'accuracy': make_scorer(accuracy_score), 
                     'balanced_accuracy': make_scorer(balanced_accuracy_score)}

grid_search = GridSearchCV(pipeline, param_grid=grid, scoring=scoring_functions, n_jobs=-1, cv=splitter, refit='mcc')

来自the documentationcv_results_属性说明:

For multi-metric evaluation, the scores for all the scorers are available in the cv_results_ dict at the keys ending with that scorer's name ('_<scorer_name>') instead of '_score' shown above. ('split0_test_precision', 'mean_train_precision' etc.)

您可以自己轻松到达那里,grid_search.cv_results_.keys() 看看有什么可用的。它应该是例如grid_search.cv_results_['std_test_mcc'].