mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-21 14:05:14 +02:00
first trivial model touches
This commit is contained in:
parent
eb1d8f211f
commit
4953d71b7a
3 changed files with 56 additions and 22 deletions
|
|
@ -6,6 +6,7 @@ import pylab as pb
|
|||
from matplotlib import pyplot as plt
|
||||
|
||||
import GPy
|
||||
from GPy.models.mrd import MRD
|
||||
|
||||
default_seed = np.random.seed(123344)
|
||||
|
||||
|
|
@ -99,6 +100,36 @@ def oil_100():
|
|||
# m.plot_latent(labels=data['Y'].argmax(axis=1))
|
||||
return m
|
||||
|
||||
def mrd_simulation():
|
||||
num = 2
|
||||
ard1 = np.array([1., 1, 0, 0], dtype=float)
|
||||
ard2 = np.array([0., 1, 1, 0], dtype=float)
|
||||
ard1[ard1 == 0] = 1E+10
|
||||
ard2[ard2 == 0] = 1E+10
|
||||
|
||||
make_params = lambda ard: np.hstack([[1], ard, [1, .3]])
|
||||
|
||||
D1, D2, N, M, Q = 50, 100, 150, 15, 4
|
||||
X = np.random.randn(N, Q)
|
||||
|
||||
k = GPy.kern.rbf(Q, ARD=True, lengthscale=ard1) + GPy.kern.bias(Q, 1) + GPy.kern.white(Q, 0.0001)
|
||||
Y1 = np.random.multivariate_normal(np.zeros(N), k.K(X), D1).T
|
||||
Y1 -= Y1.mean(0)
|
||||
|
||||
k = GPy.kern.rbf(Q, ARD=True, lengthscale=ard2) + GPy.kern.bias(Q, 1) + GPy.kern.white(Q, 0.0001)
|
||||
Y2 = np.random.multivariate_normal(np.zeros(N), k.K(X), D2).T
|
||||
Y2 -= Y2.mean(0)
|
||||
|
||||
k = GPy.kern.rbf(Q, ARD=True) + GPy.kern.bias(Q) + GPy.kern.white(Q, 1.0)
|
||||
|
||||
m = MRD(Y1, Y2, Q=Q, M=M, kernel=k, _debug=False)
|
||||
m.ensure_default_constraints()
|
||||
|
||||
m.optimize(messages=1, max_f_eval=5000)
|
||||
|
||||
import ipdb;ipdb.set_trace()
|
||||
return m
|
||||
|
||||
def brendan_faces():
|
||||
data = GPy.util.datasets.brendan_faces()
|
||||
Y = data['Y'][0:-1:10, :]
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class GPLVM(GP):
|
|||
|
||||
def plot(self):
|
||||
assert self.likelihood.Y.shape[1]==2
|
||||
pb.scatter(self.likelihood.Y[:,0],self.likelihood.Y[:,1],40,self.X[:,0].copy(),linewidth=0,cmap=pb.cm.jet)
|
||||
pb.scatter(self.likelihood.Y[:,0],self.likelihood.Y[:,1],40,self.X[:,0].copy(),linewidth=0,cmap=pb.cm.jet) # @UndefinedVariable
|
||||
Xnew = np.linspace(self.X.min(),self.X.max(),200)[:,None]
|
||||
mu, var, upper, lower = self.predict(Xnew)
|
||||
pb.plot(mu[:,0], mu[:,1],'k',linewidth=1.5)
|
||||
|
|
@ -90,7 +90,7 @@ class GPLVM(GP):
|
|||
Xtest_full[:, :2] = Xtest
|
||||
mu, var, low, up = self.predict(Xtest_full)
|
||||
var = var.mean(axis=1) # this was var[:, :2] edit by Neil
|
||||
pb.imshow(var.reshape(resolution,resolution).T[::-1,:],extent=[xmin[0],xmax[0],xmin[1],xmax[1]],cmap=pb.cm.binary,interpolation='bilinear')
|
||||
pb.imshow(var.reshape(resolution,resolution).T[::-1,:],extent=[xmin[0],xmax[0],xmin[1],xmax[1]],cmap=pb.cm.binary,interpolation='bilinear') # @UndefinedVariable
|
||||
|
||||
|
||||
for i,ul in enumerate(np.unique(labels)):
|
||||
|
|
|
|||
|
|
@ -11,4 +11,7 @@ from warped_GP import warpedGP
|
|||
from sparse_GPLVM import sparse_GPLVM
|
||||
from uncollapsed_sparse_GP import uncollapsed_sparse_GP
|
||||
from Bayesian_GPLVM import Bayesian_GPLVM
|
||||
import mrd
|
||||
MRD = mrd.MRD
|
||||
del mrd
|
||||
from generalized_FITC import generalized_FITC
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue