刘建平的博客中关于随机森林调参的代码在运行时会出现如下所示的错误:
AttributeError: ‘GridSearchCV’ object has no attribute ‘grid_scores_’
解决方法如下:grid_scores_在sklearn0.20版本中已被删除,取而代之的是cv_results_。
原代码:
print(gsearch1.grid_scores_, gsearch1.best_params_, gsearch1.best_score_)
正确的代码:
print(gsearch1.cv_results_, gsearch1.best_params_, gsearch1.best_score_)