optuna/optuna-examples

Getting error fit() got an unexpected keyword argument 'callbacks' while running catboost_pruning.py

ooghry opened this issue · 1 comments

Hello

I've been trying to run catboost_pruning.py, but I got this error immediately.

Any help would be appreciated

Environment

  • Optuna version: 2.10.0
  • Catboost version: 0.25.1
  • Python version: 3.6.9
[W 2022-02-01 20:55:41,660] Trial 0 failed because of the following error: TypeError("fit() got an unexpected keyword argument 'callbacks'",)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/optuna/study/_optimize.py", line 213, in _run_trial
    value_or_values = func(trial)
  File "<ipython-input-24-57f614d12d83>", line 30, in objective
    callbacks=[pruning_callback],
TypeError: fit() got an unexpected keyword argument 'callbacks'
TypeError                                 Traceback (most recent call last)
<ipython-input-25-da54f0e9fc16> in <module>
      3         pruner=optuna.pruners.MedianPruner(n_warmup_steps=5), direction="maximize"
      4     )
----> 5     study.optimize(objective, n_trials=100, timeout=600)
      6 
      7     print("Number of finished trials: {}".format(len(study.trials)))

/usr/local/lib/python3.6/site-packages/optuna/study/study.py in optimize(self, func, n_trials, timeout, n_jobs, catch, callbacks, gc_after_trial, show_progress_bar)
    407             callbacks=callbacks,
    408             gc_after_trial=gc_after_trial,
--> 409             show_progress_bar=show_progress_bar,
    410         )
    411 

/usr/local/lib/python3.6/site-packages/optuna/study/_optimize.py in _optimize(study, func, n_trials, timeout, n_jobs, catch, callbacks, gc_after_trial, show_progress_bar)
     74                 reseed_sampler_rng=False,
     75                 time_start=None,
---> 76                 progress_bar=progress_bar,
     77             )
     78         else:

/usr/local/lib/python3.6/site-packages/optuna/study/_optimize.py in _optimize_sequential(study, func, n_trials, timeout, catch, callbacks, gc_after_trial, reseed_sampler_rng, time_start, progress_bar)
    161 
    162         try:
--> 163             trial = _run_trial(study, func, catch)
    164         except Exception:
    165             raise

/usr/local/lib/python3.6/site-packages/optuna/study/_optimize.py in _run_trial(study, func, catch)
    262 
    263     if state == TrialState.FAIL and func_err is not None and not isinstance(func_err, catch):
--> 264         raise func_err
    265     return trial
    266 

/usr/local/lib/python3.6/site-packages/optuna/study/_optimize.py in _run_trial(study, func, catch)
    211 
    212     try:
--> 213         value_or_values = func(trial)
    214     except exceptions.TrialPruned as e:
    215         # TODO(mamu): Handle multi-objective cases.

<ipython-input-24-57f614d12d83> in objective(trial)
     28         verbose=0,
     29         early_stopping_rounds=100,
---> 30         callbacks=[pruning_callback],
     31     )
     32 

TypeError: fit() got an unexpected keyword argument 'callbacks'

I updated Optuna to 1.0.4, and the error is gone.