HyperparameterTuner#
- class openstef_models.integrations.optuna.HyperparameterTuner(**data: Any) None[source]
Bases:
BaseConfig,GenericBayesian hyperparameter tuner powered by Optuna.
Orchestrates an Optuna study over the tunable search spaces declared on
HyperParamsfields of the provided config. Override methods prefixed with_to customise study creation, objective evaluation, or parameter suggestion.- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'ignore', 'protected_namespaces': ()}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
config:
Annotated[TypeVar(ConfigT, bound=BaseConfig)]
-
train_dataset:
Annotated[TimeSeriesDataset]
-
create_workflow:
Annotated[Callable[[TypeVar(ConfigT, bound=BaseConfig)],CustomForecastingWorkflow]]
-
metric_name:
str
-
direction:
Literal['maximize','minimize']
-
n_trials:
int
-
n_jobs:
int
-
study_name:
str
- static suggest_value(trial: Trial, trial_key: str, tuning_range: TuningRange) bool | int | float | str | None[source]
Suggest a single parameter value via the Optuna trial API.
Override to add custom suggestion logic or constraints.
- tune(*, show_progress_bar: bool = True) tuple[ConfigT, Study][source]
Run the Optuna study and return the best config.
- Returns:
(best_config, study)tuple.- Raises:
ValueError – If no tunable fields are found or metric_name is invalid.
- Parameters:
show_progress_bar (
bool)- Return type:
tuple[TypeVar(ConfigT, bound=BaseConfig),Study]
- fit_with_tuning(*, show_progress_bar: bool = True) TuningResult[source]
Tune, then fit a final workflow with the best config.
- Returns:
TuningResultwith the best config and Optuna study.- Raises:
RuntimeError – If the final workflow fit fails after tuning.
- Parameters:
show_progress_bar (
bool)- Return type:
TuningResult[TypeVar(ConfigT, bound=BaseConfig)]