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.
Get the current recommender, if available.
get_next_recommender
(batch_size, searchspace)Get the recommender for the next recommendation.
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
A finite-length sequence of recommenders to be used.
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.
- get_current_recommender()¶
Get the current recommender, if available.
- Return type:
- get_next_recommender(batch_size: int, searchspace: SearchSpace, objective: Objective | None = None, measurements: DataFrame | None = None, pending_experiments: DataFrame | None = None)¶
Get the recommender for the next recommendation.
Returns the next recommender in row that has not yet been used for generating recommendations. In case of multiple consecutive calls, this means that the same recommender instance is returned until its
recommend()
method is called.See
baybe.recommenders.base.RecommenderProtocol.recommend()
for details on the method arguments.- Return type:
- recommend(batch_size: int, searchspace: SearchSpace, objective: Objective | None = None, measurements: DataFrame | None = None, pending_experiments: DataFrame | None = None)¶
See
baybe.recommenders.base.RecommenderProtocol.recommend()
.- Return type:
- select_recommender(batch_size: int, searchspace: SearchSpace | None = None, objective: Objective | None = None, measurements: DataFrame | None = None, pending_experiments: DataFrame | None = None)[source]¶
Select a pure recommender for the given experimentation context.
See
baybe.recommenders.base.RecommenderProtocol.recommend()
for details on the method arguments.- Return type:
- to_json()¶
Create an object’s JSON representation.
- Return type:
- 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
.