mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-15 06:52:39 +02:00
Corrected v2 missing print brackets. Added test code for new model and util
This commit is contained in:
parent
132c8d92b2
commit
ea8b732181
3 changed files with 68 additions and 1 deletions
|
|
@ -405,6 +405,24 @@ class MiscTests(unittest.TestCase):
|
|||
warp_m.plot()
|
||||
warp_f.plot(X.min()-10, X.max()+10)
|
||||
plt.show()
|
||||
|
||||
def test_offset_regression(self):
|
||||
#Tests GPy.models.GPOffsetRegression. Using two small time series
|
||||
#from a sine wave, we confirm the algorithm determines that the
|
||||
#likelihood is maximised when the offset hyperparameter is approximately
|
||||
#equal to the actual offset in X between the two time series.
|
||||
offset = 3
|
||||
X1 = np.arange(0,50,5.0)[:,None]
|
||||
X2 = np.arange(0+offset,50+offset,5.0)[:,None]
|
||||
X = np.vstack([X1,X2])
|
||||
ind = np.vstack([np.zeros([10,1]),np.ones([10,1])])
|
||||
X = np.hstack([X,ind])
|
||||
Y = np.sin((X[0:10,0])/30.0)[:,None]
|
||||
Y = np.vstack([Y,Y])
|
||||
|
||||
m = GPy.models.GPOffsetRegression(X,Y)
|
||||
m.optimize()
|
||||
assert np.abs(m.offset[0]-offset)<0.1, "GPOffsetRegression model failing to estimate correct offset."
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue