How to suppress CatBoost iteration results?

Gavin picture Gavin · Jun 30, 2018 · Viewed 8.6k times · Source

I am trying to use CatBoost to fit a binary model. When I use the following code, I thought verbose=False can help to suppress the iteration logs. But it didn't. Is there a way to avoid print the iterations?

model=CatBoostClassifier(iterations=300, depth=6, learning_rate=0.1, 
loss_function='Logloss',
         rsm = 0.95, 
         border_count = 64, 
         eval_metric =  'AUC', 
         l2_leaf_reg= 3.5, 
         one_hot_max_size=30, 
         use_best_model = True,
         verbose=False,
         random_seed = 502)

model.fit(X_train, y_train,
     eval_set=(X_test_filtered, y_test_num),   
     verbose = False,
     plot=True)

enter image description here

Answer

Anna Veronika Dorogush picture Anna Veronika Dorogush · Jul 5, 2018

CatBoost has several parameters to control verbosity. Those are verbose, silent and logging_level.

By default logging is verbose, so you see loss value on every iteration. If you want to see less logging, you need to use one of these parameters. It's not allowed to set two of them simultaneously.

silent has two possible values - True and False.

verbose can also be True and False, but it also can be an integer. If it is an integer N, then logging will be printed out each N-th iteration.

logging_level can be 'Silent', 'Verbose', 'Info' and 'Debug':

  • 'Silent' means no output to stdout (except for important warnings) and is same as silent=True or verbose=False.
  • 'Verbose' is the default logging mode. It's the same as verbose=True or silent=False.
  • 'Info' prints out the trees that are selected on every iteration.
  • 'Debug' prints a lot of debug info.

There are two places where you can use these parameters. The first one is model creation. The second one is fitting of the created model. If you have used a parameter when creating the model then it will be used during fitting if no parameter in fit function is specified.

If you use parameter in fit function then the mode selected by this parameter will be used.

In your case it looks like you have encountered a bug. The next time you see some bug, the best thing is to report to CatBoost team using issues on the GitHub page. This bug should have already been fixed, so try upgrading to the latest version or build code from source.