mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-09 03:52:39 +02:00
likelihoods are now Parameterized objects
This commit is contained in:
parent
3db9d01734
commit
127340d17d
5 changed files with 15 additions and 9 deletions
|
|
@ -372,7 +372,10 @@ class Parameterized(object):
|
|||
for j in tie:
|
||||
ties[j] = '(' + str(i) + ')'
|
||||
|
||||
values = ['%.4f' % float(v) for v in values]
|
||||
if values.size == 1:
|
||||
values = ['%.4f' %float(values)]
|
||||
else:
|
||||
values = ['%.4f' % float(v) for v in values]
|
||||
max_names = max([len(names[i]) for i in range(len(names))] + [len(header[0])])
|
||||
max_values = max([len(values[i]) for i in range(len(values))] + [len(header[1])])
|
||||
max_constraint = max([len(constraints[i]) for i in range(len(constraints))] + [len(header[2])])
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ class EP(likelihood):
|
|||
self.VVT_factor = self.V
|
||||
self.trYYT = 0.
|
||||
|
||||
super(EP, self).__init__()
|
||||
|
||||
def restart(self):
|
||||
self.tau_tilde = np.zeros(self.N)
|
||||
self.v_tilde = np.zeros(self.N)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ class Gaussian(likelihood):
|
|||
self._variance = np.asarray(variance) + 1.
|
||||
self._set_params(np.asarray(variance))
|
||||
|
||||
super(Gaussian, self).__init__()
|
||||
|
||||
def set_data(self, data):
|
||||
self.data = data
|
||||
self.N, D = data.shape
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ class Gaussian_Mixed_Noise(likelihood):
|
|||
self.set_data(data_list)
|
||||
self._set_params(np.asarray(noise_params))
|
||||
|
||||
super(Gaussian_Mixed_Noise, self).__init__()
|
||||
|
||||
def set_data(self, data_list):
|
||||
self.data = np.vstack(data_list)
|
||||
self.N, D = self.data.shape
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import numpy as np
|
||||
import copy
|
||||
from ..core.parameterized import Parameterized
|
||||
|
||||
class likelihood:
|
||||
class likelihood(Parameterized):
|
||||
"""
|
||||
The atom for a likelihood class
|
||||
|
||||
|
|
@ -16,10 +17,10 @@ class likelihood:
|
|||
self.is_heteroscedastic : enables significant computational savings in GP
|
||||
self.precision : a scalar or vector representation of the effective target precision
|
||||
self.YYT : (optional) = np.dot(self.Y, self.Y.T) enables computational savings for D>N
|
||||
self.V : self.precision * self.Y
|
||||
self.V : self.precision * self.Y
|
||||
"""
|
||||
def __init__(self,data):
|
||||
raise ValueError, "this class is not to be instantiated"
|
||||
def __init__(self):
|
||||
Parameterized.__init__(self)
|
||||
|
||||
def _get_params(self):
|
||||
raise NotImplementedError
|
||||
|
|
@ -38,7 +39,3 @@ class likelihood:
|
|||
|
||||
def predictive_values(self, mu, var):
|
||||
raise NotImplementedError
|
||||
|
||||
def copy(self):
|
||||
""" Returns a (deep) copy of the current likelihood """
|
||||
return copy.deepcopy(self)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue