对 GridSearchCV 的工作感到困惑

tan*_*ngy 3 python machine-learning scikit-learn

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

这里说“该模型在完整的开发集上进行了训练”

然而,我们在这里只应用了 n 折交叉验证。分类器是否也在整个数据上进行自我训练?或者只是在应用预测时选择 n 倍中具有最佳参数的训练有素的最佳估计器?

Mar*_*rkV 5

如果要使用predict,则需要设置'refit'True。从文档中:

\n\n
refit : boolean\n    Refit the best estimator with the entire dataset. \n    If \xe2\x80\x9cFalse\xe2\x80\x9d, it is impossible to make predictions using \n    this GridSearchCV instance after fitting.\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n