mlos_bench.tunables.tunable
Tunable parameter definition.
Attributes
Tunable value type. |
|
Tunable value type tuple. |
|
Tunable values dictionary type. |
|
The string name of a tunable value type. |
|
Tunable value distribution type. |
Classes
A typed dict for tunable parameters' distributions. |
|
A tunable parameter definition and its current value. |
|
A typed dict for tunable parameters. |
Module Contents
- class mlos_bench.tunables.tunable.DistributionDict[source]
Bases:
TypedDict
A typed dict for tunable parameters’ distributions.
Initialize self. See help(type(self)) for accurate signature.
- class mlos_bench.tunables.tunable.Tunable(name: str, config: TunableDict)[source]
A tunable parameter definition and its current value.
Create an instance of a new tunable parameter.
- Parameters:
- __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.
- 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.
- Returns:
values – List of all possible values of a categorical tunable.
- Return type:
List[str]
- property category: str | None[source]
Get the current value of the tunable as a string.
- Return type:
Optional[str]
- 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).
- Return type:
Dict[str, Any]
- 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: Iterable[int] | Iterable[float] | None[source]
Get a sequence of quanitized 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:
- class mlos_bench.tunables.tunable.TunableDict[source]
Bases:
TypedDict
A typed dict for tunable 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]
- distribution: DistributionDict | None[source]