SKLearnClusteringRecommender

class baybe.recommenders.pure.nonpredictive.clustering.SKLearnClusteringRecommender[source]

Bases: NonPredictiveRecommender, ABC

Intermediate class for cluster-based selection of discrete candidates.

Suitable for sklearn-like models that have a fit and predict method. Specific model parameters and cluster sub-selection techniques can be declared in the derived classes.

Public methods

__init__([model_params, ...])

Method generated by attrs for class SKLearnClusteringRecommender.

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

Recommend a batch of points from the given search space.

Public attributes and properties

model_params

The parameters for the used model.

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.

model_class

Class variable describing the model class.

model_cluster_num_parameter_name

Class variable describing the name of the clustering parameter.

__init__(model_params: dict = NOTHING, *, allow_repeated_recommendations: bool = False, allow_recommending_already_measured: bool = True)

Method generated by attrs for class SKLearnClusteringRecommender.

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.

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] = 'DISCRETE'

Class variable reflecting the search space compatibility.

model_class: ClassVar[type[ClusterMixin]]

Class variable describing the model class.

model_cluster_num_parameter_name: ClassVar[str]

Class variable describing the name of the clustering parameter.

model_params: dict

The parameters for the used model. This is initialized with reasonable default values for the derived child classes.