baysian gplvm and example changes

This commit is contained in:
Max Zwiessele 2013-04-24 16:38:40 +01:00
parent f8c3cd669d
commit 992a35b614
2 changed files with 100 additions and 88 deletions

View file

@ -13,7 +13,6 @@ import priors
from ..util.linalg import jitchol from ..util.linalg import jitchol
from ..inference import optimization from ..inference import optimization
from .. import likelihoods from .. import likelihoods
import re
class model(parameterised): class model(parameterised):
def __init__(self): def __init__(self):
@ -215,7 +214,7 @@ class model(parameterised):
for s in positive_strings: for s in positive_strings:
for i in self.grep_param_names(s): for i in self.grep_param_names(s):
if not (i in currently_constrained): if not (i in currently_constrained):
to_make_positive.append(re.escape(param_names[i])) to_make_positive.append(param_names[i])
if warn: if warn:
print "Warning! constraining %s postive"%name print "Warning! constraining %s postive"%name
if len(to_make_positive): if len(to_make_positive):

View file

@ -161,13 +161,26 @@ class Bayesian_GPLVM(sparse_GP, GPLVM):
ax.plot(self.Z[:, input_1], self.Z[:, input_2], '^w') ax.plot(self.Z[:, input_1], self.Z[:, input_2], '^w')
return ax return ax
def plot_X_1d(self, fig_num="MRD X 1d", axes=None, colors=None): def plot_X_1d(self, fig=None, axes=None, fig_num="MRD X 1d", colors=None):
import pylab """
Plot latent space X in 1D:
fig = pylab.figure(num=fig_num, figsize=(min(8, (3 * len(self.bgplvms))), min(12, (2 * self.X.shape[1])))) -if fig is given, create Q subplots in fig and plot in these
-if axes is given plot Q 1D latent space plots of X into each `axis`
-if neither fig nor axes is given create a figure with fig_num and plot in there
colors:
colors of different latent space dimensions Q
"""
import pylab
if fig is None and axes is None:
fig = pylab.figure(num=fig_num, figsize=(8, min(12, (2 * self.X.shape[1]))))
if colors is None: if colors is None:
colors = pylab.gca()._get_lines.color_cycle colors = pylab.gca()._get_lines.color_cycle
pylab.clf() pylab.clf()
else:
colors = iter(colors)
plots = [] plots = []
for i in range(self.X.shape[1]): for i in range(self.X.shape[1]):
if axes is None: if axes is None: