欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

AttributeError: 'GridSearchCV' object has no attribute 'grid_scores_'

程序员文章站 2022-07-13 10:51:36
...

 网上查到原因是sklearn旧版本有'grid_scores_',而新版本改成了'cv_results_'

 

在此罗列其输出的两种版本形式:

旧版本

for params, mean_score, scores in grid_result.grid_scores_: 

    print("%f (%f) with: %r" % (scores.mean(), scores.std(), params))

新版本 

means = grid_result.cv_results_['mean_test_score']
params = grid_result.cv_results_['params']
for mean,param in zip(means,params):
    print("%f  with:   %r" % (mean,param))