Closed jorisparet closed 2 months ago
Hi @jorisparet,
fitting the GP is expensive. If you don't continue with the optimization then fitting the GP is not necessary -- unless you manually use it the way you do (but the maximize
loop can't know that). Hence, the GP is only fitted before the suggest
step and it will always miss the last point.
You can aways fit manually instead.
Hope that helps
Hi @till-m,
OK, I understand the idea. Although, if the optimizer prints out the last evaluated value of the target function during the maximize
loop, I would (naively) expect it to be taken into account in the GP as well, since one may want to use the GP as a surrogate in addition to only finding the maximum of the target function.
Again, I'm new to the package, so perhaps my view is a bit different from someone more familiar with Bayesian optimization, but it might be useful to mention it at least in the docs that maximize
does not automatically fit the last point.
I'll let you close the issue, in case you think an action is needed (e.g. add a comment in the docs) or not.
Thanks for your help and the quick reply. 🙂
Hey @jorisparet,
IIRC this is not the first time some confusion has been caused by the last point being unfitted. I think you have a good point in that comment in the documentation would be helpful. I'll leave this issue open for now to track that.
Hello,
I am quite new to the package, so it is likely that I am missing something obvious (my sincerest apologies if this is the case). I have not been able to find an explanation for what I observed, though, so it is probably better to bring it up just in case.
The bug The Gaussian Process regressor in
optimizer._gp
does not fit all the points sampled by theoptimizer.maximize
method. The last point seems to be left out.Reproduction I basically ran an example adapted from the documentation (before the recent acquisition function API redesign in #447). Here is the code I used:
Expected behavior The predicted mean from the GP should pass through all the points in
x_obs
. The point at $x=5.199$ is not taken into account by the GP. Note that this is the last one sampled fromoptimizer.minimize
. I tried with different values ofrandom_state
andn_iter
and it seems to be systematic.Screenshot
Environment (please complete the following information):
python
version 3.10.9numpy
version 1.26.4scipy
version 1.14.0bayesian-optimization
version 1.5.1Thank you for your help, cheers.