corrected the predictive variance for Gaussian likelihoods

This commit is contained in:
James Hensman 2013-03-13 09:58:39 +00:00
parent 9d27c920e0
commit eb82d6a255
4 changed files with 12 additions and 7 deletions

View file

@ -51,7 +51,7 @@ class Gaussian(likelihood):
true_var = (var + self._variance)*self._std**2 true_var = (var + self._variance)*self._std**2
_5pc = mean + - 2.*np.sqrt(true_var) _5pc = mean + - 2.*np.sqrt(true_var)
_95pc = mean + 2.*np.sqrt(true_var) _95pc = mean + 2.*np.sqrt(true_var)
return mean, _5pc, _95pc return mean, true_var, _5pc, _95pc
def fit_full(self): def fit_full(self):
""" """

View file

@ -25,11 +25,16 @@ class likelihood:
def _get_param_names(self): def _get_param_names(self):
raise NotImplementedError raise NotImplementedError
def _set_params(self,x): def _set_params(self, x):
raise NotImplementedError raise NotImplementedError
def fit(self): def fit(self):
raise NotImplementedError raise NotImplementedError
def _gradients(self,partial): def _gradients(self, partial):
raise NotImplementedError raise NotImplementedError
def predictive_values(self, mu, var):
raise NotImplementedError

View file

@ -48,14 +48,14 @@ class probit(likelihood_function):
def predictive_values(self,mu,var): def predictive_values(self,mu,var):
""" """
Compute mean, and conficence interval (percentiles 5 and 95) of the prediction Compute mean, variance and conficence interval (percentiles 5 and 95) of the prediction
""" """
mu = mu.flatten() mu = mu.flatten()
var = var.flatten() var = var.flatten()
mean = stats.norm.cdf(mu/np.sqrt(1+var)) mean = stats.norm.cdf(mu/np.sqrt(1+var))
p_025 = np.zeros(mu.shape) p_025 = np.zeros(mu.shape)
p_975 = np.ones(mu.shape) p_975 = np.ones(mu.shape)
return mean, p_025, p_975 return mean, np.nan*var, p_025, p_975 # TODO: better values here (mean is okay)
class Poisson(likelihood_function): class Poisson(likelihood_function):
""" """
@ -131,4 +131,4 @@ class Poisson(likelihood_function):
tmp = stats.poisson.ppf(np.array([.025,.975]),mean) tmp = stats.poisson.ppf(np.array([.025,.975]),mean)
p_025 = tmp[:,0] p_025 = tmp[:,0]
p_975 = tmp[:,1] p_975 = tmp[:,1]
return mean,p_025,p_975 return mean,np.nan*mean,p_025,p_975 # better variance here TODO

View file

@ -179,7 +179,7 @@ class GP(model):
mu, var = self._raw_predict(Xnew, slices, full_cov) mu, var = self._raw_predict(Xnew, slices, full_cov)
#now push through likelihood TODO #now push through likelihood TODO
mean, _025pm, _975pm = self.likelihood.predictive_values(mu, var) mean, var, _025pm, _975pm = self.likelihood.predictive_values(mu, var)
return mean, var, _025pm, _975pm return mean, var, _025pm, _975pm