mlos_core.data_classes

Data classes for mlos_core used to pass around configurations, observations, and suggestions.

mlos_core uses pandas DataFrame s and Series to represent configurations and scores and context (information about where the configuration was evaluated).

These modules encapsulate tuples of those for easier passing around and manipulation.

Classes

Observation

A single observation of a configuration.

Observations

A set of observations of a configuration scores.

Suggestion

A single suggestion for a configuration.

Module Contents

class mlos_core.data_classes.Observation(*, config: pandas.Series, score: pandas.Series = pd.Series(), context: pandas.Series | None = None, metadata: pandas.Series | None = None)[source]

A single observation of a configuration.

Creates a new Observation object.

Parameters:
  • config (pandas.Series) – The configuration observed.

  • score (pandas.Series) – The score metrics observed.

  • context (Optional[pandas.Series]) – The context in which the configuration was evaluated. Not Yet Implemented.

  • metadata (Optional[pandas.Series]) – The metadata in which the configuration was evaluated

__eq__(other: Any) bool[source]
Parameters:

other (Any)

Return type:

bool

__ne__(other: Any) bool[source]
Parameters:

other (Any)

Return type:

bool

__repr__() str[source]
Return type:

str

to_suggestion() Suggestion[source]

Converts the observation to a suggestion.

Returns:

The suggestion.

Return type:

Suggestion

property config: pandas.Series[source]

Gets (a copy of) the config of the Observation.

Return type:

pandas.Series

property context: pandas.Series | None[source]

Gets (a copy of) the context of the Observation.

Return type:

Optional[pandas.Series]

property metadata: pandas.Series | None[source]

Gets (a copy of) the metadata of the Observation.

Return type:

Optional[pandas.Series]

property score: pandas.Series[source]

Gets (a copy of) the score of the Observation.

Return type:

pandas.Series

class mlos_core.data_classes.Observations(*, configs: pandas.DataFrame = pd.DataFrame(), scores: pandas.DataFrame = pd.DataFrame(), contexts: pandas.DataFrame | None = None, metadata: pandas.DataFrame | None = None, observations: Iterable[Observation] | None = None)[source]

A set of observations of a configuration scores.

Creates a new Observation object.

Can accept either a set of Observations or a collection of aligned config and score (and optionally context) dataframes.

If both are provided the two sets will be merged.

Parameters:
  • configs (pandas.DataFrame) – Pandas dataframe containing configurations. Column names are the parameter names.

  • scores (pandas.DataFrame) – The score metrics observed in a dataframe.

  • contexts (Optional[pandas.DataFrame]) – The context in which the configuration was evaluated. Not Yet Implemented.

  • metadata (Optional[pandas.DataFrame]) – The metadata in which the configuration was evaluated Not Yet Implemented.

  • observations (Optional[Iterable[Observation]])

__eq__(other: Any) bool[source]
Parameters:

other (Any)

Return type:

bool

__iter__() Iterator[Observation][source]
Return type:

Iterator[Observation]

__len__() int[source]
Return type:

int

__ne__(other: Any) bool[source]
Parameters:

other (Any)

Return type:

bool

__repr__() str[source]
Return type:

str

append(observation: Observation) None[source]

Appends the given observation to this observation.

Parameters:

observation (Observation) – The observation to append.

Return type:

None

filter_by_index(index: pandas.Index) Observations[source]

Filters the observation by the given indices.

Parameters:

index (pandas.Index) – The indices to filter by.

Returns:

The filtered observation.

Return type:

Observation

property configs: pandas.DataFrame[source]

Gets a copy of the configs of the Observations.

Return type:

pandas.DataFrame

property contexts: pandas.DataFrame | None[source]

Gets a copy of the contexts of the Observations.

Return type:

Optional[pandas.DataFrame]

property metadata: pandas.DataFrame | None[source]

Gets a copy of the metadata of the Observations.

Return type:

Optional[pandas.DataFrame]

property scores: pandas.DataFrame[source]

Gets a copy of the scores of the Observations.

Return type:

pandas.DataFrame

class mlos_core.data_classes.Suggestion(*, config: pandas.Series, context: pandas.Series | None = None, metadata: pandas.Series | None = None)[source]

A single suggestion for a configuration.

A Suggestion is an Observation that has not yet been scored. Evaluating the Suggestion and calling complete(scores) can convert it to an Observation.

Creates a new Suggestion.

Parameters:
  • config (pandas.Series) – The configuration suggested.

  • context (Optional[pandas.Series]) – The context for this suggestion, by default None

  • metadata (Optional[pandas.Series]) – Any metadata provided by the underlying optimizer, by default None

__eq__(other: Any) bool[source]
Parameters:

other (Any)

Return type:

bool

__ne__(other: Any) bool[source]
Parameters:

other (Any)

Return type:

bool

__repr__() str[source]
Return type:

str

complete(score: pandas.Series) Observation[source]

Completes the Suggestion by adding a score to turn it into an Observation.

Parameters:

score (pandas.Series) – The score metrics observed.

Returns:

The observation of the suggestion.

Return type:

Observation

to_configspace_config(space: ConfigSpace.ConfigurationSpace) ConfigSpace.Configuration[source]

Convert a Configuration Space to a Configuration.

Parameters:

space (ConfigSpace.ConfigurationSpace) – The ConfigurationSpace to be converted.

Returns:

The output Configuration.

Return type:

ConfigSpace.Configuration

property config: pandas.Series[source]

Gets (a copy of) the config of the Suggestion.

Return type:

pandas.Series

property context: pandas.Series | None[source]

Gets (a copy of) the context of the Suggestion.

Return type:

Optional[pandas.Series]

property metadata: pandas.Series | None[source]

Gets (a copy of) the metadata of the Suggestion.

Return type:

Optional[pandas.Series]