@@ -64,20 +64,23 @@ def dispatch(self, event):
6464
6565class BayesianOptimization (Observable ):
6666 """
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.
67+ This class takes the function to optimize as well as the parameters bounds
68+ in order to find which values for the parameters yield the maximum value
69+ using bayesian optimization.
6970
7071 Parameters
7172 ----------
7273 f: function
7374 Function to be maximized.
7475
7576 pbounds: dict
76- Dictionary with parameters names as keys and a tuple with minimum and maximum values.
77+ Dictionary with parameters names as keys and a tuple with minimum
78+ and maximum values.
7779
7880 random_state: int or numpy.random.RandomState, optional(default=None)
79- If the value is an integer, it is used as the seed for creating a numpy.random.RandomState.
80- Otherwise the random state provieded it is used. When set to None, an unseeded random state is generated.
81+ If the value is an integer, it is used as the seed for creating a
82+ numpy.random.RandomState. Otherwise the random state provieded it is used.
83+ When set to None, an unseeded random state is generated.
8184
8285 verbose: int, optional(default=2)
8386 The level of verbosity.
@@ -88,24 +91,24 @@ class BayesianOptimization(Observable):
8891 Methods
8992 -------
9093 probe()
91- Evaluates the function on the given points. Can be used to guide the optimizer.
94+ Evaluates the function on the given points.
95+ Can be used to guide the optimizer.
9296
9397 maximize()
94- Tries to find the parameters that yield the maximum value for the given function.
98+ Tries to find the parameters that yield the maximum value for the
99+ given function.
95100
96101 set_bounds()
97102 Allows changing the lower and upper searching bounds
98103 """
99104 def __init__ (self , f , pbounds , random_state = None , verbose = 2 ,
100105 bounds_transformer = None ):
101- """"""
102106 self ._random_state = ensure_rng (random_state )
103107
104108 # Data structure containing the function to be optimized, the bounds of
105109 # its domain, and a record of the evaluations we have done so far
106110 self ._space = TargetSpace (f , pbounds , random_state )
107111
108- # queue
109112 self ._queue = Queue ()
110113
111114 # Internal GP regressor
@@ -151,8 +154,8 @@ def probe(self, params, lazy=True):
151154 The parameters where the optimizer will evaluate the function.
152155
153156 lazy: bool, optional(default=True)
154- If True, the optimizer will evaluate the points when calling maximize().
155- Otherwise it will evaluate it at the moment.
157+ If True, the optimizer will evaluate the points when calling
158+ maximize(). Otherwise it will evaluate it at the moment.
156159 """
157160 if lazy :
158161 self ._queue .add (params )
@@ -207,15 +210,18 @@ def maximize(self,
207210 xi = 0.0 ,
208211 ** gp_params ):
209212 """
210- Probes the target space to find the parameters that yield the maximum value for the given function.
213+ Probes the target space to find the parameters that yield the maximum
214+ value for the given function.
211215
212216 Parameters
213217 ----------
214218 init_points : int, optional(default=5)
215- Number of iterations before the explorations starts the exploration for the maximum.
219+ Number of iterations before the explorations starts the exploration
220+ for the maximum.
216221
217222 n_iter: int, optional(default=25)
218- Number of iterations where the method attempts to find the maximum value.
223+ Number of iterations where the method attempts to find the maximum
224+ value.
219225
220226 acq: {'ucb', 'ei', 'poi'}
221227 The acquisition method used.
@@ -226,13 +232,15 @@ def maximize(self,
226232 kappa: float, optional(default=2.576)
227233 Parameter to indicate how closed are the next parameters sampled.
228234 Higher value = favors spaces that are least explored.
229- Lower value = favors spaces where the regression function is the highest.
235+ Lower value = favors spaces where the regression function is the
236+ highest.
230237
231238 kappa_decay: float, optional(default=1)
232239 `kappa` is multiplied by this factor every iteration.
233240
234241 kappa_decay_delay: int, optional(default=0)
235- Number of iterations that must have passed before applying the decay to `kappa`.
242+ Number of iterations that must have passed before applying the decay
243+ to `kappa`.
236244
237245 xi: float, optional(default=0.0)
238246 [unused]
@@ -276,4 +284,5 @@ def set_bounds(self, new_bounds):
276284 self ._space .set_bounds (new_bounds )
277285
278286 def set_gp_params (self , ** params ):
287+ """Set parameters to the internal Gaussian Process Regressor"""
279288 self ._gp .set_params (** params )
0 commit comments