catboost: Using parameters from saved model for cross-validation leads to 'exclusive parameters' error.

Problem: “Only one of parameters [‘verbose’, ‘logging_level’, ‘verbose_eval’, ‘silent’] should be set” printed by cv function after loading from file previously saved model. catboost version: 0.12.2 Operating System: CentOS Linux release 7.4.1708 CPU: Intel® Xeon® CPU E5-2450 v2 @ 2.50GHz

model = CatBoostClassifier(loss_function='MultiClass')
model.fit(train_pool, 
  verbose=False, 
  plot=True,
  eval_set=validation_pool)
model.save_model(str(model_path.absolute()))
model = CatBoostClassifier()
model.load_model(str(model_path.absolute()))
cv_data = cv(
    whole_pool,
    params=model.get_params()
)
---------------------------------------------------------------------------
CatboostError                             Traceback (most recent call last)
<ipython-input-40-f150897615b8> in <module>
      1 cv_data = cv(
      2     whole_pool,
----> 3     params=model.get_params()
      4 )

~/.conda/envs/catboost/lib/python3.6/site-packages/catboost/core.py in cv(pool, params, dtrain, iterations, num_boost_round, fold_count, nfold, inverted, partition_random_seed, seed, shuffle, logging_level, stratified, as_pandas, metric_period, verbose, verbose_eval, plot, early_stopping_rounds, save_snapshot, snapshot_file, snapshot_interval, max_time_spent_on_fixed_cost_ratio, dev_max_iterations_batch_size)
   2876 
   2877     params = deepcopy(params)
-> 2878     _process_synonyms(params)
   2879 
   2880     metric_period, verbose, logging_level = _process_verbose(metric_period, verbose, logging_level, verbose_eval)

~/.conda/envs/catboost/lib/python3.6/site-packages/catboost/core.py in _process_synonyms(params)
    754         del params['silent']
    755 
--> 756     metric_period, verbose, logging_level = _process_verbose(metric_period, verbose, logging_level, verbose_eval, silent)
    757 
    758     if metric_period is not None:

~/.conda/envs/catboost/lib/python3.6/site-packages/catboost/core.py in _process_verbose(metric_period, verbose, logging_level, verbose_eval, silent)
    133     at_most_one = sum(params.get(exclusive) is not None for exclusive in exclusive_params)
    134     if at_most_one > 1:
--> 135         raise CatboostError('Only one of parameters {} should be set'.format(exclusive_params))
    136 
    137     if verbose is None:

CatboostError: Only one of parameters ['verbose', 'logging_level', 'verbose_eval', 'silent'] should be set

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 23 (7 by maintainers)

Most upvoted comments

please import CatBoost

from catboost import CatBoost

Thanks, @Anaststam ! Yes, it’s bug. I’ll fix it as soon as possible. Right now you can use CatBoost().load_model to avoid this problem.

Thanks, @LyzhinIvan. I had a CatBoostRegressor model and I got the same error when the model loaded CatBoostRegressor․load_model (path) like that. Everything started working without errors when the model was loaded CatBoost.load_model (path) in this way.

Thanks, @Anaststam ! Yes, it’s bug. I’ll fix it as soon as possible. Right now you can use CatBoost().load_model to avoid this problem.

@annaveronika thank you for the fix! Do you have an estimate when the minor version will be released? I’m working on an autoML package mljar-supervised. We are using CatBoost among many algorithms, and CatBoost is very often selected as the best algorithm or as a part of the ensemble (which is selected as the best algorithm) and we are waiting for the fix.

Came across the same issue, and it seems that the problem here is that when saving the model, CatBoost adds the parameter logging_level setting its value to 'Silent' when you did not even specify it. This way you get more than one non-null exclusive parameters, i.e. in your case you get verbose = 0 and 'logging_level': 'Silent'. You can bypass this error by updating the params dictionary setting the logging_level value to None this way:

cv_params = model.get_params()
cv_params.update({
    'logging_level': None,
})
cv_data = cv(
    whole_pool,
    params=cv_params
)

or make a change to _process_verbose function to address this issue:

if params.get('verbose') == 0 and params.get('logging_level') == 'Silent':
    at_most_one -= 1
if at_most_one > 1:
    raise CatBoostError('Only one of parameters {} should be set'.format(exclusive_params))