josejimenezluna / pyGPGO

Bayesian optimization for Python
http://pygpgo.readthedocs.io
MIT License
241 stars 61 forks source link

Missing hyperparameter in matern52 #17

Closed Anders-Sjoberg closed 5 years ago

Anders-Sjoberg commented 5 years ago

Hi Hawk31,

I have notice that norm r in matern52 is not divided by the length-scale l (hyperparameter) everywhere. This result in that the kernel is not always positive definite (when l is less than 1), which in turn results in that the Cholesky decomposition crashes. Here is an example where this happen:

from pyGPGO.covfunc import matern52
from pyGPGO.surrogates.GaussianProcess import GaussianProcess
import numpy as np

np.random.seed(0)
X = np.random.uniform((10, 10), size = (10,2))
y = y = np.random.uniform(10, size = (10))
matern_52 = matern52(l = 0.5)
gp = GaussianProcess(matern_52)
gp.fit(X,y)

I have made an update of matern52 and I have included an extra test that check if the eigenvalues are greater than zero for different generated kernels and with different data (and thereby it is positive definite). However, the test does not include kernel expSine because that kernel usually crashes. I am not even sure that expSine is a positive definite function(?).

Best Regards, Saizor

josejimenezluna commented 5 years ago

Thank you for the PR @Saizor . It's already been merged