mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-09 12:02:38 +02:00
[printing] added model details for printing
This commit is contained in:
parent
f048245a9c
commit
a358c51829
2 changed files with 9 additions and 3 deletions
|
|
@ -372,4 +372,13 @@ class Model(Parameterized):
|
||||||
self.optimizer_array = x
|
self.optimizer_array = x
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
model_details = [['Name', self.name],
|
||||||
|
['Log-likelihood', '{}'.format(float(self.log_likelihood()))],
|
||||||
|
["Number of Parameters", '{}'.format(self.size)]]
|
||||||
|
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__())
|
||||||
|
return "\n".join(to_print)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,6 @@ class Parameterized(Parameterizable):
|
||||||
def _ties_str(self):
|
def _ties_str(self):
|
||||||
return [','.join(x._ties_str) for x in self.flattened_parameters]
|
return [','.join(x._ties_str) for x in self.flattened_parameters]
|
||||||
def __str__(self, header=True):
|
def __str__(self, header=True):
|
||||||
|
|
||||||
name = adjust_name_for_printing(self.name) + "."
|
name = adjust_name_for_printing(self.name) + "."
|
||||||
constrs = self._constraints_str;
|
constrs = self._constraints_str;
|
||||||
ts = self._ties_str
|
ts = self._ties_str
|
||||||
|
|
@ -365,11 +364,9 @@ class Parameterized(Parameterizable):
|
||||||
to_print = []
|
to_print = []
|
||||||
for n, d, c, t, p in itertools.izip(names, desc, constrs, ts, prirs):
|
for n, d, c, t, p in itertools.izip(names, desc, constrs, ts, prirs):
|
||||||
to_print.append(format_spec.format(name=n, desc=d, const=c, t=t, pri=p))
|
to_print.append(format_spec.format(name=n, desc=d, const=c, t=t, pri=p))
|
||||||
# to_print = [format_spec.format(p=p, const=c, t=t) if isinstance(p, Param) else p.__str__(header=False) for p, c, t in itertools.izip(self.parameters, constrs, ts)]
|
|
||||||
sep = '-' * (nl + sl + cl + + pl + tl + 8 * 2 + 3)
|
sep = '-' * (nl + sl + cl + + pl + tl + 8 * 2 + 3)
|
||||||
if header:
|
if header:
|
||||||
header = " {{0:<{0}s}} | {{1:^{1}s}} | {{2:^{2}s}} | {{3:^{3}s}} | {{4:^{4}s}}".format(nl, sl, cl, pl, tl).format(name, "Value", "Constraint", "Prior", "Tied to")
|
header = " {{0:<{0}s}} | {{1:^{1}s}} | {{2:^{2}s}} | {{3:^{3}s}} | {{4:^{4}s}}".format(nl, sl, cl, pl, tl).format(name, "Value", "Constraint", "Prior", "Tied to")
|
||||||
# header += '\n' + sep
|
|
||||||
to_print.insert(0, header)
|
to_print.insert(0, header)
|
||||||
return '\n'.format(sep).join(to_print)
|
return '\n'.format(sep).join(to_print)
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue