skforecast icon indicating copy to clipboard operation
skforecast copied to clipboard

bayesian_search_forecaster (Optuna) & Saving/Resuming Study with RDB Backend

Open wheredoesyourmindgo opened this issue 1 year ago • 1 comments

I'm trying to figure out if there is a way to pick up where I left off with the bayesian_search_forecaster().

After I create a SQLite DB as described on Saving/Resuming Study with RDB Backend, I get the following error on a 2nd execution of the following function.

results, frozen_trial = bayesian_search_forecaster(
                           ...,
                            metric = 'mean_absolute_error',
                            kwargs_create_study  = {
                                 'study_name': "model-study",
                                 'storage': "sqlite:///model-study.db",
                                'load_if_exists': True
                            },
                            kwargs_study_optimize = {}
                        )

Error:

File ~/.../lib/python3.8/site-packages/skforecast/model_selection/model_selection.py:1584, in _bayesian_search_optuna(forecaster, y, search_space, steps, metric, initial_train_size, fixed_train_size, gap, allow_incomplete_fold, exog, lags_grid, refit, n_trials, random_state, return_best, n_jobs, verbose, show_progress, kwargs_create_study, kwargs_study_optimize) 1581 params_list.append(trial.params) 1582 lags_list.append(lags) -> 1584 for m, m_values in zip(metric, metric_values[i]): 1585 m_name = m if isinstance(m, str) else m.name 1586 metric_dict[m_name].append(m_values)

IndexError: list index out of range

wheredoesyourmindgo avatar Jan 14 '24 23:01 wheredoesyourmindgo

Hi @wheredoesyourmindgo Thanks for using skforecast and reporting this error. It seems there is a bug in the way we internally call optuna.create_study() within bayesian_search_forecaster(). We will try to fix this in the next release.

JoaquinAmatRodrigo avatar Jan 16 '24 17:01 JoaquinAmatRodrigo

Hi, This issue has been inactive for a while, so we're closing it to keep the repo tidy. If needed, feel free to reopen or create a new issue.

Thanks!

JoaquinAmatRodrigo avatar Aug 08 '24 08:08 JoaquinAmatRodrigo