Skip to content

Commit 20b46ab

Browse files
author
brendan
committed
fixes #382
1 parent 17dfc06 commit 20b46ab

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

bayes_opt/bayesian_optimization.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,8 @@ def _prime_subscriptions(self):
246246
def maximize(self,
247247
init_points=5,
248248
n_iter=25,
249-
acq='ucb',
250-
kappa=2.576,
251-
kappa_decay=1,
252-
kappa_decay_delay=0,
253-
xi=0.0,
254-
**gp_params):
249+
utility_function=None):
250+
255251
"""
256252
Probes the target space to find the parameters that yield the maximum
257253
value for the given function.
@@ -291,13 +287,16 @@ def maximize(self,
291287
self._prime_subscriptions()
292288
self.dispatch(Events.OPTIMIZATION_START)
293289
self._prime_queue(init_points)
294-
self.set_gp_params(**gp_params)
295290

296-
util = UtilityFunction(kind=acq,
297-
kappa=kappa,
298-
xi=xi,
299-
kappa_decay=kappa_decay,
300-
kappa_decay_delay=kappa_decay_delay)
291+
if utility_function is None:
292+
util = UtilityFunction(kind='ucb',
293+
kappa=2.576,
294+
xi=0.0,
295+
kappa_decay=1,
296+
kappa_decay_delay=0)
297+
else:
298+
util = utility_function
299+
301300
iteration = 0
302301
while not self._queue.empty or iteration < n_iter:
303302
try:

examples/test.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ def black_box_function(x, y):
2727

2828
optimizer.maximize(init_points=2,
2929
n_iter=25,
30-
acq='ucb',
31-
kappa=5,
32-
xi=1,
33-
**{'normalize_y':True, 'alpha':2.5e-3, 'n_restarts_optimizer':20})
30+
utility_function=utility)
3431
# for point in range(20):
3532
# next_point_to_probe = optimizer.suggest(utility)
3633
# NextPointValues = np.array(list(next_point_to_probe.values()))

0 commit comments

Comments
 (0)