mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-13 22:12:38 +02:00
Fixed prior error
This commit is contained in:
parent
63c2321469
commit
4160a7b4d8
2 changed files with 67 additions and 2 deletions
|
|
@ -45,6 +45,69 @@ class PriorTests(unittest.TestCase):
|
|||
# should raise an assertionerror.
|
||||
self.assertRaises(AssertionError, m.rbf.set_prior, gaussian)
|
||||
|
||||
def test_set_prior(self):
|
||||
xmin, xmax = 1, 2.5*np.pi
|
||||
b, C, SNR = 1, 0, 0.1
|
||||
X = np.linspace(xmin, xmax, 500)
|
||||
y = b*X + C + 1*np.sin(X)
|
||||
y += 0.05*np.random.randn(len(X))
|
||||
X, y = X[:, None], y[:, None]
|
||||
m = GPy.models.GPRegression(X, y)
|
||||
|
||||
gaussian = GPy.priors.Gaussian(1, 1)
|
||||
#m.rbf.set_prior(gaussian)
|
||||
# setting a Gaussian prior on non-negative parameters
|
||||
# should raise an assertionerror.
|
||||
self.assertRaises(AssertionError, m.rbf.set_prior, gaussian)
|
||||
|
||||
def test_set_gaussian_for_reals(self):
|
||||
xmin, xmax = 1, 2.5*np.pi
|
||||
b, C, SNR = 1, 0, 0.1
|
||||
X = np.linspace(xmin, xmax, 500)
|
||||
y = b*X + C + 1*np.sin(X)
|
||||
y += 0.05*np.random.randn(len(X))
|
||||
X, y = X[:, None], y[:, None]
|
||||
m = GPy.models.SparseGPRegression(X, y)
|
||||
|
||||
gaussian = GPy.priors.Gaussian(1, 1)
|
||||
m.Z.set_prior(gaussian)
|
||||
# setting a Gaussian prior on non-negative parameters
|
||||
# should raise an assertionerror.
|
||||
#self.assertRaises(AssertionError, m.Z.set_prior, gaussian)
|
||||
|
||||
|
||||
|
||||
def test_fixed_domain_check(self):
|
||||
xmin, xmax = 1, 2.5*np.pi
|
||||
b, C, SNR = 1, 0, 0.1
|
||||
X = np.linspace(xmin, xmax, 500)
|
||||
y = b*X + C + 1*np.sin(X)
|
||||
y += 0.05*np.random.randn(len(X))
|
||||
X, y = X[:, None], y[:, None]
|
||||
m = GPy.models.GPRegression(X, y)
|
||||
|
||||
m.rbf.fix()
|
||||
gaussian = GPy.priors.Gaussian(1, 1)
|
||||
# setting a Gaussian prior on non-negative parameters
|
||||
# should raise an assertionerror.
|
||||
self.assertRaises(AssertionError, m.rbf.set_prior, gaussian)
|
||||
|
||||
def test_fixed_domain_check1(self):
|
||||
xmin, xmax = 1, 2.5*np.pi
|
||||
b, C, SNR = 1, 0, 0.1
|
||||
X = np.linspace(xmin, xmax, 500)
|
||||
y = b*X + C + 1*np.sin(X)
|
||||
y += 0.05*np.random.randn(len(X))
|
||||
X, y = X[:, None], y[:, None]
|
||||
m = GPy.models.GPRegression(X, y)
|
||||
|
||||
m.kern.lengthscale.fix()
|
||||
gaussian = GPy.priors.Gaussian(1, 1)
|
||||
# setting a Gaussian prior on non-negative parameters
|
||||
# should raise an assertionerror.
|
||||
self.assertRaises(AssertionError, m.rbf.set_prior, gaussian)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print "Running unit tests, please be (very) patient..."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue