From 9a7d9fa5b7f3893e18f44bf45463eba7ed68a73b Mon Sep 17 00:00:00 2001 From: Zhenwen Dai Date: Wed, 29 Jan 2014 10:28:39 +0000 Subject: [PATCH] adapter laplace inference into the param framework --- .../latent_function_inference/laplace.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/GPy/inference/latent_function_inference/laplace.py b/GPy/inference/latent_function_inference/laplace.py index 2b2128db..fa5bb3b8 100644 --- a/GPy/inference/latent_function_inference/laplace.py +++ b/GPy/inference/latent_function_inference/laplace.py @@ -53,6 +53,27 @@ class LaplaceInference(object): self.restart() 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): """ Reset likelihood variables to their defaults