【发布时间】:2018-09-20 05:45:59
【问题描述】:
我想在 scikit-learns GridSearchCV-method 中使用 early-stopping-option。此 SO-thread 中显示了一个示例:
import xgboost as xgb
from sklearn.model_selection import GridSearchCV
trainX= [[1], [2], [3], [4], [5]]
trainY = [1, 2, 3, 4, 5]
testX = trainX
testY = trainY
param_grid = {"subsample" : [0.5, 0.8],
"n_estimators" : [600]}
fit_params = {"early_stopping_rounds":1,
"eval_set" : [[testX, testY]]}
model = xgb.XGBRegressor()
gridsearch = GridSearchCV(estimator = xgb.XGBRegressor(),
param_grid=param_grid,
fit_params=fit_params,
verbose=1,
cv=2)
gridsearch.fit(trainX,trainY)
但是,我想将交叉验证过程的保留集用作验证集。有没有办法在GridSearchCV 中指定这个?
【问题讨论】:
-
人们一直在想这个问题。确实很奇怪,不能为此目的使用 CV 折叠 stackoverflow.com/questions/43866284/…
-
你可以用 hyperOpt 包做到这一点。
-
@EranMoshe 谢谢。你有例子吗?
标签: python scikit-learn xgboost grid-search