mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-18 13:55:14 +02:00
[merge] devel and plotting tests from meanfunc
This commit is contained in:
commit
52567d7732
6 changed files with 44 additions and 4 deletions
Binary file not shown.
Binary file not shown.
|
|
@ -28,10 +28,49 @@ class MFtests(unittest.TestCase):
|
|||
A linear mean function with parameters that we'll learn alongside the kernel
|
||||
"""
|
||||
|
||||
X = np.linspace(-1,10,50).reshape(-1,1)
|
||||
|
||||
Y = 3-np.abs((X-6))
|
||||
Y += .5*np.cos(3*X) + 0.3*np.random.randn(*X.shape)
|
||||
|
||||
mf = GPy.mappings.PiecewiseLinear(1, 1, [-1,1], [9,2])
|
||||
|
||||
k =GPy.kern.RBF(1)
|
||||
lik = GPy.likelihoods.Gaussian()
|
||||
m = GPy.core.GP(X, Y, kernel=k, likelihood=lik, mean_function=mf)
|
||||
self.assertTrue(m.checkgrad())
|
||||
|
||||
def test_parametric_mean_function_composition(self):
|
||||
"""
|
||||
A linear mean function with parameters that we'll learn alongside the kernel
|
||||
"""
|
||||
|
||||
X = np.linspace(0,10,50).reshape(-1,1)
|
||||
Y = np.sin(X) + 0.5*np.cos(3*X) + 0.1*np.random.randn(*X.shape) + 3*X
|
||||
|
||||
mf = GPy.mappings.Linear(1,1)
|
||||
mf = GPy.mappings.Compound(GPy.mappings.Linear(1,1),
|
||||
GPy.mappings.Kernel(1, 1, np.random.normal(0,1,(1,1)),
|
||||
GPy.kern.RBF(1))
|
||||
)
|
||||
|
||||
k =GPy.kern.RBF(1)
|
||||
lik = GPy.likelihoods.Gaussian()
|
||||
m = GPy.core.GP(X, Y, kernel=k, likelihood=lik, mean_function=mf)
|
||||
self.assertTrue(m.checkgrad())
|
||||
|
||||
def test_parametric_mean_function_additive(self):
|
||||
"""
|
||||
A linear mean function with parameters that we'll learn alongside the kernel
|
||||
"""
|
||||
|
||||
X = np.linspace(0,10,50).reshape(-1,1)
|
||||
Y = np.sin(X) + 0.5*np.cos(3*X) + 0.1*np.random.randn(*X.shape) + 3*X
|
||||
|
||||
mf = GPy.mappings.Additive(GPy.mappings.Constant(1,1,3),
|
||||
GPy.mappings.Additive(GPy.mappings.MLP(1,1),
|
||||
GPy.mappings.Identity(1,1)
|
||||
)
|
||||
)
|
||||
|
||||
k =GPy.kern.RBF(1)
|
||||
lik = GPy.likelihoods.Gaussian()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue