SheffieldML / GPyOpt

Gaussian Process Optimization using GPy
BSD 3-Clause "New" or "Revised" License
928 stars 261 forks source link

Matern kernel #59

Closed ghost closed 7 years ago

ghost commented 7 years ago

I understand that "kernel" will become deprecated in the new version. How can one specify the Gpy Matern ARD 5/2 kernel with the newest API?

GPyOpt.methods.bayesian_optimization.BayesianOptimization(f, domain=None, constrains=None, cost_withGradients=None, model_type='GP', X=None, Y=None, initial_design_numdata=None, initial_design_type='random', acquisition_type='EI', normalize_Y=True, exact_feval=False, acquisition_optimizer_type='lbfgs', model_update_interval=1, evaluator_type='sequential', batch_size=1, num_cores=1, verbosity=True, verbosity_model=False, bounds=None, **kwargs)

javiergonzalezh commented 7 years ago

Hi, You can either pass it in the **kwargs or once you have created the BayesOpt object you can access the kernel in the model and change it.

Hope it helps!

Javier

alansaul commented 7 years ago

Just to chime in here, you need to be a little careful when changing a kernel in a GPy model, although m_BO.model.kern = something_else will make it use the new kernel, the model will still see the old kernel.

I just made a tiny gist to illustrate this and how I would go about it to skirt this problem: https://gist.github.com/alansaul/b1135805681efc35d2c94a32c6850acf

It would be easy to make a wrapper to do something like m_BO.change_kernel(new_kernel) or something if you wish to do this often. It would probably make more sense to do this in GPy though.

Cheers,

Alan

javiergonzalezh commented 7 years ago

Thanks Alan for mentioning that. It is a very good point.

Javier

On 18 November 2016 at 11:00, Alan Saul notifications@github.com wrote:

Just to chime in here, you need to be a little careful when changing a kernel in a GPy model, although m_BO.model.kern = something_else will make it use the new kernel, the model will still see the old kernel.

I just made a tiny gist to illustrate this and how I would go about it to skirt this problem: https://gist.github.com/alansaul/b1135805681efc35d2c94a32c6850acf

It would be easy to make a wrapper to do something like m_BO.change_kernel(new_kernel) or something if you wish to do this often. It would probably make more sense to do this in GPy though.

Cheers,

Alan

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SheffieldML/GPyOpt/issues/59#issuecomment-261505429, or mute the thread https://github.com/notifications/unsubscribe-auth/AGiS8xCtYEgE8vf6wqdcLZfQqtIq4FIlks5q_YU0gaJpZM4K2C2U .

ghost commented 7 years ago

Thanks a lot. Is there a reason the kernel arg will become deprecated in the next version?

javiergonzalezh commented 7 years ago

We aimed to have a Bayesian Optimization class that is model agnostic: you can (only) select the model and pass its parameters in the **kargs. However, as GPs are the most standard model for BO and some other people raised this question it may be interesting making an exception in this case.

Javier

On 18 November 2016 at 14:17, ab07 notifications@github.com wrote:

Thanks a lot. Is there a reason the kernel arg will become deprecated in the next version?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SheffieldML/GPyOpt/issues/59#issuecomment-261541623, or mute the thread https://github.com/notifications/unsubscribe-auth/AGiS80B5o6fbykS4IrPZj8oozCzrn2L8ks5q_bNggaJpZM4K2C2U .

ghost commented 7 years ago

Sorry I'm a little confused -- does modifying the kernel in the current version via m = GPyOpt.methods.BayesianOptimization(f, domain, acquisition, model_type="GP", acquisition_type, kernel=GPy.kern.Matern52(input_dim) get ignored and default to the rbf kernel, or is this different to changing m.kern = GPy.kern.Matern52(input_dim)? Thanks so much for your help.

javiergonzalezh commented 7 years ago

Passing a new kernel when when instantiating the class will work because the model is created using the kernel you are passing. If you try to modify it later you need to do what @alansaul was mentioning in his post.

Javier

ghost commented 7 years ago

Thanks so much. And thank you for your work on this package.