[magnification] mostly plotting and some model corrections for _predictive_variable

This commit is contained in:
Max Zwiessele 2015-09-02 15:46:40 +01:00
parent 26bdcfa82e
commit ca60ad3195
7 changed files with 54 additions and 33 deletions

View file

@ -405,9 +405,10 @@ class GP(Model):
for each point N in Xnew
"""
from ..util.linalg import jitchol
G = self.predict_wishard_embedding(Xnew, kern)
return np.array([2*np.sqrt(np.exp(np.sum(np.log(np.diag(jitchol(G[n, :, :])))))) for n in range(Xnew.shape[0])])
from ..util.linalg import jitchol
return np.array([np.sqrt(np.exp(2*np.sum(np.log(np.diag(jitchol(G[n, :, :])))))) for n in range(Xnew.shape[0])])
#return np.array([np.sqrt(np.linalg.det(G[n, :, :])) for n in range(Xnew.shape[0])])
def posterior_samples_f(self,X,size=10, full_cov=True):
"""
@ -564,6 +565,22 @@ class GP(Model):
plot_raw=plot_raw, Y_metadata=Y_metadata,
data_symbol=data_symbol, predict_kw=predict_kw, **kw)
def plot_magnification(self, labels=None, which_indices=None,
resolution=50, ax=None, marker='o', s=40,
fignum=None, legend=True,
plot_limits=None,
aspect='auto', updates=False, **kwargs):
import sys
assert "matplotlib" in sys.modules, "matplotlib package has not been imported."
from ..plotting.matplot_dep import dim_reduction_plots
return dim_reduction_plots.plot_magnification(self, labels, which_indices,
resolution, ax, marker, s,
fignum, False, legend,
plot_limits, aspect, updates, **kwargs)
def input_sensitivity(self, summarize=True):
"""
Returns the sensitivity for each dimension of this model

View file

@ -181,3 +181,18 @@ class SparseGP(GP):
var[i] = np.diag(var_)+p0-t2
return mu, var
def plot_magnification(self, labels=None, which_indices=None,
resolution=50, ax=None, marker='o', s=40,
fignum=None, legend=True,
plot_limits=None,
aspect='auto', updates=False, plot_inducing=True, **kwargs):
import sys
assert "matplotlib" in sys.modules, "matplotlib package has not been imported."
from ..plotting.matplot_dep import dim_reduction_plots
return dim_reduction_plots.plot_magnification(self, labels, which_indices,
resolution, ax, marker, s,
fignum, plot_inducing, legend,
plot_limits, aspect, updates, **kwargs)

View file

@ -24,7 +24,6 @@ class VerboseOptimization(object):
self.model.add_observer(self, self.print_status)
self.status = 'running'
self.clear = clear_after_finish
self.deltat = .2
self.update()
@ -80,6 +79,7 @@ class VerboseOptimization(object):
def __enter__(self):
self.start = time.time()
self._time = self.start
return self
def print_out(self, seconds):
@ -143,12 +143,12 @@ class VerboseOptimization(object):
def print_status(self, me, which=None):
self.update()
seconds = time.time()-self.start
t = time.time()
seconds = t-self.start
#sys.stdout.write(" "*len(self.message))
self.deltat += seconds
if self.deltat > .3 or seconds < .3:
if t-self._time > .3 or seconds < .3:
self.print_out(seconds)
self.deltat = 0
self._time = t
self.iteration += 1