mlos_bench.optimizers.track_best_optimizer module

Mock optimizer for mlos_bench.

class mlos_bench.optimizers.track_best_optimizer.TrackBestOptimizer(tunables: TunableGroups, config: dict, global_config: dict | None = None, service: Service | None = None)

Bases: Optimizer

Base Optimizer class that keeps track of the best score and configuration.

Attributes:
config_space

Get the tunable parameters of the optimizer as a ConfigurationSpace.

current_iteration

The current number of iterations (suggestions) registered.

max_suggestions

The maximum number of iterations (suggestions) to run.

name

The name of the optimizer.

seed

The random seed for the optimizer.

start_with_defaults

Return True if the optimizer should start with the default values.

supports_preload

Return True if the optimizer supports pre-loading the data from previous experiments.

targets

A dictionary of {target: direction} of optimization targets.

tunable_params

Get the tunable parameters of the optimizer as TunableGroups.

Methods

bulk_register(configs, scores[, status])

Pre-load the optimizer with the bulk data from previous experiments.

get_best_observation()

Get the best observation so far.

not_converged()

Return True if not converged, False otherwise.

register(tunables, status[, score])

Register the observation for the given configuration.

suggest()

Generate the next suggestion.

get_best_observation() Tuple[Dict[str, float], TunableGroups] | Tuple[None, None]

Get the best observation so far.

Returns:
(value, tunables)Tuple[Dict[str, float], TunableGroups]

The best value and the corresponding configuration. (None, None) if no successful observation has been registered yet.

register(tunables: TunableGroups, status: Status, score: Dict[str, int | float | str | None] | None = None) Dict[str, float] | None

Register the observation for the given configuration.

Parameters:
tunablesTunableGroups

The configuration that has been benchmarked. Usually it’s the same config that the .suggest() method returned.

statusStatus

Final status of the experiment (e.g., SUCCEEDED or FAILED).

scoreOptional[Dict[str, TunableValue]]

A dict with the final benchmark results. None if the experiment was not successful.

Returns:
valueOptional[Dict[str, float]]

Benchmark scores extracted (and possibly transformed) from the dataframe that’s being MINIMIZED.