Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def objectiveCat(trial):
- param = {}
- param['learning_rate'] = 0.02
- param['depth'] = trial.suggest_int('depth', 13, 15)
- param['l2_leaf_reg'] = trial.suggest_discrete_uniform('l2_leaf_reg', 4.0, 5.5, 0.5)
- param['min_child_samples'] = trial.suggest_categorical('min_child_samples', [4, 6, 8])
- param['grow_policy'] = 'Depthwise'
- param['iterations'] = trial.suggest_int('iterations', 600, 1000)
- param['use_best_model'] = True
- param['eval_metric'] = 'RMSE'
- param['od_type'] = 'iter'
- param['od_wait'] = 20
- param['random_state'] = 1
- param['logging_level'] = 'Silent'
- regressor = CatBoostRegressor(**param)
- regressor.fit(train_X.copy(), train_y.copy(),
- eval_set=[(val_X.copy(), val_y.copy())],
- early_stopping_rounds=10)
- loss = mean_squared_error(val_y, regressor.predict(val_X.copy()))
- return loss
- study = optuna.create_study(study_name=f'catboost-seed{1}')
- study.optimize(objectiveCat, n_trials=10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement