mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-15 06:52:39 +02:00
coregionalisation changed to coregionalization
This commit is contained in:
parent
1bc9374717
commit
4bb2ea9606
9 changed files with 24 additions and 79 deletions
|
|
@ -9,9 +9,9 @@ import pylab as pb
|
|||
import numpy as np
|
||||
import GPy
|
||||
|
||||
def coregionalisation_toy2(max_iters=100):
|
||||
def coregionalization_toy2(max_iters=100):
|
||||
"""
|
||||
A simple demonstration of coregionalisation on two sinusoidal functions.
|
||||
A simple demonstration of coregionalization on two sinusoidal functions.
|
||||
"""
|
||||
X1 = np.random.rand(50, 1) * 8
|
||||
X2 = np.random.rand(30, 1) * 5
|
||||
|
|
@ -22,7 +22,7 @@ def coregionalisation_toy2(max_iters=100):
|
|||
Y = np.vstack((Y1, Y2))
|
||||
|
||||
k1 = GPy.kern.rbf(1) + GPy.kern.bias(1)
|
||||
k2 = GPy.kern.coregionalise(2,1)
|
||||
k2 = GPy.kern.coregionalize(2,1)
|
||||
k = k1**k2 #k = k1.prod(k2,tensor=True)
|
||||
m = GPy.models.GPRegression(X, Y, kernel=k)
|
||||
m.constrain_fixed('.*rbf_var', 1.)
|
||||
|
|
@ -40,9 +40,9 @@ def coregionalisation_toy2(max_iters=100):
|
|||
pb.plot(X2[:, 0], Y2[:, 0], 'gx', mew=2)
|
||||
return m
|
||||
|
||||
def coregionalisation_toy(max_iters=100):
|
||||
def coregionalization_toy(max_iters=100):
|
||||
"""
|
||||
A simple demonstration of coregionalisation on two sinusoidal functions.
|
||||
A simple demonstration of coregionalization on two sinusoidal functions.
|
||||
"""
|
||||
X1 = np.random.rand(50, 1) * 8
|
||||
X2 = np.random.rand(30, 1) * 5
|
||||
|
|
@ -63,9 +63,9 @@ def coregionalisation_toy(max_iters=100):
|
|||
axes[1].set_title('Output 1')
|
||||
return m
|
||||
|
||||
def coregionalisation_sparse(max_iters=100):
|
||||
def coregionalization_sparse(max_iters=100):
|
||||
"""
|
||||
A simple demonstration of coregionalisation on two sinusoidal functions using sparse approximations.
|
||||
A simple demonstration of coregionalization on two sinusoidal functions using sparse approximations.
|
||||
"""
|
||||
X1 = np.random.rand(500, 1) * 8
|
||||
X2 = np.random.rand(300, 1) * 5
|
||||
|
|
@ -76,19 +76,14 @@ def coregionalisation_sparse(max_iters=100):
|
|||
Y = np.vstack((Y1, Y2))
|
||||
|
||||
num_inducing = 40
|
||||
Z = np.hstack((np.random.rand(num_inducing, 1) * 8, np.random.randint(0, 2, num_inducing)[:, None]))
|
||||
Z = np.hstack((np.random.rand(num_inducing, 1) * 8, np.random.randint(0, 2, num_inducing)[:, None]))
|
||||
#Z = np.hstack((np.random.rand(num_inducing, 1) * 8, np.random.randint(0, 2, num_inducing)[:, None]))
|
||||
|
||||
k1 = GPy.kern.rbf(1)
|
||||
|
||||
m = GPy.models.SparseGPMultioutputRegression(X_list=[X1,X2],Y_list=[Y1,Y2],kernel_list=[k1],num_inducing=20)
|
||||
#k2 = GPy.kern.coregionalise(2, 2)
|
||||
#k = k1**k2 #.prod(k2, tensor=True) # + GPy.kern.white(2,0.001)
|
||||
#m = GPy.models.SparseGPRegression(X, Y, kernel=k, Z=Z)
|
||||
m.constrain_fixed('.*rbf_var', 1.)
|
||||
|
||||
#m.constrain_fixed('iip')
|
||||
#m.constrain_bounded('noise_variance', 1e-3, 1e-1)
|
||||
m.constrain_bounded('noise_variance', 1e-3, 1e-1)
|
||||
# m.optimize_restarts(5, robust=True, messages=1, max_iters=max_iters, optimizer='bfgs')
|
||||
m.optimize(max_iters=max_iters)
|
||||
|
||||
|
|
@ -97,19 +92,6 @@ def coregionalisation_sparse(max_iters=100):
|
|||
m.plot(output=1,ax=axes[1])
|
||||
axes[0].set_title('Output 0')
|
||||
axes[1].set_title('Output 1')
|
||||
# plotting:
|
||||
#pb.figure()
|
||||
#Xtest1 = np.hstack((np.linspace(0, 9, 100)[:, None], np.zeros((100, 1))))
|
||||
#Xtest2 = np.hstack((np.linspace(0, 9, 100)[:, None], np.ones((100, 1))))
|
||||
#mean, var, low, up = m.predict(Xtest1)
|
||||
#GPy.util.plot.gpplot(Xtest1[:, 0], mean, low, up)
|
||||
#mean, var, low, up = m.predict(Xtest2)
|
||||
#GPy.util.plot.gpplot(Xtest2[:, 0], mean, low, up)
|
||||
#pb.plot(X1[:, 0], Y1[:, 0], 'rx', mew=2)
|
||||
#pb.plot(X2[:, 0], Y2[:, 0], 'gx', mew=2)
|
||||
#y = pb.ylim()[0]
|
||||
#pb.plot(Z[:, 0][Z[:, 1] == 0], np.zeros(np.sum(Z[:, 1] == 0)) + y, 'r|', mew=2)
|
||||
#pb.plot(Z[:, 0][Z[:, 1] == 1], np.zeros(np.sum(Z[:, 1] == 1)) + y, 'g|', mew=2)
|
||||
return m
|
||||
|
||||
def epomeo_gpx(max_iters=100):
|
||||
|
|
@ -135,8 +117,8 @@ def epomeo_gpx(max_iters=100):
|
|||
np.random.randint(0, 4, num_inducing)[:, None]))
|
||||
|
||||
k1 = GPy.kern.rbf(1)
|
||||
k2 = GPy.kern.coregionalise(output_dim=5, rank=5)
|
||||
k = k1**k2
|
||||
k2 = GPy.kern.coregionalize(output_dim=5, rank=5)
|
||||
k = k1**k2
|
||||
|
||||
m = GPy.models.SparseGPRegression(t, Y, kernel=k, Z=Z, normalize_Y=True)
|
||||
m.constrain_fixed('.*rbf_var', 1.)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue