mlos_core.optimizers.bayesian_optimizers.smac_optimizer module¶
Contains the wrapper class for SMAC Bayesian optimizers.
See Also: <https://automl.github.io/SMAC3/main/index.html>
- class mlos_core.optimizers.bayesian_optimizers.smac_optimizer.SmacOptimizer(*, parameter_space: ConfigurationSpace, optimization_targets: List[str], objective_weights: List[float] | None = None, space_adapter: BaseSpaceAdapter | None = None, seed: int | None = 0, run_name: str | None = None, output_directory: str | None = None, max_trials: int = 100, n_random_init: int | None = None, max_ratio: float | None = None, use_default_config: bool = False, n_random_probability: float = 0.1)¶
Bases:
BaseBayesianOptimizer
Wrapper class for SMAC based Bayesian optimization.
- Attributes:
n_random_init
Gets the number of random samples to use to initialize the optimizer’s search space sampling.
space_adapter
Get the space adapter instance (if any).
Methods
acquisition_function
(*, configs[, context])Invokes the acquisition function from this Bayesian optimizer for the given configuration.
cleanup
()Remove temp files, release resources, etc.
get_best_observations
(*[, n_max])Get the N best observations so far as a triplet of DataFrames (config, score, context).
get_observations
()Returns the observations as a triplet of DataFrames (config, score, context).
register
(*, configs, scores[, context, metadata])Wrapper method, which employs the space adapter (if any), before registering the configs and scores.
register_pending
(*, configs[, context, metadata])Registers the given configs as "pending".
suggest
(*[, context, defaults])Wrapper method, which employs the space adapter (if any), after suggesting a new configuration.
surrogate_predict
(*, configs[, context])Obtain a prediction from this Bayesian optimizer's surrogate model for the given configuration(s).
- acquisition_function(*, configs: DataFrame, context: DataFrame | None = None) ndarray[Any, dtype[_ScalarType_co]] ¶
Invokes the acquisition function from this Bayesian optimizer for the given configuration.
- Parameters:
- configspd.DataFrame
Dataframe of configs / parameters. The columns are parameter names and the rows are the configs.
- contextpd.DataFrame
Not Yet Implemented.
- cleanup() None ¶
Remove temp files, release resources, etc.
after use. Default is no-op. Redefine this method in optimizers that require cleanup.
- property n_random_init: int¶
Gets the number of random samples to use to initialize the optimizer’s search space sampling.
Note: This may not be equal to the value passed to the initializer, due to logic present in the SMAC. See Also: max_ratio
- Returns:
- int
The number of random samples used to initialize the optimizer’s search space sampling.
- register_pending(*, configs: DataFrame, context: DataFrame | None = None, metadata: DataFrame | None = None) None ¶
Registers the given configs as “pending”. That is it say, it has been suggested by the optimizer, and an experiment trial has been started. This can be useful for executing multiple trials in parallel, retry logic, etc.
- Parameters:
- configspd.DataFrame
Dataframe of configs / parameters. The columns are parameter names and the rows are the configs.
- contextpd.DataFrame
Not Yet Implemented.
- metadataOptional[pd.DataFrame]
Metadata returned by the backend optimizer’s suggest method.
- surrogate_predict(*, configs: DataFrame, context: DataFrame | None = None) ndarray[Any, dtype[_ScalarType_co]] ¶
Obtain a prediction from this Bayesian optimizer’s surrogate model for the given configuration(s).
- Parameters:
- configspd.DataFrame
Dataframe of configs / parameters. The columns are parameter names and the rows are the configs.
- contextpd.DataFrame
Not Yet Implemented.