mlos_bench.optimizers.convert_configspace module

Functions to convert TunableGroups to ConfigSpace for use with the mlos_core optimizers.

class mlos_bench.optimizers.convert_configspace.TunableValueKind

Bases: object

Enum for the kind of the tunable value (special or not). It is not a true enum because ConfigSpace wants string values.

RANGE = 'range'
SPECIAL = 'special'
mlos_bench.optimizers.convert_configspace.configspace_data_to_tunable_values(data: dict) Dict[str, int | float | str | None]

Remove the fields that correspond to special values in ConfigSpace. In particular, remove and keys suffixes added by special_param_names.

mlos_bench.optimizers.convert_configspace.special_param_name_is_temp(name: str) bool

Check if name corresponds to a temporary ConfigSpace parameter.

NOTE: ! characters are currently disallowed in Tunable names in order handle this logic.

Parameters:
namestr

The name of the hyperparameter.

Returns:
is_specialbool

True if the name corresponds to a temporary ConfigSpace hyperparameter.

mlos_bench.optimizers.convert_configspace.special_param_name_strip(name: str) str

Remove the temporary suffix from a special parameter name.

NOTE: ! characters are currently disallowed in Tunable names in order handle this logic.

Parameters:
namestr

The name of the hyperparameter.

Returns:
stripped_namestr

The name of the hyperparameter without the temporary suffix.

mlos_bench.optimizers.convert_configspace.special_param_names(name: str) Tuple[str, str]

Generate the names of the auxiliary hyperparameters that correspond to a tunable that can have special values.

NOTE: ! characters are currently disallowed in Tunable names in order handle this logic.

Parameters:
namestr

The name of the tunable parameter.

Returns:
special_namestr

The name of the hyperparameter that corresponds to the special value.

type_namestr

The name of the hyperparameter that chooses between the regular and the special values.

mlos_bench.optimizers.convert_configspace.tunable_groups_to_configspace(tunables: TunableGroups, seed: int | None = None) ConfigurationSpace

Convert TunableGroups to hyperparameters in ConfigurationSpace.

Parameters:
tunablesTunableGroups

A collection of tunable parameters.

seedOptional[int]

Random seed to use.

Returns:
configspaceConfigurationSpace

A new ConfigurationSpace instance that corresponds to the input TunableGroups.

mlos_bench.optimizers.convert_configspace.tunable_values_to_configuration(tunables: TunableGroups) Configuration

Converts a TunableGroups current values to a ConfigSpace Configuration.

Parameters:
tunablesTunableGroups

The TunableGroups to take the current value from.

Returns:
Configuration

A ConfigSpace Configuration.