Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there way to save trained model after overfitting occurs in CatBoost?

Tags:

I am using CatBoostRegressor in Python version of the Catboost library.

According to documentation, it's possible to use overfitting detector, which I am doing, like this:

model = CatBoostRegressor(iterations=iters, learning_rate=0.03, depth=depth, verbose=True, od_pval=1, od_type='IncToDec', od_wait=20)
model.fit(train_pool, eval_set=validation_pool)

# this code didn't executed
model.save_model(model_name)

However, after the overfitting occurs, I've got my Python script interrupted, prematurely stopped, pick any phrase you want, and save model part didn't get executed, which leads to a lot of waisted time and no results in the end. I didn't get any stacktrace.

Is there any possibility to handle it in CatBoost and save hours of fitting work?

like image 710
Mysterion Avatar asked Nov 19 '17 17:11

Mysterion


People also ask

How do I stop CatBoost Overfitting?

CatBoost has built-in parameters to reduce overfitting The default value is False that does not activate early stopping. We can use an integer to stop the learning process early to reduce overfitting.

What is early stopping in CatBoost?

If overfitting occurs, CatBoost can stop the training earlier than the training parameters dictate. For example, it can be stopped before the specified number of trees are built. This option is set in the starting parameters. Choose the implementation for more details.

How does CatBoost handle missing values?

conclusion:catboost doesn't provide fuctionality to handle missing values in categorical variables. original text: The feature f is categorical and takes the value None for some object Obj. A matrix is used for the training. The column that contains the value of the feature f for the object Obj contains the value None.


1 Answers

Use this code. It will save the model no matter what happens in the try block.

try:
    model.fit(X, y)
finally:
    model.save_model()
like image 146
Myles Hollowed Avatar answered Oct 11 '22 15:10

Myles Hollowed