Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion bayes_opt/bayesian_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class BayesianOptimization(object):

def __init__(self, f, pbounds, random_state=None, verbose=1):
def __init__(self, f, pbounds, random_state=None, verbose=1, callbacks=None):
"""
:param f:
Function to be maximized.
Expand Down Expand Up @@ -71,6 +71,12 @@ def __init__(self, f, pbounds, random_state=None, verbose=1):
# Verbose
self.verbose = verbose

# Callback
if(callbacks is None):
self.callbacks = []
else:
self.callbacks = callbacks

def init(self, init_points):
"""
Initialization method to kick start the optimization process. It is a
Expand Down Expand Up @@ -104,6 +110,9 @@ def _observe_point(self, x):
y = self.space.observe_point(x)
if self.verbose:
self.plog.print_step(x, y)
# Callback
for c in self.callbacks:
c()
return y

def explore(self, points_dict, eager=False):
Expand Down