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:

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(searchspace[, batch_size, ...])

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

select_recommender(searchspace[, ...])

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:

allow_recommending_already_measured

Deprecated! The flag has become an attribute of baybe.recommenders.pure.base.PureRecommender.

allow_repeated_recommendations

Deprecated! The flag has become an attribute of baybe.recommenders.pure.base.PureRecommender.

__init__(recommenders, mode: Literal['raise', 'reuse_last', 'cyclic'] = 'raise', _step: int = -1, _n_last_measurements: int = -1, *, allow_repeated_recommendations: bool | None = None, allow_recommending_already_measured: bool | None = None)

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(searchspace: SearchSpace, batch_size: int = 1, train_x: DataFrame | None = None, train_y: DataFrame | None = None)

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

Return type:

DataFrame

select_recommender(searchspace: SearchSpace, batch_size: int = 1, train_x: DataFrame | None = None, train_y: 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.

allow_recommending_already_measured: bool

Deprecated! The flag has become an attribute of baybe.recommenders.pure.base.PureRecommender.

allow_repeated_recommendations: bool

Deprecated! The flag has become an attribute of baybe.recommenders.pure.base.PureRecommender.

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.