对GridSearchCV的工作感到困惑

时间:2014-11-16 21:07:20

标签: python machine-learning scikit-learn

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

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

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

1 个答案:

答案 0 :(得分: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基于整个训练集。

相关问题