Skip to content
Snippets Groups Projects
Commit 6a1f869e authored by Bas Nijholt's avatar Bas Nijholt
Browse files

SKOptLearner: create 'tell_pending' which deprecates 'tell(x, None)'

parent a8472d09
No related branches found
No related tags found
No related merge requests found
Pipeline #12183 failed
This commit is part of merge request !107. Comments created here will be created in the context of that merge request.
...@@ -27,11 +27,13 @@ class SKOptLearner(Optimizer, BaseLearner): ...@@ -27,11 +27,13 @@ class SKOptLearner(Optimizer, BaseLearner):
self.function = function self.function = function
super().__init__(**kwargs) super().__init__(**kwargs)
def tell(self, x, y, fit=True): def tell(self, x, y, fit=True):
if y is not None: super().tell([x], y, fit)
# 'skopt.Optimizer' takes care of points we
# have not got results for. def tell_pending(self, x):
super().tell([x], y, fit) # 'skopt.Optimizer' takes care of points we
# have not got results for.
pass
def remove_unfinished(self): def remove_unfinished(self):
pass pass
...@@ -46,7 +48,10 @@ class SKOptLearner(Optimizer, BaseLearner): ...@@ -46,7 +48,10 @@ class SKOptLearner(Optimizer, BaseLearner):
# estimator of loss, but it is the cheapest. # estimator of loss, but it is the cheapest.
return 1 - model.score(self.Xi, self.yi) return 1 - model.score(self.Xi, self.yi)
def ask(self, n, add_data=True): def ask(self, n, tell_pending=True):
if not tell_pending:
raise NotImplementedError('Asking points is an irreversible '
'action, so use `ask(n, tell_pending=True`.')
points = super().ask(n) points = super().ask(n)
# TODO: Choose a better estimate for the loss improvement. # TODO: Choose a better estimate for the loss improvement.
if self.space.n_dims > 1: if self.space.n_dims > 1:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment