BotorchRecommender

class baybe.recommenders.pure.bayesian.botorch.BotorchRecommender[source]

Bases: BayesianRecommender

A pure recommender utilizing Botorch’s optimization machinery.

This recommender makes use of Botorch’s optimize_acqf_discrete, optimize_acqf and optimize_acqf_mixed functions to optimize discrete, continuous and hybrid search spaces, respectively. Accordingly, it can be applied to all kinds of search spaces.

Note

In hybrid search spaces, the used algorithm performs a brute-force optimization that can be computationally expensive. Thus, the behavior of the algorithm in hybrid search spaces can be controlled via two additional parameters.

Public methods

__init__(*[, ...])

Method generated by attrs for class BotorchRecommender.

get_surrogate(searchspace, objective, ...)

Get the trained surrogate model.

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

Recommend a batch of points from the given search space.

Public attributes and properties

sequential_continuous

Flag defining whether to apply sequential greedy or batch optimization in continuous search spaces.

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.

n_restarts

Number of times gradient-based optimization is restarted from different initial points.

n_raw_samples

Number of raw samples drawn for the initialization heuristic in gradient-based optimization.

acquisition_function

The used acquisition function class.

acquisition_function_cls

Deprecated! Raises an error when used.

allow_recommending_already_measured

Deprecated!

allow_recommending_pending_experiments

Deprecated!

allow_repeated_recommendations

Deprecated!

compatibility

Class variable reflecting the search space compatibility.

surrogate_model

Deprecated!

__init__(*, allow_repeated_recommendations: bool | None = None, allow_recommending_already_measured: bool | None = None, allow_recommending_pending_experiments: bool | None = None, surrogate_model: SurrogateProtocol = NOTHING, acquisition_function: AcquisitionFunction | str = NOTHING, acquisition_function_cls: str | None = None, sequential_continuous: bool = False, hybrid_sampler=None, sampling_percentage: float = 1.0, n_restarts: int = 10, n_raw_samples: int = 64)

Method generated by attrs for class BotorchRecommender.

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

get_surrogate(searchspace: SearchSpace, objective: Objective, measurements: DataFrame)

Get the trained surrogate model.

Return type:

SurrogateProtocol

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

Recommend a batch of points from the given search space.

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

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

  • objective (Optional[Objective]) – An optional objective to be optimized.

  • measurements (Optional[DataFrame]) – Optional experimentation data that can be used for model training. The data is to be provided in “experimental representation”: It needs to contain one column for each parameter spanning the search space (column name matching the parameter name) and one column for each target tracked by the objective (column name matching the target name). Each row corresponds to one conducted experiment, where the parameter columns define the experimental setting and the target columns report the measured outcomes.

  • pending_experiments (Optional[DataFrame]) – Parameter configurations in “experimental representation” specifying experiments that are currently pending.

Return type:

DataFrame

Returns:

A dataframe containing the recommendations in experimental representation as individual rows.

acquisition_function: AcquisitionFunction

The used acquisition function class.

acquisition_function_cls: str | None

Deprecated! Raises an error when used.

property allow_recommending_already_measured: NoReturn

Deprecated!

property allow_recommending_pending_experiments: NoReturn

Deprecated!

property allow_repeated_recommendations: NoReturn

Deprecated!

compatibility: ClassVar[SearchSpaceType] = 'HYBRID'

Class variable reflecting the search space compatibility.

hybrid_sampler: DiscreteSamplingMethod | None

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

n_raw_samples: int

Number of raw samples drawn for the initialization heuristic in gradient-based optimization. Does not affect purely discrete optimization.

n_restarts: int

Number of times gradient-based optimization is restarted from different initial points. Does not affect purely discrete optimization.

sampling_percentage: float

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

sequential_continuous: bool

Flag defining whether to apply sequential greedy or batch optimization in continuous search spaces. In discrete/hybrid spaces, sequential greedy optimization is applied automatically.

property surrogate_model: SurrogateProtocol

Deprecated!