plotting debug

This commit is contained in:
Max Zwiessele 2013-04-15 15:58:33 +01:00
parent c63beddcf0
commit 37f94310d5
3 changed files with 30 additions and 3 deletions

View file

@ -52,12 +52,14 @@ class kern(parameterised):
parameterised.__init__(self) parameterised.__init__(self)
def plot_ARD(self, ax=pb.gca()): def plot_ARD(self, ax=None):
""" """
If an ARD kernel is present, it bar-plots the ARD parameters If an ARD kernel is present, it bar-plots the ARD parameters
""" """
if ax is None:
ax = pb.gca()
for p in self.parts: for p in self.parts:
if hasattr(p, 'ARD') and p.ARD: if hasattr(p, 'ARD') and p.ARD:
ax.set_title('ARD parameters, %s kernel' % p.name) ax.set_title('ARD parameters, %s kernel' % p.name)

View file

@ -60,12 +60,13 @@ class GPLVM(GP):
mu, var, upper, lower = self.predict(Xnew) mu, var, upper, lower = self.predict(Xnew)
pb.plot(mu[:,0], mu[:,1],'k',linewidth=1.5) pb.plot(mu[:,0], mu[:,1],'k',linewidth=1.5)
def plot_latent(self, labels=None, which_indices=None, resolution=50, ax=pb.gca()): def plot_latent(self, labels=None, which_indices=None, resolution=50, ax=None):
""" """
:param labels: a np.array of size self.N containing labels for the points (can be number, strings, etc) :param labels: a np.array of size self.N containing labels for the points (can be number, strings, etc)
:param resolution: the resolution of the grid on which to evaluate the predictive variance :param resolution: the resolution of the grid on which to evaluate the predictive variance
""" """
if ax is None:
ax = pb.gca()
util.plot.Tango.reset() util.plot.Tango.reset()
if labels is None: if labels is None:

View file

@ -225,6 +225,29 @@ class MRD(model):
self.X = X self.X = X
return X return X
def plot_X_1d(self, colors=None):
if colors is None:
colors = pylab.gca()._get_lines.color_cycle
fig = pylab.figure(num="MRD X 1d", figsize=(4 * len(self.bgplvms), (2 * self.X.shape[1])))
fig.clf()
ax1 = fig.add_subplot(self.X.shape[1], 1, 1)
ax1.plot(self.X, c='k', alpha=.3)
plots = ax1.plot(self.X.T[0], c=colors.next())
for i in range(self.X.shape[1] - 1):
ax = fig.add_subplot(self.X.shape[1], 1, i + 2)
ax.plot(self.X, c='k', alpha=.3)
plots.extend(ax.plot(self.X.T[i + 1], c=colors.next()))
if i < self.X.shape[1] - 2:
ax.set_xticklabels('')
ax1.set_xticklabels('')
ax1.legend(plots, [r"$\mathbf{{X_{}}}$".format(i + 1) for i in range(self.X.shape[1])],
bbox_to_anchor=(0., 1 + .01 * self.X.shape[1],
1., 1. + .01 * self.X.shape[1]), loc=3,
ncol=self.X.shape[1], mode="expand", borderaxespad=0.)
pylab.draw()
fig.tight_layout(h_pad=.01, rect=(0, 0, 1, .95))
return fig
def plot_X(self): def plot_X(self):
fig = pylab.figure("MRD X", figsize=(4 * len(self.bgplvms), 3)) fig = pylab.figure("MRD X", figsize=(4 * len(self.bgplvms), 3))
fig.clf() fig.clf()
@ -267,6 +290,7 @@ class MRD(model):
def _debug_plot(self): def _debug_plot(self):
self.plot_X() self.plot_X()
self.plot_X_1d()
self.plot_latent() self.plot_latent()
self.plot_scales() self.plot_scales()