Skip to content

Commit

Permalink
The tell method of the optimizer allows replacing the data now
Browse files Browse the repository at this point in the history
This retains the last position of the sampler, and thus improves the initialization of the next fit.
This fixes issue #11.
  • Loading branch information
kiudee committed Jan 24, 2020
1 parent f59bb81 commit 9aa4972
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bask/optimizer.py
Expand Up @@ -75,8 +75,11 @@ def ask(self):
raise RuntimeError("Initialization is finished, but no model has been fit.")
return self._next_x

def tell(self, x, y, fit=True, n_samples=5, gp_samples=100, gp_burnin=10, progress=False):
def tell(self, x, y, fit=True, replace=False, n_samples=5, gp_samples=100, gp_burnin=10, progress=False):
# if y isn't a scalar it means we have been handed a batch of points
if replace:
self.Xi = []
self.yi = []
if is_listlike(y) and is_2Dlistlike(x):
self.Xi.extend(x)
self.yi.extend(y)
Expand All @@ -91,7 +94,7 @@ def tell(self, x, y, fit=True, n_samples=5, gp_samples=100, gp_burnin=10, progre
if fit and self._n_initial_points <= 0:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
if self.gp.pos_ is None:
if self.gp.pos_ is None or replace:
self.gp.fit(
self.space.transform(self.Xi),
self.yi,
Expand Down

0 comments on commit 9aa4972

Please sign in to comment.