【问题标题】:Get standard deviation for a GridSearchCV获取 GridSearchCV 的标准差
【发布时间】:2018-08-12 10:46:42
【问题描述】:

在 scikit-learn 0.20 之前,我们可以使用 result.grid_scores_[result.best_index_] 来获得标准差。 (例如返回:mean: 0.76172, std: 0.05225, params: {'n_neighbors': 21}

scikit-learn 0.20 中获得最佳分数标准差的最佳方法是什么?

【问题讨论】:

    标签: python scikit-learn data-science cross-validation grid-search


    【解决方案1】:

    在较新的版本中,grid_scores_ 被重命名为 cv_results_。在documentation之后,你需要这个:

    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_).
    

    所以在你的情况下,你需要

    • 最佳参数:- result.cv_results_['params'][result.best_index_]result.best_params_
    • 最佳平均分:- result.cv_results_['mean_test_score'][result.best_index_]result.best_score_

    • 最佳标准:- result.cv_results_['std_test_score'][result.best_index_]

    【讨论】:

      猜你喜欢
      • 2020-07-07
      • 1970-01-01
      • 2014-02-27
      • 2021-10-30
      • 1970-01-01
      • 2015-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多