mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-10 12:32:40 +02:00
fixing qualtile code for some likelhoods
This commit is contained in:
parent
2af47f1d31
commit
9780fb48de
2 changed files with 14 additions and 3 deletions
|
|
@ -232,6 +232,17 @@ class Bernoulli(Likelihood):
|
||||||
np.seterr(**state)
|
np.seterr(**state)
|
||||||
return d3logpdf_dlink3
|
return d3logpdf_dlink3
|
||||||
|
|
||||||
|
def predictive_quantiles(self, mu, var, quantiles, Y_metadata=None):
|
||||||
|
"""
|
||||||
|
Get the "quantiles" of the binary labels (Bernoulli draws). all the
|
||||||
|
quantiles must be either 0 or 1, since those are the only values the
|
||||||
|
draw can take!
|
||||||
|
"""
|
||||||
|
p = self.predictive_mean(mu, var)
|
||||||
|
return [np.asarray(p>(q/100.), dtype=np.int32) for q in quantiles]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def samples(self, gp, Y_metadata=None):
|
def samples(self, gp, Y_metadata=None):
|
||||||
"""
|
"""
|
||||||
Returns a set of samples of observations based on a given value of the latent variable.
|
Returns a set of samples of observations based on a given value of the latent variable.
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ class Poisson(Likelihood):
|
||||||
"""
|
"""
|
||||||
return self.gp_link.transf(gp)
|
return self.gp_link.transf(gp)
|
||||||
|
|
||||||
def samples(self, gp, Y_metadata=None):
|
def samples(self, gp, Y_metadata=None, samples=1):
|
||||||
"""
|
"""
|
||||||
Returns a set of samples of observations based on a given value of the latent variable.
|
Returns a set of samples of observations based on a given value of the latent variable.
|
||||||
|
|
||||||
|
|
@ -145,5 +145,5 @@ class Poisson(Likelihood):
|
||||||
"""
|
"""
|
||||||
orig_shape = gp.shape
|
orig_shape = gp.shape
|
||||||
gp = gp.flatten()
|
gp = gp.flatten()
|
||||||
Ysim = np.random.poisson(self.gp_link.transf(gp))
|
Ysim = np.random.poisson(self.gp_link.transf(gp), [samples, gp.size]).T
|
||||||
return Ysim.reshape(orig_shape)
|
return Ysim.reshape(orig_shape+(samples,))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue