mlos_bench.tunables.covariant_group

Tunable parameter definition.

Classes

CovariantTunableGroup

A collection of tunable parameters.

Module Contents

class mlos_bench.tunables.covariant_group.CovariantTunableGroup(name: str, config: dict)[source]

A collection of tunable parameters.

Changing any of the parameters in the group incurs the same cost of the experiment.

Create a new group of tunable parameters.

Parameters:
  • name (str) – Human-readable identifier of the tunable parameters group.

  • config (dict) – Python dict that represents a CovariantTunableGroup (e.g., deserialized from JSON).

__contains__(tunable: str | mlos_bench.tunables.tunable.Tunable) bool[source]
Parameters:

tunable (Union[str, mlos_bench.tunables.tunable.Tunable])

Return type:

bool

__eq__(other: object) bool[source]

Check if two CovariantTunableGroup objects are equal.

Parameters:

other (CovariantTunableGroup) – A covariant tunable group object to compare to.

Returns:

is_equal – True if two CovariantTunableGroup objects are equal.

Return type:

bool

__getitem__(tunable: str | mlos_bench.tunables.tunable.Tunable) mlos_bench.tunables.tunable.TunableValue[source]
Parameters:

tunable (Union[str, mlos_bench.tunables.tunable.Tunable])

Return type:

mlos_bench.tunables.tunable.TunableValue

__repr__() str[source]

Produce a human-readable version of the CovariantTunableGroup (mostly for logging).

Returns:

string – A human-readable version of the CovariantTunableGroup.

Return type:

str

__setitem__(tunable: str | mlos_bench.tunables.tunable.Tunable, tunable_value: mlos_bench.tunables.tunable.TunableValue | mlos_bench.tunables.tunable.Tunable) mlos_bench.tunables.tunable.TunableValue[source]
Parameters:
Return type:

mlos_bench.tunables.tunable.TunableValue

copy() CovariantTunableGroup[source]

Deep copy of the CovariantTunableGroup object.

Returns:

group – A new instance of the CovariantTunableGroup object that is a deep copy of the original one.

Return type:

CovariantTunableGroup

equals_defaults(other: CovariantTunableGroup) bool[source]

Checks to see if the other CovariantTunableGroup is the same, ignoring the current values of the two groups’ Tunables.

Parameters:

other (CovariantTunableGroup) – A covariant tunable group object to compare to.

Returns:

are_equal – True if the two CovariantTunableGroup objects’ metadata are the same, False otherwise.

Return type:

bool

get_current_cost() int[source]

Get the cost of the experiment given current tunable values.

Returns:

cost – Cost of the experiment or 0 if parameters have not been updated.

Return type:

int

get_names() Iterable[str][source]

Get the names of all tunables in the group.

Return type:

Iterable[str]

get_tunable(tunable: str | mlos_bench.tunables.tunable.Tunable) mlos_bench.tunables.tunable.Tunable[source]

Access the entire Tunable in a group (not just its value). Throw KeyError if the tunable is not in the group.

Parameters:

tunable (str) – Name of the tunable parameter.

Returns:

An instance of the Tunable parameter.

Return type:

Tunable

get_tunable_values_dict() Dict[str, mlos_bench.tunables.tunable.TunableValue][source]

Get current values of all tunables in the group as a dict.

Returns:

tunables

Return type:

Dict[str, TunableValue]

get_tunables() Iterable[mlos_bench.tunables.tunable.Tunable][source]

Gets the set of tunables for this CovariantTunableGroup.

Return type:

Iterable[Tunable]

is_defaults() bool[source]

Checks whether the currently assigned values of all tunables are at their defaults.

Return type:

bool

is_updated() bool[source]

Check if any of the tunable values in the group has been updated.

Returns:

is_updated – True if any of the tunable values in the group has been updated, False otherwise.

Return type:

bool

reset_is_updated() None[source]

Clear the update flag.

That is, state that running an experiment with the current values of the tunables in this group has no extra cost.

Return type:

None

restore_defaults() None[source]

Restore all tunable parameters to their default values.

Return type:

None

property cost: int[source]

Get the cost of changing the values in the covariant group. This value is a constant. Use get_current_cost() to get the cost given the group update status.

Returns:

cost – Cost of changing the values in the covariant group.

Return type:

int

property name: str[source]

Get the name of the covariant group.

Returns:

name – Name (i.e., a string id) of the covariant group.

Return type:

str