我正在使用Optuna for CatboostRegressor进行超参数调整,但是我意识到我得到的试验是随机顺序的(我的试验是从试验7开始,然后是试验5,最后是试验8。我在网上看到的所有示例都是按顺序进行的,例如试验0以值结束: xxxxx,试验1,试验2……(示例:https://www.kaggle.com/saurabhshahane/catboost-hyperparameter-tuning-with-optuna)
这是一个问题,还是没有什么值得担心的?不知道为什么我的顺序是随机的。
我还想知道是否应该先做cb.cv (Catboost的交叉验证)而不是cb.CatBoostRegressor,然后再做.fit和.predict进行超参数调优?或者,我使用哪种方法来获取最佳超参数并不重要?

这是我的代码:
def objective(trial):
optuna_params = {"subsample": trial.suggest_float("subsample", 0.5, 0.99),
'od_wait': trial.suggest_int('od_wait', 10, 50, step=1),
"colsample_bylevel": trial.suggest_float("colsample_bylevel", 0.5, 0.99),
"random_strength": trial.suggest_int("random_strength", 1, 10, step=1),
"l2_leaf_reg": trial.suggest_float("l2_leaf_reg", 1.0, 50.0),
"max_depth": trial.suggest_int("max_depth", 4, 10, step=1),
"n_estimators": trial.suggest_int("n_estimators", 100, 2500, step=1),
'learning_rate': trial.suggest_loguniform("learning_rate", 0.005, 0.1)}
cbregressor = cb.CatBoostRegressor(**optuna_params,
random_state=0,
loss_function='MAE',
eval_metric='MAE',
one_hot_max_size=0,
boost_from_average=True)
cat_optuna = cbregressor.fit(cat_train_pool2, eval_set=cat_val_pool2, verbose=False, early_stopping_rounds=10)
y_valid_pred_cat3 = cat_optuna.predict(X_validation2)
MAE = mean_absolute_error(y_validation, y_valid_pred_cat3)
print('MAE score of CatBoost =', MAE)
return MAEstudy = optuna.create_study(direction="minimize", sampler = TPESampler(seed=0), study_name="Catboost Optuna")
study.optimize(objective, n_trials=100, n_jobs=-1)发布于 2021-10-24 06:16:59
这是个问题,还是没什么好担心的?不知道为什么我的顺序是随机的。
不是的。当我们在study.optimize方法中设置n_jobs=-1时,使用线程并行执行优化。
Regresser与CV
我想任何一个都可以。通常,当我们使用CV时,过拟合比单一列车/val分裂发生的可能性更小(即,在此设置中为回归)。然而,CV代价的计算代价很高。
https://stackoverflow.com/questions/69693929
复制相似问题