@@ -63,6 +63,33 @@ def dispatch(self, event):
6363
6464
6565class BayesianOptimization (Observable ):
66+ """
67+ This class takes the function to optimize as well as the parameters bounds in order to
68+ find which values for the parameters yield the maximum value using bayesian optimization.
69+
70+ Parameters
71+ ----------
72+ f: function
73+ The function to optimize.
74+ pbounds: dict
75+ The dictionary with the bounds for the parameters to use in the optimization. The dictionary contains the lower
76+ and upper boundaries.
77+ random_state: int or numpy.random.RandomState, optional(default=None)
78+ If the value is an integer, it is used as the seed for creating a numpy.random.RandomState.
79+ Otherwise the random state provieded it is used. When set to None, an unseeded random state is generated.
80+ verbose: int, optional(default=2)
81+ The level of verbosity.
82+ bounds_transformer: DomainTransformer, optional(default=None)
83+ If provided, the transformation is applied to the bounds.
84+
85+ Methods
86+ -------
87+ probe()
88+ Evaluates the function on the given points. Can be used to guide the optimizer.
89+
90+ maximize()
91+ Tries to find the parameters that yield the maximum value for the given function.
92+ """
6693 def __init__ (self , f , pbounds , random_state = None , verbose = 2 ,
6794 bounds_transformer = None ):
6895 """"""
@@ -109,15 +136,25 @@ def register(self, params, target):
109136 self .dispatch (Events .OPTIMIZATION_STEP )
110137
111138 def probe (self , params , lazy = True ):
112- """Probe target of x"""
139+ """
140+ Evaluates the function on the given points. Useful to guide the optimizer.
141+
142+ Parameters
143+ ----------
144+ params: dict or list
145+ The parameters where the optimizer will evaluate the function.
146+ lazy: bool, optional(default=True)
147+ If True, the optimizer will evaluate the points when calling maximize().
148+ Otherwise it will evaluate it at the moment.
149+ """
113150 if lazy :
114151 self ._queue .add (params )
115152 else :
116153 self ._space .probe (params )
117154 self .dispatch (Events .OPTIMIZATION_STEP )
118155
119156 def suggest (self , utility_function ):
120- """Most promissing point to probe next"""
157+ """Most promising point to probe next"""
121158 if len (self ._space ) == 0 :
122159 return self ._space .array_to_params (self ._space .random_sample ())
123160
@@ -162,7 +199,31 @@ def maximize(self,
162199 kappa_decay_delay = 0 ,
163200 xi = 0.0 ,
164201 ** gp_params ):
165- """Mazimize your function"""
202+ """
203+ Probes the target space to find the parameters that yield the maximum value for the given function.
204+
205+ Parameters
206+ ----------
207+ init_points : int, optional(default=5)
208+ Number of iterations before the explorations starts the exploration for the maximum.
209+ n_iter: int, optional(default=25)
210+ Number of iterations where the method attempts to find the maximum value.
211+ acq: {'ucb', 'ei', 'poi'}
212+ The acquisition method used.
213+ * 'ucb' stands for the Upper Confidence Bounds method
214+ * 'ei' is the Expected Improvement method
215+ * 'poi' is the Probability Of Improvement criterion.
216+ kappa: float, optional(default=2.576)
217+ Parameter to indicate how closed are the next parameters sampled.
218+ Higher value = favors spaces that are least explored.
219+ Lower value = favors spaces where the regression function is the highest.
220+ kappa_decay: float, optional(default=1)
221+ `kappa` is multiplied by this factor every iteration.
222+ kappa_decay_delay: int, optional(default=0)
223+ Number of iterations that must have passed before applying the decay to `kappa`.
224+ xi: float, optional(default=0.0)
225+ [unused]
226+ """
166227 self ._prime_subscriptions ()
167228 self .dispatch (Events .OPTIMIZATION_START )
168229 self ._prime_queue (init_points )
0 commit comments