dflemin3 / approxposterior

A Python package for approximate Bayesian inference and optimization using Gaussian processes
https://dflemin3.github.io/approxposterior/
MIT License
41 stars 9 forks source link

Unnecessary creation of a new GP object in `findNextPoint` #72

Open syrte opened 3 years ago

syrte commented 3 years ago

Hi David, thanks for the nice package! It is really helpful!

I plan to apply your package to integer parameters, which might require playing some tricks on the kernel (e.g., adding a white noise). Here I have a question relating to the code at approx.py#L712-L716

self.gp = george.GP(kernel=self.gp.kernel, fit_mean=True,
                    mean=self.gp.mean,
                    white_noise=self.gp.white_noise,
                    fit_white_noise=False)
self.gp.set_parameter_vector(currentHype)

It creates a new GP object, however, it does not hold all the original properties in self.gp, e.g., fit_white_noise can be True in a user-supplied gp.

While we can check the status in gp.models["white_noise"].unfrozen_mask in principle, it seems the creation of a new GP object here is not necessary. Because the following line will update all the things we need (as far as I see)

self.gp.compute(self.theta)

If the above understanding is correct, it sounds reasonable to remove lines L712-L716. Am I right? Or I have missed something? Thanks!