mlos_core.optimizers.optimizer.BaseOptimizer

class mlos_core.optimizers.optimizer.BaseOptimizer(*, parameter_space: ConfigurationSpace, space_adapter: BaseSpaceAdapter | None = None)

Optimizer abstract base class defining the basic interface.

Attributes:
space_adapter

Get the space adapter instance (if any).

Methods

cleanup()

Remove temp files, release resources, etc.

get_best_observation()

Returns the best observation so far as a dataframe.

get_observations()

Returns the observations as a dataframe.

register(configurations, scores[, context])

Wrapper method, which employs the space adapter (if any), before registering the configurations and scores.

register_pending(configurations[, context])

Registers the given configurations as "pending".

suggest([context, defaults])

Wrapper method, which employs the space adapter (if any), after suggesting a new configuration.

__init__(*, parameter_space: ConfigurationSpace, space_adapter: BaseSpaceAdapter | None = None)

Create a new instance of the base optimizer.

Parameters:
parameter_spaceConfigSpace.ConfigurationSpace

The parameter space to optimize.

space_adapterBaseSpaceAdapter

The space adapter class to employ for parameter space transformations.

cleanup() None

Remove temp files, release resources, etc. after use. Default is no-op. Redefine this method in optimizers that require cleanup.

get_best_observation() DataFrame

Returns the best observation so far as a dataframe.

Returns:
best_observationpd.DataFrame

Dataframe with a single row containing the best observation. The columns are parameter names and “score” for the score.

get_observations() DataFrame

Returns the observations as a dataframe.

Returns:
observationspd.DataFrame

Dataframe of observations. The columns are parameter names and “score” for the score, each row is an observation.

register(configurations: DataFrame, scores: Series, context: DataFrame | None = None) None

Wrapper method, which employs the space adapter (if any), before registering the configurations and scores.

Parameters:
configurationspd.DataFrame

Dataframe of configurations / parameters. The columns are parameter names and the rows are the configurations.

scorespd.Series

Scores from running the configurations. The index is the same as the index of the configurations.

contextpd.DataFrame

Not Yet Implemented.

abstract register_pending(configurations: DataFrame, context: DataFrame | None = None) None

Registers the given configurations 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:
configurationspd.DataFrame

Dataframe of configurations / parameters. The columns are parameter names and the rows are the configurations.

contextpd.DataFrame

Not Yet Implemented.

property space_adapter: BaseSpaceAdapter | None

Get the space adapter instance (if any).

suggest(context: DataFrame | None = None, defaults: bool = False) DataFrame

Wrapper method, which employs the space adapter (if any), after suggesting a new configuration.

Parameters:
contextpd.DataFrame

Not Yet Implemented.

defaultsbool

Whether or not to return the default config instead of an optimizer guided one. By default, use the one from the optimizer.

Returns:
configurationpd.DataFrame

Pandas dataframe with a single row. Column names are the parameter names.