I am using the scikit-learn Python library to perform Bayesian optimization (on top of Gaussian process regression) on a function which takes seven inputs. Four of these inputs represent physical angles, so the Gaussian kernel should be periodic in them; a natural choice is sklearn.gaussian_process.kernels.ExpSineSquared
. However, I do not want to arbitrarily force the function to be periodic in the other three.
According to The Kernel Cookbook, the proper way to do this is to simply multiply an ExpSineSquared
kernel over the periodic variables with an aperiodic kernel (say the Matérn kernel) over the others and obtain something like
ExpSineSquared(x[:3])*Matern(x[3:])
(where x
is the 7-vector of parameters). One would think that the Product
kernel implemented in sklearn.gaussian_process.kernels
would be the way to go, but as far as I can tell this would not allow me to choose which parameters are periodic and which are not; using the Product
kernel would effectively give me ExpSineSquared(x)*Matern(x)
.
Since I'm not very experienced with GPR in sklearn, what is the best way to implement my desired kernel?