adapter laplace inference into the param framework

This commit is contained in:
Zhenwen Dai 2014-01-29 10:28:39 +00:00
parent ae03b63afb
commit 9a7d9fa5b7

View file

@ -53,6 +53,27 @@ class LaplaceInference(object):
self.restart() self.restart()
likelihood.__init__(self) likelihood.__init__(self)
def inference(self, kern, X, likelihood, Y, Y_metadata=None):
"""
Returns a Posterior class containing essential quantities of the posterior
"""
# Compute K
self.K = kern.K(X)
self.data = Y
self.N, self.D = Y.shape
#Find mode
self.f_hat = self.rasm_mode(self.K)
#Compute hessian and other variables at mode
self._compute_likelihood_variables()
#Compute fake variables replicating laplace approximation to posterior
self._compute_GP_variables()
return Posterior(mean=self.f_hat, cov=self.covariance_matrix, K=self.K)
def restart(self): def restart(self):
""" """
Reset likelihood variables to their defaults Reset likelihood variables to their defaults