[param_to_array] deprecated and removed param_to_array from code, use param.values instead

This commit is contained in:
Max Zwiessele 2014-10-06 08:59:24 +01:00
parent c1d998e272
commit 6a260409fa
16 changed files with 349 additions and 231 deletions

View file

@ -1,7 +1,6 @@
import numpy as np
from latent_space_visualizations.controllers.imshow_controller import ImshowController,ImAnnotateController
from ...util.misc import param_to_array
from ...core.parameterization.variational import VariationalPosterior
from .base_plots import x_frame2D
import itertools
@ -55,9 +54,9 @@ def plot_latent(model, labels=None, which_indices=None,
#fethch the data points X that we'd like to plot
X = model.X
if isinstance(X, VariationalPosterior):
X = param_to_array(X.mean)
X = X.mean
else:
X = param_to_array(X)
X = X
if X.shape[0] > 1000:
@ -175,7 +174,7 @@ def plot_latent(model, labels=None, which_indices=None,
ax.set_aspect('auto') # set a nice aspect ratio
if plot_inducing:
Z = param_to_array(model.Z)
Z = model.Z
ax.plot(Z[:, input_1], Z[:, input_2], '^w')
ax.set_xlim((xmin, xmax))

View file

@ -35,8 +35,7 @@ def add_bar_labels(fig, ax, bars, bottom=0):
def plot_bars(fig, ax, x, ard_params, color, name, bottom=0):
from ...util.misc import param_to_array
return ax.bar(left=x, height=param_to_array(ard_params), width=.8,
return ax.bar(left=x, height=ard_params.view(np.ndarray), width=.8,
bottom=bottom, align='center',
color=color, edgecolor='k', linewidth=1.2,
label=name.replace("_"," "))

View file

@ -8,7 +8,6 @@ except:
pass
import numpy as np
from base_plots import gpplot, x_frame1D, x_frame2D
from ...util.misc import param_to_array
from ...models.gp_coregionalized_regression import GPCoregionalizedRegression
from ...models.sparse_gp_coregionalized_regression import SparseGPCoregionalizedRegression
from scipy import sparse
@ -67,7 +66,6 @@ def plot_fit(model, plot_limits=None, which_data_rows='all',
X_variance = model.X.variance
else:
X = model.X
#X, Y = param_to_array(X, model.Y)
Y = model.Y
if sparse.issparse(Y): Y = Y.todense().view(np.ndarray)

View file

@ -1,5 +1,4 @@
import pylab as pb, numpy as np
from ...util.misc import param_to_array
def plot(parameterized, fignum=None, ax=None, colors=None):
"""
@ -21,7 +20,7 @@ def plot(parameterized, fignum=None, ax=None, colors=None):
else:
colors = iter(colors)
plots = []
means, variances = param_to_array(parameterized.mean, parameterized.variance)
means, variances = parameterized.mean, parameterized.variance
x = np.arange(means.shape[0])
for i in range(means.shape[1]):
if ax is None:
@ -68,7 +67,7 @@ def plot_SpikeSlab(parameterized, fignum=None, ax=None, colors=None, side_by_sid
else:
colors = iter(colors)
plots = []
means, variances, gamma = param_to_array(parameterized.mean, parameterized.variance, parameterized.binary_prob)
means, variances, gamma = parameterized.mean, parameterized.variance, parameterized.binary_prob
x = np.arange(means.shape[0])
for i in range(means.shape[1]):
if side_by_side:
@ -77,7 +76,7 @@ def plot_SpikeSlab(parameterized, fignum=None, ax=None, colors=None, side_by_sid
else:
sub1 = (means.shape[1]*2,1,2*i+1)
sub2 = (means.shape[1]*2,1,2*i+2)
# mean and variance plot
a = fig.add_subplot(*sub1)
a.plot(means, c='k', alpha=.3)

View file

@ -4,7 +4,6 @@ import GPy
import numpy as np
import matplotlib as mpl
import time
from ...util.misc import param_to_array
from GPy.core.parameterization.variational import VariationalPosterior
try:
import visual
@ -127,7 +126,7 @@ class lvm(matplotlib_show):
self.latent_index = latent_index
self.latent_dim = model.input_dim
self.disable_drag = disable_drag
# The red cross which shows current latent point.
self.latent_values = vals
self.latent_handle = self.latent_axes.plot([0],[0],'rx',mew=2)[0]
@ -474,7 +473,7 @@ class mocap_data_show(matplotlib_show):
self.axes.set_ylim(self.y_lim)
self.axes.set_zlim(self.z_lim)
self.axes.auto_scale_xyz([-1., 1.], [-1., 1.], [-1., 1.])
# self.axes.set_aspect('equal')
# self.axes.autoscale(enable=False)
@ -500,7 +499,7 @@ class skeleton_show(mocap_data_show):
:param vals: set of modeled angles to use for printing in the axis when it's first created.
:type vals: np.array
:param skel: skeleton object that has the parameters of the motion capture skeleton associated with it.
:type skel: mocap.skeleton object
:type skel: mocap.skeleton object
:param padding:
:type int
"""
@ -512,7 +511,7 @@ class skeleton_show(mocap_data_show):
"""Takes a set of angles and converts them to the x,y,z coordinates in the internal prepresentation of the class, ready for plotting.
:param vals: the values that are being modelled."""
if self.padding>0:
channels = np.zeros((self.vals.shape[0], self.vals.shape[1]+self.padding))
channels[:, 0:self.vals.shape[0]] = self.vals
@ -524,7 +523,7 @@ class skeleton_show(mocap_data_show):
self.vals[:, 0] = vals_mat[:, 0].copy()
self.vals[:, 1] = vals_mat[:, 2].copy()
self.vals[:, 2] = vals_mat[:, 1].copy()
def wrap_around(self, lim, connect):
quot = lim[1] - lim[0]
self.vals = rem(self.vals, quot)+lim[0]
@ -546,7 +545,7 @@ def data_play(Y, visualizer, frame_rate=30):
Example usage:
This example loads in the CMU mocap database (http://mocap.cs.cmu.edu) subject number 35 motion number 01. It then plays it using the mocap_show visualize object.
.. code-block:: python
data = GPy.util.datasets.cmu_mocap(subject='35', train_motions=['01'])
@ -556,7 +555,7 @@ def data_play(Y, visualizer, frame_rate=30):
GPy.util.visualize.data_play(Y, visualize)
"""
for y in Y:
visualizer.modify(y[None, :])