mlos_bench.tunables.tunable
Tunable parameter definition.
Attributes
Tunable value distribution type.  | 
|
A tunable parameter value type alias.  | 
|
Tunable value type.  | 
|
The string name of a tunable value type.  | 
|
Tunable value type tuple.  | 
|
Tunable values dictionary type.  | 
Classes
A TypedDict for a   | 
|
A TypedDict for a   | 
|
A tunable parameter definition and its current value.  | 
|
A TypedDict for a   | 
|
A TypedDict for a   | 
Functions
  | 
Creates a TunableDict from a regular dict.  | 
Module Contents
- class mlos_bench.tunables.tunable.DistributionDict[source]
 Bases:
DistributionDictOptA TypedDict for a
Tunableparameter’s requireddistribution’s config parameters.Mostly used by type checking. These are the types expected to be received from the json config.
Initialize self. See help(type(self)) for accurate signature.
- class mlos_bench.tunables.tunable.DistributionDictOpt[source]
 Bases:
TypedDictA TypedDict for a
Tunableparameter’s optionaldistribution’s config parameters.Mostly used by type checking. These are the types expected to be received from the json config.
Initialize self. See help(type(self)) for accurate signature.
- class mlos_bench.tunables.tunable.Tunable(name: str, config: dict)[source]
 A tunable parameter definition and its current value.
Create an instance of a new tunable parameter.
- Parameters:
 
See also
mlos_bench.tunablesfor more information on tunable parameters and their configuration.
- __lt__(other: object) bool[source]
 Compare the two Tunable objects. We mostly need this to create a canonical list of tunable objects when hashing a TunableGroup.
- __repr__() str[source]
 Produce a human-readable version of the Tunable (mostly for logging).
- Returns:
 string – A human-readable version of the Tunable.
- Return type:
 
- copy() Tunable[source]
 Deep copy of the Tunable object.
- Returns:
 tunable – A new Tunable object that is a deep copy of the original one.
- Return type:
 
- in_range(value: int | float | str | None) bool[source]
 Check if the value is within the range of the tunable.
Do NOT check for special values. Return False if the tunable or value is categorical or None.
- is_default() TunableValue[source]
 Checks whether the currently assigned value of the tunable is at its default.
- Return type:
 
- is_valid(value: TunableValue) bool[source]
 Check if the value can be assigned to the tunable.
- update(value: TunableValue) bool[source]
 Assign the value to the tunable. Return True if it is a new value, False otherwise.
- DTYPE: dict[TunableValueTypeName, TunableValueType][source]
 Maps Tunable types to their corresponding Python types by name.
- property cardinality: int | None[source]
 Gets the cardinality of elements in this tunable, or else None. (i.e., when the tunable is continuous float and not quantized).
If the tunable has quantization set, this
- Returns:
 cardinality – Either the number of points in the tunable or else None.
- Return type:
 
- property categories: list[str | None][source]
 Get the list of all possible values of a categorical tunable. Return None if the tunable is not categorical.
- property category: str | None[source]
 Get the current value of the tunable as a string.
- Return type:
 str | None
- property default: TunableValue[source]
 Get the default value of the tunable.
- Return type:
 
- property distribution: DistributionName | None[source]
 Get the name of the distribution (uniform, normal, or beta) if specified.
- Returns:
 distribution – Name of the distribution (uniform, normal, or beta) or None.
- Return type:
 
- property distribution_params: dict[str, float][source]
 Get the parameters of the distribution, if specified.
- property dtype: TunableValueType[source]
 Get the actual Python data type of the tunable.
This is useful for bulk conversions of the input data.
- Returns:
 dtype – Data type of the tunable - one of {int, float, str}.
- Return type:
 
- property is_categorical: bool[source]
 Check if the tunable is categorical.
- Returns:
 is_categorical – True if the tunable is categorical, False otherwise.
- Return type:
 
- property is_log: bool | None[source]
 Check if numeric tunable is log scale.
- Returns:
 log – True if numeric tunable is log scale, False if linear.
- Return type:
 
- property is_numerical: bool[source]
 Check if the tunable is an integer or float.
- Returns:
 is_int – True if the tunable is an integer or float, False otherwise.
- Return type:
 
- property is_special: bool[source]
 Check if the current value of the tunable is special.
- Returns:
 is_special – True if the current value of the tunable is special, False otherwise.
- Return type:
 
- property meta: dict[str, Any][source]
 Get the tunable’s metadata.
This is a free-form dictionary that can be used to store any additional information about the tunable (e.g., the unit information).
- property quantization_bins: int | None[source]
 Get the number of quantization bins, if specified.
- Returns:
 quantization_bins – Number of quantization bins, or None.
- Return type:
 int | None
- property quantized_values: collections.abc.Iterable[int] | collections.abc.Iterable[float] | None[source]
 Get a sequence of quantized values for this tunable.
- property range: tuple[int, int] | tuple[float, float][source]
 Get the range of the tunable if it is numerical, None otherwise.
- property range_weight: float | None[source]
 Get weight of the range of the numeric tunable. Return None if there are no weights or a tunable is categorical.
- Returns:
 weight – Weight of the range or None.
- Return type:
 
- property span: int | float[source]
 Gets the span of the range.
Note: this does not take quantization into account.
- property special: list[int] | list[float][source]
 Get the special values of the tunable. Return an empty list if there are none.
- property type: TunableValueTypeName[source]
 Get the data type of the tunable.
- Returns:
 type – Data type of the tunable - one of {‘int’, ‘float’, ‘categorical’}.
- Return type:
 
- property value: TunableValue[source]
 Get the current value of the tunable.
- Return type:
 
- property values: collections.abc.Iterable[str | None] | collections.abc.Iterable[int] | collections.abc.Iterable[float] | None[source]
 Gets the categories or quantized values for this tunable.
- class mlos_bench.tunables.tunable.TunableDict[source]
 Bases:
TunableDictOptA TypedDict for a
Tunableparameter’s required config parameters.Mostly used for mypy type checking. These are the types expected to be received from the json config.
Initialize self. See help(type(self)) for accurate signature.
- default: TunableValue[source]
 
- class mlos_bench.tunables.tunable.TunableDictOpt[source]
 Bases:
TypedDictA TypedDict for a
Tunableparameter’s optional config parameters.Mostly used for mypy type checking. These are the types expected to be received from the json config.
Initialize self. See help(type(self)) for accurate signature.
- distribution: DistributionDict | None[source]
 
- mlos_bench.tunables.tunable.tunable_dict_from_dict(config: dict[str, Any]) TunableDict[source]
 Creates a TunableDict from a regular dict.