【问题标题】:BayesSearchCV skipt: ValueError: Not all points are within the bounds of the spaceBayesSearchCV 跳过:ValueError:并非所有点都在空间范围内
【发布时间】:2020-08-19 01:47:27
【问题描述】:

我正在运行 XGBRegressor 和来自 skoptBayesSearchCV 进行参数调整

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)

c:\users\joel thomas wilson\anaconda_python\py2020\envs\optimus_prime\lib\site-packages\skopt\utils.py in check_x_in_space(x, space) 184 如果 is_2Dlistlike(x): 185 如果不是 np.all([p 在空间中的 p 在 x]): --> 186 raise ValueError("并非所有点都在范围内" 187“空间。”) 188 如果有的话([len(p) != len(space.dimensions) for p in x]):

ValueError:并非所有点都在空间范围内。

关于我们搜索每个参数的规则/范围的任何线索,是否取决于X 范围?就像我的模型目标在 [-1, 1] 的范围内。这和这个有关系吗?

【问题讨论】:

  • 你有多少个变量?超过 1000 个?

标签: python xgboost hyperparameters skopt


【解决方案1】:

您的模型目标不会影响该范围问题。

我建议使用内置数据空间类指定 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'),
}

如果还是遇到同样的问题,可以随时尝试反复注释掉一些搜索变量,找出引发错误的罪魁祸首。

【讨论】:

    猜你喜欢
    • 2020-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-13
    • 2021-01-15
    • 2012-09-09
    • 2017-10-30
    • 1970-01-01
    相关资源
    最近更新 更多