mlos_bench.optimizers.convert_configspace

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

Classes

TunableValueKind

Enum for the kind of the tunable value (special or not).

Functions

configspace_data_to_tunable_values(→ Dict[str, ...)

Remove the fields that correspond to special values in ConfigSpace.

special_param_name_is_temp(→ bool)

Check if name corresponds to a temporary ConfigSpace parameter.

special_param_name_strip(→ str)

Remove the temporary suffix from a special parameter name.

special_param_names(→ Tuple[str, str])

Generate the names of the auxiliary hyperparameters that correspond to a tunable

tunable_groups_to_configspace(...)

Convert TunableGroups to hyperparameters in ConfigurationSpace.

tunable_values_to_configuration(...)

Converts a TunableGroups current values to a ConfigSpace Configuration.

Module Contents

class mlos_bench.optimizers.convert_configspace.TunableValueKind[source]

Enum for the kind of the tunable value (special or not).

It is not a true enum because ConfigSpace wants string values.

RANGE = 'range'[source]
SPECIAL = 'special'[source]
mlos_bench.optimizers.convert_configspace.configspace_data_to_tunable_values(data: dict) Dict[str, mlos_bench.tunables.tunable.TunableValue][source]

Remove the fields that correspond to special values in ConfigSpace.

In particular, remove and keys suffixes added by special_param_names.

Parameters:

data (dict)

Return type:

Dict[str, mlos_bench.tunables.tunable.TunableValue]

mlos_bench.optimizers.convert_configspace.special_param_name_is_temp(name: str) bool[source]

Check if name corresponds to a temporary ConfigSpace parameter.

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

Parameters:

name (str) – The name of the hyperparameter.

Returns:

is_special – True if the name corresponds to a temporary ConfigSpace hyperparameter.

Return type:

bool

mlos_bench.optimizers.convert_configspace.special_param_name_strip(name: str) str[source]

Remove the temporary suffix from a special parameter name.

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

Parameters:

name (str) – The name of the hyperparameter.

Returns:

stripped_name – The name of the hyperparameter without the temporary suffix.

Return type:

str

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

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:

name (str) – The name of the tunable parameter.

Returns:

  • special_name (str) – The name of the hyperparameter that corresponds to the special value.

  • type_name (str) – The name of the hyperparameter that chooses between the regular and the special values.

Return type:

Tuple[str, str]

mlos_bench.optimizers.convert_configspace.tunable_groups_to_configspace(tunables: mlos_bench.tunables.tunable_groups.TunableGroups, seed: int | None = None) ConfigSpace.ConfigurationSpace[source]

Convert TunableGroups to hyperparameters in ConfigurationSpace.

Parameters:
  • tunables (TunableGroups) – A collection of tunable parameters.

  • seed (Optional[int]) – Random seed to use.

Returns:

configspace – A new ConfigurationSpace instance that corresponds to the input TunableGroups.

Return type:

ConfigSpace.ConfigurationSpace

mlos_bench.optimizers.convert_configspace.tunable_values_to_configuration(tunables: mlos_bench.tunables.tunable_groups.TunableGroups) ConfigSpace.Configuration[source]

Converts a TunableGroups current values to a ConfigSpace Configuration.

Parameters:

tunables (TunableGroups) – The TunableGroups to take the current value from.

Returns:

A ConfigSpace Configuration.

Return type:

ConfigSpace.Configuration