StreamingSequentialMetaRecommender¶
- class baybe.recommenders.meta.sequential.StreamingSequentialMetaRecommender[source]¶
Bases:
BaseSequentialMetaRecommenderA meta recommender that switches between recommenders from an iterable.
Similar to
baybe.recommenders.meta.sequential.SequentialMetaRecommenderbut without explicit list conversion. This enables a number of advanced use cases:It supports arbitrary iterables, allowing to configure recommender sequences of infinite length. This is useful when the total number of iterations unknown in advance.
It can be used to adaptively adjust the recommender sequence based on the latest context available outside the class, by modifying the iterable on the fly.
The downside is that serialization is not supported.
- Raises:
NoRecommendersLeftError – If more recommenders are requested than there are recommenders available.
Public methods
__init__(recommenders, *[, _n_last_measurements])Method generated by attrs for class StreamingSequentialMetaRecommender.
from_dict(dictionary)Create an object from its dictionary representation.
from_json(source, /)Create an object from its JSON representation.
Deprecated! Use
select_recommender()orget_non_meta_recommender()instead.Deprecated! Use
select_recommender()orget_non_meta_recommender()instead.get_non_meta_recommender([batch_size, ...])Follow the meta recommender chain to the selected non-meta recommender.
recommend(batch_size, searchspace[, ...])See
baybe.recommenders.base.RecommenderProtocol.recommend().select_recommender([batch_size, ...])Select a recommender for the given experimentation context.
to_dict()Create an object's dictionary representation.
to_json([sink, overwrite])Create an object's JSON representation.
Public attributes and properties
An iterable providing the recommenders to be used.
Boolean indicating if the meta recommender is stateful.
- __init__(recommenders: Iterable[RecommenderProtocol], *, _n_last_measurements: int = 0)¶
Method generated by attrs for class StreamingSequentialMetaRecommender.
For details on the parameters, see Public attributes and properties.
- classmethod from_json(source: str | Path | SupportsRead[str], /)¶
Create an object from its JSON representation.
- Parameters:
source (str | Path | SupportsRead[str]) –
The JSON source. Can be:
A string containing JSON content.
A file path or
Pathobject pointing to a JSON file.A file-like object with a
read()method.
- Raises:
ValueError – If
sourceis not one of the allowed types.- Return type:
_T
- Returns:
The reconstructed object.
- get_current_recommender()¶
Deprecated! Use
select_recommender()orget_non_meta_recommender()instead.- Return type:
- get_next_recommender()¶
Deprecated! Use
select_recommender()orget_non_meta_recommender()instead.- Return type:
- get_non_meta_recommender(batch_size: int | None = None, searchspace: SearchSpace | None = None, objective: Objective | None = None, measurements: DataFrame | None = None, pending_experiments: DataFrame | None = None)¶
Follow the meta recommender chain to the selected non-meta recommender.
Recursively calls
MetaRecommender.select_recommender()until a non-meta recommender is encountered, which is then returned. Effectively, this extracts the recommender responsible for generating the recommendations for the specified context.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 | None = None, searchspace: SearchSpace | None = None, objective: Objective | None = None, measurements: DataFrame | None = None, pending_experiments: DataFrame | None = None)¶
Select a recommender for the given experimentation context.
See
baybe.recommenders.base.RecommenderProtocol.recommend()for details on the method arguments.- Return type:
- to_dict()¶
Create an object’s dictionary representation.
- Return type:
- Returns:
The dictionary representation of the object.
- to_json(sink: str | Path | SupportsWrite[str] | None = None, /, *, overwrite: bool = False, **kwargs: Any)¶
Create an object’s JSON representation.
- Parameters:
sink (str | Path | SupportsWrite[str] | None) –
The JSON sink. Can be:
None(only returns the JSON string).A file path or
Pathobject pointing to a location where to write the JSON content.A file-like object with a
write()method.
overwrite (bool) – Boolean flag indicating if to overwrite the file if it already exists. Only relevant if
sinkis a file path orPathobject.**kwargs (Any) – Additional keyword arguments to pass to
json.dumps().
- Raises:
FileExistsError – If
sinkpoints to an already existing file butoverwriteisFalse.- Return type:
str
- Returns:
The JSON representation as a string.
-
recommenders:
Iterable[RecommenderProtocol]¶ An iterable providing the recommenders to be used.