@@ -53,20 +53,81 @@ BayBE offers two entry points for requesting recommendations:
53
53
54
54
55
55
## Excluding Configurations
56
+ When asking for recommendation, you often don't want to consider all possible
57
+ combinations of parameter values (a.k.a. the full Cartesian product space) but you may
58
+ want to exclude certain configurations that are known to be infeasible or undesirable.
59
+ There are several ways to do this, including using BayBE's sophisticated [ constraint
60
+ machinery] ( userguide/constraints ) . Which approach is the right choice for you depends on
61
+ whether you want to exclude configurations * permanently* or (in-)activate them
62
+ * dynamically* during your experimentation cycle.
63
+
64
+ ### Permanent Exclusion
65
+
66
+ Permanently excluding certain parameter configurations from the recommendation is
67
+ generally done by adjusting the {class}` ~baybe.searchspace.core.SearchSpace ` object
68
+ accordingly, which defines the set of candidate configurations that will be considered.
69
+
70
+ BayBE provides several ways to achieve this, which we'll illustrate by comparing against
71
+ the following "full" search space:
72
+ ``` python
73
+ searchspace_full = TaskParameter(" p" , [" A" , " B" , " C" ]).to_searchspace()
74
+ ```
75
+ Depending on the specific needs and complexity of the filtering operation, one approach
76
+ may be preferred over the other, but generally these mechanisms exist:
77
+
78
+ * Restricting individual parameter objects:
79
+ ``` python
80
+ searchspace_reduced = TaskParameter(
81
+ " p" , [" A" , " B" , " C" ], active_values = [" A" , " B" ]
82
+ ).to_searchspace()
83
+ ```
84
+
85
+ ``` {admonition} Reduced
86
+ :class: caution
87
+
88
+ Note that this is *not* the same as defining the parameter with a reduced set of
89
+ values `["A", "B"]` since in this case the value "C" would be undefined. This
90
+ makes adding measurements containing that value impossible.
91
+ ```
92
+
93
+ * Specifying only a subset of configurations (discrete spaces only):
94
+ ``` python
95
+ searchspace_reduced = SearchSpace.from_dataframe(
96
+ pd.DataFrame({" p" : [" A" , " B" ]}),
97
+ parameters = [TaskParameter(" p" , [" A" , " B" , " C" ])],
98
+ )
99
+ ```
100
+
101
+ * Filtering the search space using constraints:
102
+ ``` python
103
+ searchspace_reduced = SearchSpace.from_product(
104
+ parameters = [CategoricalParameter(" p" , [" A" , " B" , " C" ])],
105
+ constraints = [DiscreteExcludeConstraint([" p" ], [SubSelectionCondition([" C" ])])],
106
+ )
107
+ ```
108
+
109
+ * Using specialized constructors like
110
+ {meth}` ~baybe.searchspace.discrete.SubspaceDiscrete.from_simplex ` .
111
+
112
+ ### Dynamic Exclusion
113
+
114
+ Dynamic exclusion of candidates means to in-/exclude certain parameter configurations
115
+ while you are already in the middle of your experimentation process. Here,
116
+ we need to consider two different cases:
56
117
57
- Excluding certain parameter configurations from recommendation is generally done by
58
- adjusting the {class}` ~baybe.searchspace.core.SearchSpace ` object accordingly, which
59
- defines the set of candidate configurations that will be considered.
60
118
* ** Recommenders** \
61
- The above means that, for [ stateless queries] ( #stateless ) , you can simply pass a
62
- different search space object to each call according to your needs:
119
+ Since recommender queries are [ stateless] ( #stateless ) with respect to the
120
+ experimental context, you can easily adjust your search space object for each query
121
+ as needed using any of the * permanent* exclusion methods. For example:
63
122
``` python
64
123
# Recommendation with full search space
65
124
searchspace_full = CategoricalParameter(" p" , [" A" , " B" , " C" ]).to_searchspace()
66
125
recommender.recommend(batch_size, searchspace_full, objective, measurements)
67
126
68
127
# Recommendation with reduced search space
69
- searchspace_reduced = CategoricalParameter(" p" , [" A" , " B" ]).to_searchspace()
128
+ searchspace_reduced = TaskParameter(
129
+ " p" , [" A" , " B" , " C" ], active_values = [" A" , " B" ]
130
+ ).to_searchspace()
70
131
recommender.recommend(batch_size, searchspace_reduced, objective, measurements)
71
132
```
72
133
@@ -93,6 +154,14 @@ defines the set of candidate configurations that will be considered.
93
154
{class}` ~baybe.constraints.base.DiscreteConstraint ` objects.
94
155
For more details, see {meth}` baybe.campaign.Campaign.toggle_discrete_candidates ` .
95
156
157
+ ``` {admonition} Candidate Toggling vs. Applying Constraints
158
+ :class: attention
159
+
160
+ Currently, dynamic exclusion via toggling is only possible for discrete candidates.
161
+ To restrict the set of continuous candidates, use
162
+ {class}`~baybe.constraints.base.ContinuousConstraint`s when creating the space.
163
+ ```
164
+
96
165
``` {admonition} Trajectory-Based Control
97
166
:class: seealso
98
167
@@ -101,14 +170,6 @@ defines the set of candidate configurations that will be considered.
101
170
{ref}`flags <userguide/campaigns:Candidate Control in Discrete Spaces>`.
102
171
```
103
172
104
- ``` {admonition} Continuous Constraints
105
- :class: attention
106
-
107
- Currently, candidate exclusion at the {class}`~baybe.campaign.Campaign` level is
108
- only possible for the discrete part of the underlying search space. To restrict
109
- the continuous part of the search, use
110
- {class}`~baybe.constraints.base.ContinuousConstraint`s when creating the space.
111
- ```
112
173
113
174
114
175
0 commit comments