如果我在 scikit-learn 库中使用 GridSearchCV 来查找最佳模型,它返回的最终模型是什么?也就是说,对于每组超参数,我们训练一定数量的 CV(比如 3 个)模型。这样,函数会返回这3个模型中最好的模型来获得最佳的参数设置吗?
最佳答案
GridSearchCV
将返回一个包含大量信息的对象。它确实返回了在遗漏数据上表现最佳的模型:
best_estimator_ : estimator or dict
Estimator that was chosen by the search, i.e. estimator which gave highest score (or smallest loss if specified) on the left out data. Not available if refit=False.
请注意,这不是在整个数据上训练的模型。这意味着,一旦您确信这是您想要的模型,您将需要自己在整个数据上重新训练模型。
引用号:http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html
关于python - GridSearchCV最终模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49455806/