mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-27 14:25:16 +02:00
Merge branch 'devel' into travis_testing
This commit is contained in:
commit
dad7315c8a
86 changed files with 806 additions and 3227 deletions
|
|
@ -640,7 +640,7 @@ class GP(Model):
|
|||
fignum, ax, data_symbol, **kw)
|
||||
|
||||
|
||||
def errorbars_trainset(self, which_data_rows='all',
|
||||
def plot_errorbars_trainset(self, which_data_rows='all',
|
||||
which_data_ycols='all', fixed_inputs=[], fignum=None, ax=None,
|
||||
linecol=None, data_symbol='kx', predict_kw=None, plot_training_data=True,lw=None):
|
||||
|
||||
|
|
@ -669,7 +669,7 @@ class GP(Model):
|
|||
kw = {}
|
||||
if lw is not None:
|
||||
kw['lw'] = lw
|
||||
return models_plots.errorbars_trainset(self, which_data_rows, which_data_ycols, fixed_inputs,
|
||||
return models_plots.plot_errorbars_trainset(self, which_data_rows, which_data_ycols, fixed_inputs,
|
||||
fignum, ax, linecol, data_symbol,
|
||||
predict_kw, plot_training_data, **kw)
|
||||
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ class Model(Parameterized):
|
|||
opt.model = self
|
||||
else:
|
||||
optimizer = optimization.get_optimizer(optimizer)
|
||||
opt = optimizer(start, model=self, max_iters=max_iters, **kwargs)
|
||||
opt = optimizer(x_init=start, model=self, max_iters=max_iters, **kwargs)
|
||||
|
||||
with VerboseOptimization(self, opt, maxiters=max_iters, verbose=messages, ipython_notebook=ipython_notebook, clear_after_finish=clear_after_finish) as vo:
|
||||
opt.run(f_fp=self._objective_grads, f=self._objective, fp=self._grads)
|
||||
|
|
@ -422,7 +422,7 @@ class Model(Parameterized):
|
|||
to_print.append(super(Model, self)._repr_html_())
|
||||
return "\n".join(to_print)
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self, VT100=True):
|
||||
model_details = [['Name', self.name],
|
||||
['Log-likelihood', '{}'.format(float(self.log_likelihood()))],
|
||||
["Number of Parameters", '{}'.format(self.size)],
|
||||
|
|
@ -432,6 +432,6 @@ class Model(Parameterized):
|
|||
from operator import itemgetter
|
||||
max_len = reduce(lambda a, b: max(len(b[0]), a), model_details, 0)
|
||||
to_print = [""] + ["{0:{l}} : {1}".format(name, detail, l=max_len) for name, detail in model_details] + ["Parameters:"]
|
||||
to_print.append(super(Model, self).__str__())
|
||||
to_print.append(super(Model, self).__str__(VT100=VT100))
|
||||
return "\n".join(to_print)
|
||||
|
||||
|
|
|
|||
|
|
@ -227,8 +227,8 @@ class Nameable(Gradcheckable):
|
|||
Make an object nameable inside the hierarchy.
|
||||
"""
|
||||
def __init__(self, name, *a, **kw):
|
||||
super(Nameable, self).__init__(*a, **kw)
|
||||
self._name = name or self.__class__.__name__
|
||||
super(Nameable, self).__init__(*a, **kw)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
|||
|
|
@ -314,8 +314,8 @@ class Parameterized(Parameterizable):
|
|||
if name in pnames:
|
||||
param = self.parameters[pnames.index(name)]
|
||||
param[:] = val; return
|
||||
except AttributeError:
|
||||
pass
|
||||
except AttributeError as a:
|
||||
raise
|
||||
return object.__setattr__(self, name, val);
|
||||
|
||||
#===========================================================================
|
||||
|
|
@ -405,7 +405,7 @@ class Parameterized(Parameterizable):
|
|||
</style>"""
|
||||
return style + '\n' + '<table class="tg">' + '\n'.format(sep).join(to_print) + '\n</table>'
|
||||
|
||||
def __str__(self, header=True):
|
||||
def __str__(self, header=True, VT100=True):
|
||||
name = adjust_name_for_printing(self.name) + "."
|
||||
constrs = self._constraints_str;
|
||||
ts = self._ties_str
|
||||
|
|
@ -416,7 +416,10 @@ class Parameterized(Parameterizable):
|
|||
cl = max([len(str(x)) if x else 0 for x in constrs + ["Constraint"]])
|
||||
tl = max([len(str(x)) if x else 0 for x in ts + ["Tied to"]])
|
||||
pl = max([len(str(x)) if x else 0 for x in prirs + ["Prior"]])
|
||||
format_spec = " \033[1m{{name:<{0}s}}\033[0;0m | {{desc:>{1}s}} | {{const:^{2}s}} | {{pri:^{3}s}} | {{t:^{4}s}}".format(nl, sl, cl, pl, tl)
|
||||
if VT100:
|
||||
format_spec = " \033[1m{{name:<{0}s}}\033[0;0m | {{desc:>{1}s}} | {{const:^{2}s}} | {{pri:^{3}s}} | {{t:^{4}s}}".format(nl, sl, cl, pl, tl)
|
||||
else:
|
||||
format_spec = " {{name:<{0}s}} | {{desc:>{1}s}} | {{const:^{2}s}} | {{pri:^{3}s}} | {{t:^{4}s}}".format(nl, sl, cl, pl, tl)
|
||||
to_print = []
|
||||
for n, d, c, t, p in zip(names, desc, constrs, ts, prirs):
|
||||
to_print.append(format_spec.format(name=n, desc=d, const=c, t=t, pri=p))
|
||||
|
|
|
|||
|
|
@ -42,10 +42,11 @@ class SparseGP(GP):
|
|||
|
||||
def __init__(self, X, Y, Z, kernel, likelihood, mean_function=None, X_variance=None, inference_method=None,
|
||||
name='sparse gp', Y_metadata=None, normalizer=False):
|
||||
|
||||
#pick a sensible inference method
|
||||
if inference_method is None:
|
||||
if isinstance(likelihood, likelihoods.Gaussian):
|
||||
inference_method = var_dtc.VarDTC(limit=1 if not self.missing_data else Y.shape[1])
|
||||
inference_method = var_dtc.VarDTC(limit=1)
|
||||
else:
|
||||
#inference_method = ??
|
||||
raise NotImplementedError("what to do what to do?")
|
||||
|
|
@ -112,6 +113,7 @@ class SparseGP(GP):
|
|||
#gradients wrt Z
|
||||
self.Z.gradient = self.kern.gradients_X(self.grad_dict['dL_dKmm'], self.Z)
|
||||
self.Z.gradient += self.kern.gradients_X(self.grad_dict['dL_dKnm'].T, self.Z, self.X)
|
||||
self._Zgrad = self.Z.gradient.copy()
|
||||
|
||||
|
||||
def _raw_predict(self, Xnew, full_cov=False, kern=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue