Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Optuna Checkpoints] #1215

Open
Steviey opened this issue Nov 25, 2024 · 2 comments
Open

[Optuna Checkpoints] #1215

Steviey opened this issue Nov 25, 2024 · 2 comments

Comments

@Steviey
Copy link

Steviey commented Nov 25, 2024

Description

I can not find any examples how to incorporate optuna checkpoinsts.
This works but not with optuna checkpoints:


study_name = f"study_{myKey}_{part}_{qRank}"
                db_name    = f"{myKey}_{part}_{qRank}.db"
                db_path    = psl.get_script_path(db_name)
                db_path    = f"sqlite:///{db_path}"
                try:
                    study = optuna.create_study(
                        study_name     = study_name,
                        storage        = db_path,  # Ensure the study is stored persistently
                        load_if_exists = True,  # Load the existing study if it already exists
                        direction      = "minimize",  # Or "maximize" depending on your objective
                    )
                    algoConf1 = AutoNHITS.get_default_config(h=horiz, backend="optuna")
                    def config_ov_2(trial):
                        config = {**algoConf1(trial)}
                        config.update({
                            "max_steps":maxSteps,
                            "futr_exog_list":exogNames,
                            "hist_exog_list":exogNames
                            })
                        return config
                    model = AutoNHITS(h=horiz,loss=MAE(),config=config_ov_2,search_alg=optuna.samplers.TPESampler(),backend='optuna',num_samples=folds)
                    models.append(model)
                except Exception as e:
                    print(f"Failed to configure or instantiate MLP for key '{myKey}': {e}")
                    psl.errorLog(pd,myKey,e)

Link

No response

@jmoralez
Copy link
Member

Hey. This isn't currently possible, since the study is created with fixed arguments and it's not possible to override them

study = optuna.create_study(sampler=sampler, direction="minimize")

@Steviey
Copy link
Author

Steviey commented Nov 25, 2024

No checkpoints is bad for smaller machines. Cumulative search is essential.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants