如何抑制CatBoost迭代结果?

Gav*_*vin 7 python catboost

我正在尝试使用CatBoost来拟合二进制模型。当我使用以下代码时,我认为verbose=False可以帮助抑制迭代日志。但事实并非如此。有没有办法避免打印迭代?

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)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

小智 10

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.

如果在拟合功能中使用参数,则将使用由该参数选择的模式。

就您而言,您似乎遇到了一个错误。下次看到一些错误时,最好的办法是使用GitHub页面上的问题向CatBoost团队报告。该错误应该已经得到修复,因此请尝试升级到最新版本或从源代码构建代码。


小智 7

设置metric_period=100。它应该工作。