我使用XGBRegressor和BayesSearchCV从skopt运行参数调优
opt_xgb_model_tuned = xgboost.XGBRegressor()
hyper_space = {
'booster': ['gbtree'],
'objective': ['reg:squarederror'],
'learning_rate': [0.005, 0.01, 'log-uniform'],
'max_depth': [8, 12],
'min_child_weight': [0, 10],
'gamma': [0.01, 10, 'log-uniform'],
'subsample': [0.0001, 1, 'uniform'],
'colsample_bytree': [0.001, 1.0, 'uniform'],
'reg_lambda': [0.01, 50, 'log-uniform'],
'reg_alpha': [0.001, 1, 'log-uniform'],
'max_delta_step': [0, 20],
'n_estimators': [500, 2000],
}
gs = BayesSearchCV(opt_xgb_model_tuned, hyper_space, n_iter=32, random_state=0)
gs_res = gs.fit(X_train, y_train)wilson\anaconda_python\py2020\envs\optimus_prime\lib\site-packages\skopt\utils.py c:\
\joel thomas check_x_in_space(x,如果is_2Dlistlike(x):185 (如果不是np.all(p在空间中表示p in x):-> 186 ValueError(“并非所有点都在”187“空间的范围内”) 188 (如果有的话(len(P) != len(space.dimensions)表示p in x):
ValueError:并不是所有的点都在空间的范围内。
我们搜索每个参数的规则/范围有任何线索吗?这取决于X范围吗?就像我的模型目标在- 1,1的范围内。这和这个有什么关系吗?
发布于 2021-03-04 18:41:54
您的模型目标不会影响该范围问题。
我建议使用内置数据空间类指定hyper_space搜索空间的数据类型。
例如:
from skopt.space import Real, Categorical, Integer
hyper_space = {
'booster': Categorical(['gbtree']),
'learning_rate': Real(0.005, 0.01, 'log-uniform'),
'max_depth': Integer(8, 12, 'uniform'),
}如果您仍然遇到相同的问题,您可以尝试反复注释掉一些搜索变量,以找到抛出错误的罪魁祸首。
https://stackoverflow.com/questions/61595537
复制相似问题