首页 文章

对GridSearchCV的工作感到困惑

提问于
浏览
2

GridSearchCV实现了一种拟合方法,在该方法中,它执行n次交叉验证以确定最佳参数 . 在此之后,我们可以使用predict()直接将最佳估算器应用于测试数据 - 以下链接: - http://scikit-learn.org/stable/auto_examples/grid_search_digits.html

它在这里说“模型是在完整的开发集上训练的”

但是我们在这里只应用了n次交叉验证 . 分类器是否也以某种方式在整个数据上进行自我训练?或者它是否只是在应用预测时选择n-folds中具有最佳参数的经过最佳训练的估算器?

1 回答

  • 1

    如果要使用 predict ,则需要将 'refit' 设置为 True . 从文档:

    refit : boolean
        Refit the best estimator with the entire dataset. 
        If “False”, it is impossible to make predictions using 
        this GridSearchCV instance after fitting.
    

    默认情况下它看起来是真的,因此在示例中, predict 基于整个训练集 .

相关问题