XGBoostError : value for parameter exceed bound

XGBoostError : value for parameter exceed bound

我正在训练 XGBoost 模型并使用 randomizedSearchCV 进行超参数调整。我指定参数分布为:

from xgboost import XGBRegressor

# Define a xgboost regression model
model = XGBRegressor()

params = {
      "colsample_bytree": uniform(0.1, 0.2), # fraction of cols to sample
      "gamma": uniform(0, 0.3), # min loss reduction required for next split
      "learning_rate": uniform(0.02, 0.3), # default 0.1 
      "n_estimators": randint(100, 150), # default 100
      "subsample": uniform(0.8, 0.75) # % of rows to use in training sample
}

r = RandomizedSearchCV(model, param_distributions=params, n_iter=100, 
scoring="neg_mean_absolute_error", cv=3, n_jobs=1)

即使我为 subsample 指定的范围低于 [0,1].

,我也会收到以下错误
raise XGBoostError(py_str(_LIB.XGBGetLastError()))
   xgboost.core.XGBoostError: value 1.10671 for Parameter subsample exceed bound [0,1]

  warnings.warn("Estimator fit failed. The score on this train-test"

知道为什么会这样吗?

我认为问题来自:

uniform(0.8, 0.75)

对于 numpy 和 random,函数的第一个值定义下限,第二个值定义上限。因此,对于 numpy 和 random 你想要:

uniform(0.75, 0.8)

这适用于 numpy.random.uniform 和 random.uniform:

但是,scipy.stats.uniform 的定义略有不同。即“使用参数 loc 和 scale,获得 [loc, loc + scale] 上的均匀分布。”所以对于 scipy 你想要:

uniform(0.75, 0.05)