CatBoost Early Stopping To Avoid Overfitting

Python

 1|  from catboost import CatBoostRegressor
 2|  
 3|  # Step 1: Initialise CatBoost regression model
 4|  model = CatBoostRegressor(loss_function='RMSE',
 5|                            n_estimators=1000,
 6|                            random_seed=101)
 7|  
 8|  # Step 2: Declare evaluation set
 9|  eval_set = (X_test, y_test)
10|  
11|  # Step 3: Fit model with early stopping rounds set to 10
12|  model.fit(X_train,
13|            y_train,
14|            eval_set=eval_set,
15|            early_stopping_rounds=10,
16|            verbose=False)
Did you find this snippet useful?

Sign up for free to to add this to your code library