SequentialGreedyRecommender

class baybe.recommenders.pure.bayesian.sequential_greedy.SequentialGreedyRecommender[source]

Bases: BayesianRecommender

Pure recommender using sequential greedy optimization.

This recommender implements the BoTorch functions optimize_acqf_discrete, optimize_acqf and optimize_acqf_mixed for the optimization of discrete, continuous and hybrid search spaces. In particular, it can be applied in all kinds of search spaces. It is important to note that this algorithm performs a brute-force optimization in hybrid search spaces which can be computationally expensive. Thus, the behavior of the algorithm in hybrid search spaces can be controlled by two additional parameters.

Public methods

__init__([surrogate_model, ...])

Method generated by attrs for class SequentialGreedyRecommender.

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

Recommend a batch of points from the given search space.

setup_acquisition_function(searchspace[, ...])

Create the current acquisition function from provided training data.

Public attributes and properties

hybrid_sampler

Strategy used for sampling the discrete subspace when performing hybrid search space optimization.

sampling_percentage

Percentage of discrete search space that is sampled when performing hybrid search space optimization.

acquisition_function_cls

The used acquisition function class.

allow_recommending_already_measured

Allow to make recommendations that were measured previously.

allow_repeated_recommendations

Allow to make recommendations that were already recommended earlier.

compatibility

Class variable reflecting the search space compatibility.

surrogate_model

The used surrogate model.

__init__(surrogate_model: Surrogate = NOTHING, acquisition_function_cls: Literal['PM', 'PI', 'EI', 'UCB', 'qPI', 'qEI', 'qUCB', 'VarUCB', 'qVarUCB'] = 'qEI', hybrid_sampler: str = 'None', sampling_percentage: float = 1.0, *, allow_repeated_recommendations: bool = False, allow_recommending_already_measured: bool = True)

Method generated by attrs for class SequentialGreedyRecommender.

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

recommend(searchspace: SearchSpace, batch_size: int = 1, train_x: DataFrame | None = None, train_y: DataFrame | None = None)

Recommend a batch of points from the given search space.

Parameters:
  • searchspace (SearchSpace) – The search space from which to recommend the points.

  • batch_size (int) – The number of points to be recommended.

  • train_x (Optional[DataFrame]) – Optional training inputs for training a model.

  • train_y (Optional[DataFrame]) – Optional training labels for training a model.

Return type:

DataFrame

Returns:

A dataframe containing the recommendations as individual rows.

setup_acquisition_function(searchspace: SearchSpace, train_x: DataFrame | None = None, train_y: DataFrame | None = None)

Create the current acquisition function from provided training data.

The acquisition function is stored in the private attribute _acquisition_function.

Parameters:
  • searchspace (SearchSpace) – The search space in which the experiments are to be conducted.

  • train_x (Optional[DataFrame]) – The features of the conducted experiments.

  • train_y (Optional[DataFrame]) – The corresponding response values.

Raises:

NotImplementedError – If the setup is attempted from empty training data

Return type:

None

acquisition_function_cls: Literal['PM', 'PI', 'EI', 'UCB', 'qPI', 'qEI', 'qUCB', 'VarUCB', 'qVarUCB']

The used acquisition function class.

allow_recommending_already_measured: bool

Allow to make recommendations that were measured previously. This only has an influence in discrete search spaces.

allow_repeated_recommendations: bool

Allow to make recommendations that were already recommended earlier. This only has an influence in discrete search spaces.

compatibility: ClassVar[SearchSpaceType] = 'HYBRID'

Class variable reflecting the search space compatibility.

hybrid_sampler: str

Strategy used for sampling the discrete subspace when performing hybrid search space optimization.

sampling_percentage: float

Percentage of discrete search space that is sampled when performing hybrid search space optimization. Ignored when hybrid_sampler="None".

surrogate_model: Surrogate

The used surrogate model.