From cbcb3cb33757e835664aa6e746b236b5ce645ab4 Mon Sep 17 00:00:00 2001 From: Nicolo Fusi Date: Tue, 12 Mar 2013 14:01:32 +0000 Subject: [PATCH] better GPLVM oil flow demo --- GPy/examples/dimensionality_reduction.py | 6 ++++-- GPy/models/GPLVM.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/GPy/examples/dimensionality_reduction.py b/GPy/examples/dimensionality_reduction.py index 59f35c72..d7610acb 100644 --- a/GPy/examples/dimensionality_reduction.py +++ b/GPy/examples/dimensionality_reduction.py @@ -44,12 +44,14 @@ def GPLVM_oil_100(): data = GPy.util.datasets.oil_100() # create simple GP model - m = GPy.models.GPLVM(data['X'], 2) + kernel = GPy.kern.rbf(6, ARD = True) + GPy.kern.bias(6) + m = GPy.models.GPLVM(data['X'], 6, kernel = kernel) # optimize m.ensure_default_constraints() - m.optimize() + m.optimize(messages=1) # plot print(m) + m.plot_latent(labels=data['Y'].argmax(axis=1)) return m diff --git a/GPy/models/GPLVM.py b/GPy/models/GPLVM.py index 5be54049..32594594 100644 --- a/GPy/models/GPLVM.py +++ b/GPy/models/GPLVM.py @@ -66,6 +66,8 @@ class GPLVM(GP): :param resolution: the resolution of the grid on which to evaluate the predictive variance """ + util.plot.Tango.reset() + if labels is None: labels = np.ones(self.N) if which_indices is None: @@ -88,7 +90,7 @@ class GPLVM(GP): #first, plot the output variance as a function of the latent space Xtest, xx,yy,xmin,xmax = util.plot.x_frame2D(self.X[:,[input_1, input_2]],resolution=resolution) Xtest_full = np.zeros((Xtest.shape[0], self.X.shape[1])) - Xtest_full[:, :2] = Xtest + Xtest_full[:, :2] = Xtest mu, var, low, up = self.predict(Xtest_full) var = var[:, :2] pb.imshow(var.reshape(resolution,resolution).T[::-1,:],extent=[xmin[0],xmax[0],xmin[1],xmax[1]],cmap=pb.cm.binary,interpolation='bilinear')