Get standard deviation for a GridSearchCV

我是研究僧i 提交于 2019-12-14 03:49:13

问题


Before scikit-learn 0.20 we could use result.grid_scores_[result.best_index_] to get the standard deviation. (It returned for exemple: mean: 0.76172, std: 0.05225, params: {'n_neighbors': 21})

What's the best way in scikit-learn 0.20 to get the standard deviation of the best score ?


回答1:


In newer versions, the grid_scores_ is renamed as cv_results_. Following the documentation, you need this:

best_index_ : int

The index (of the cv_results_ arrays) which corresponds to the best > 
  candidate parameter setting.

The dict at search.cv_results_['params'][search.best_index_] gives the > 
  parameter setting for the best model, that gives the highest mean
  score (search.best_score_).

So in your case, you need

  • Best params :- result.cv_results_['params'][result.best_index_] OR result.best_params_
  • Best mean score :- result.cv_results_['mean_test_score'][result.best_index_] OR result.best_score_

  • Best std :- result.cv_results_['std_test_score'][result.best_index_]



来源:https://stackoverflow.com/questions/49099293/get-standard-deviation-for-a-gridsearchcv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!