mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-11 15:15:15 +02:00
format on save
This commit is contained in:
parent
6fcb9e48fd
commit
2568201d1b
1 changed files with 23 additions and 7 deletions
|
|
@ -7,13 +7,25 @@ import unittest
|
|||
import numpy as np
|
||||
import GPy
|
||||
|
||||
|
||||
class GridModelTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
######################################
|
||||
# # 3 dimensional example
|
||||
|
||||
# sample inputs and outputs
|
||||
self.X = np.array([[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]])
|
||||
self.X = np.array(
|
||||
[
|
||||
[0, 0, 0],
|
||||
[0, 0, 1],
|
||||
[0, 1, 0],
|
||||
[0, 1, 1],
|
||||
[1, 0, 0],
|
||||
[1, 0, 1],
|
||||
[1, 1, 0],
|
||||
[1, 1, 1],
|
||||
]
|
||||
)
|
||||
self.Y = np.random.randn(8, 1) * 100
|
||||
self.dim = self.X.shape[1]
|
||||
|
||||
|
|
@ -33,10 +45,15 @@ class GridModelTest(unittest.TestCase):
|
|||
kernel2 = GPy.kern.RBF(input_dim=self.dim, variance=1, ARD=True)
|
||||
m2 = GPy.models.GPRegression(self.X, self.Y, kernel2)
|
||||
|
||||
np.testing.assert_almost_equal(kernel.variance.gradient, kernel2.variance.gradient)
|
||||
np.testing.assert_almost_equal(kernel.lengthscale.gradient, kernel2.lengthscale.gradient)
|
||||
np.testing.assert_almost_equal(m.likelihood.variance.gradient, m2.likelihood.variance.gradient)
|
||||
|
||||
np.testing.assert_almost_equal(
|
||||
kernel.variance.gradient, kernel2.variance.gradient
|
||||
)
|
||||
np.testing.assert_almost_equal(
|
||||
kernel.lengthscale.gradient, kernel2.lengthscale.gradient
|
||||
)
|
||||
np.testing.assert_almost_equal(
|
||||
m.likelihood.variance.gradient, m2.likelihood.variance.gradient
|
||||
)
|
||||
|
||||
def test_prediction_match(self):
|
||||
kernel = GPy.kern.RBF(input_dim=self.dim, variance=1, ARD=True)
|
||||
|
|
@ -45,7 +62,6 @@ class GridModelTest(unittest.TestCase):
|
|||
kernel2 = GPy.kern.RBF(input_dim=self.dim, variance=1, ARD=True)
|
||||
m2 = GPy.models.GPRegression(self.X, self.Y, kernel2)
|
||||
|
||||
test = np.array([[0,0,2],[-1,3,-4]])
|
||||
test = np.array([[0, 0, 2], [-1, 3, -4]])
|
||||
|
||||
np.testing.assert_almost_equal(m.predict(test), m2.predict(test))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue