SequentialMetaRecommender

class baybe.recommenders.meta.sequential.SequentialMetaRecommender[source]

Bases: MetaRecommender

A meta recommender that uses a pre-defined sequence of recommenders.

A new recommender is taken from the sequence whenever at least one new measurement is available, until all recommenders are exhausted. More precisely, a recommender change is triggered whenever the size of the training dataset increases; the actual content of the dataset is ignored.

Note

The provided sequence of recommenders will be internally pre-collected into a list. If this is not acceptable, consider using baybe.recommenders.meta.sequential.StreamingSequentialMetaRecommender instead.

Raises:
  • RuntimeError – If the training dataset size decreased compared to the previous call.

  • NoRecommendersLeftError – If more recommenders are requested than there are recommenders available and mode="raise".

Public methods

__init__(recommenders[, mode, _step, ...])

Method generated by attrs for class SequentialMetaRecommender.

from_dict(dictionary)

Create an object from its dictionary representation.

from_json(string)

Create an object from its JSON representation.

recommend(batch_size, searchspace[, ...])

See baybe.recommenders.base.RecommenderProtocol.recommend().

select_recommender(batch_size[, ...])

Select a pure recommender for the given experimentation context.

to_dict()

Create an object's dictionary representation.

to_json()

Create an object's JSON representation.

Public attributes and properties

recommenders

A finite-length sequence of recommenders to be used.

mode

Defines what shall happen when the last recommender in the sequence has been consumed but additional recommender changes are triggered:

__init__(recommenders, mode: Literal['raise', 'reuse_last', 'cyclic'] = 'raise', _step: int = -1, _n_last_measurements: int = -1)

Method generated by attrs for class SequentialMetaRecommender.

For details on the parameters, see Public attributes and properties.

classmethod from_dict(dictionary: dict)

Create an object from its dictionary representation.

Parameters:

dictionary (dict) – The dictionary representation.

Return type:

TypeVar(_T)

Returns:

The reconstructed object.

classmethod from_json(string: str)

Create an object from its JSON representation.

Parameters:

string (str) – The JSON representation of the object.

Return type:

TypeVar(_T)

Returns:

The reconstructed object.

recommend(batch_size: int, searchspace: SearchSpace, objective: Objective | None = None, measurements: DataFrame | None = None)

See baybe.recommenders.base.RecommenderProtocol.recommend().

Return type:

DataFrame

select_recommender(batch_size: int, searchspace: SearchSpace | None = None, objective: Objective | None = None, measurements: DataFrame | None = None)[source]

Select a pure recommender for the given experimentation context.

Parameters:
Return type:

PureRecommender

Returns:

The selected recommender.

to_dict()

Create an object’s dictionary representation.

Return type:

dict

to_json()

Create an object’s JSON representation.

Return type:

str

Returns:

The JSON representation as a string.

mode: Literal['raise', 'reuse_last', 'cyclic']

Defines what shall happen when the last recommender in the sequence has been consumed but additional recommender changes are triggered:

  • "raise": An error is raised.

  • "reuse_last": The last recommender in the sequence is used indefinitely.

  • "cycle": The selection restarts from the beginning of the sequence.

recommenders: list[PureRecommender]

A finite-length sequence of recommenders to be used. For infinite-length iterables, see baybe.recommenders.meta.sequential.StreamingSequentialMetaRecommender.