我正在訓練 XGBoost 模型并使用 randomSearchCV 進行超引數調整。我將引數分布指定為:
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"
任何想法為什么會發生這種情況?
uj5u.com熱心網友回復:
我認為問題來自:
uniform(0.8, 0.75)
函式的第一個值應定義下限,第二個值應定義上限。因此,我假設您想要:
uniform(0.75, 0.8)
這適用于 numpy.random.uniform 和 random.uniform:
- https://numpy.org/doc/stable/reference/random/generated/numpy.random.uniform.html
- https://docs.python.org/3/library/random.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/374936.html
上一篇:PowerShell::InternetExplorer下載對話框NumLockOn
下一篇:投射多個相似性的ML模型
