# GPy.likelihoods package¶

## Introduction¶

The likelihood is $$p(y|f,X)$$ which is how well we will predict target values given inputs $$X$$ and our latent function $$f$$ ($$y$$ without noise). Marginal likelihood $$p(y|X)$$, is the same as likelihood except we marginalize out the model $$f$$. The importance of likelihoods in Gaussian Processes is in determining the ‘best’ values of kernel and noise hyperparamters to relate known, observed and unobserved data. The purpose of optimizing a model (e.g. GPy.models.GPRegression) is to determine the ‘best’ hyperparameters i.e. those that minimize negative log marginal likelihood.

Most likelihood classes inherit directly from GPy.likelihoods.likelihood, although an intermediary class GPy.likelihoods.mixed_noise.MixedNoise is used by GPy.likelihoods.multioutput_likelihood.

## GPy.likelihoods.bernoulli module¶

class Bernoulli(gp_link=None)[source]

Bernoulli likelihood

$p(y_{i}|\lambda(f_{i})) = \lambda(f_{i})^{y_{i}}(1-f_{i})^{1-y_{i}}$

Note

Y takes values in either {-1, 1} or {0, 1}. link function should have the domain [0, 1], e.g. probit (default) or Heaviside

d2logpdf_dlink2(inv_link_f, y, Y_metadata=None)[source]

Hessian at y, given inv_link_f, w.r.t inv_link_f the hessian will be 0 unless i == j i.e. second derivative logpdf at y given inverse link of f_i and inverse link of f_j w.r.t inverse link of f_i and inverse link of f_j.

$\frac{d^{2}\ln p(y_{i}|\lambda(f_{i}))}{d\lambda(f)^{2}} = \frac{-y_{i}}{\lambda(f)^{2}} - \frac{(1-y_{i})}{(1-\lambda(f))^{2}}$
Parameters: inv_link_f (Nx1 array) – latent variables inverse link of f. y (Nx1 array) – data Y_metadata – Y_metadata not used in bernoulli Diagonal of log hessian matrix (second derivative of log likelihood evaluated at points inverse link of f. Nx1 array

Note

Will return diagonal of hessian, since every where else it is 0, as the likelihood factorizes over cases (the distribution for y_i depends only on inverse link of f_i not on inverse link of f_(j!=i)

d3logpdf_dlink3(inv_link_f, y, Y_metadata=None)[source]

Third order derivative log-likelihood function at y given inverse link of f w.r.t inverse link of f

$\frac{d^{3} \ln p(y_{i}|\lambda(f_{i}))}{d^{3}\lambda(f)} = \frac{2y_{i}}{\lambda(f)^{3}} - \frac{2(1-y_{i}}{(1-\lambda(f))^{3}}$
Parameters: inv_link_f (Nx1 array) – latent variables passed through inverse link of f. y (Nx1 array) – data Y_metadata – Y_metadata not used in bernoulli third derivative of log likelihood evaluated at points inverse_link(f) Nx1 array

$\frac{d\ln p(y_{i}|\lambda(f_{i}))}{d\lambda(f)} = \frac{y_{i}}{\lambda(f_{i})} - \frac{(1 - y_{i})}{(1 - \lambda(f_{i}))}$
Parameters: inv_link_f (Nx1 array) – latent variables inverse link of f. y (Nx1 array) – data Y_metadata – Y_metadata not used in bernoulli gradient of log likelihood evaluated at points inverse link of f. Nx1 array
exact_inference_gradients(dL_dKdiag, Y_metadata=None)[source]

Log Likelihood function given inverse link of f.

$\ln p(y_{i}|\lambda(f_{i})) = y_{i}\log\lambda(f_{i}) + (1-y_{i})\log (1-f_{i})$
Parameters: inv_link_f (Nx1 array) – latent variables inverse link of f. y (Nx1 array) – data Y_metadata – Y_metadata not used in bernoulli log likelihood evaluated at points inverse link of f. float
moments_match_ep(Y_i, tau_i, v_i, Y_metadata_i=None)[source]

Moments match of the marginal approximation in EP algorithm

Parameters: i – number of observation (int) tau_i – precision of the cavity distribution (float) v_i – mean/variance of the cavity distribution (float)

Likelihood function given inverse link of f.

$p(y_{i}|\lambda(f_{i})) = \lambda(f_{i})^{y_{i}}(1-f_{i})^{1-y_{i}}$
Parameters: inv_link_f (Nx1 array) – latent variables inverse link of f. y (Nx1 array) – data Y_metadata – Y_metadata not used in bernoulli likelihood evaluated for this point float
predictive_mean(mu, variance, Y_metadata=None)[source]

Quadrature calculation of the predictive mean: E(Y_star|Y) = E( E(Y_star|f_star, Y) )

Parameters: mu – mean of posterior sigma – standard deviation of posterior
predictive_quantiles(mu, var, quantiles, Y_metadata=None)[source]

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!

predictive_variance(mu, variance, pred_mean, Y_metadata=None)[source]

Approximation to the predictive variance: V(Y_star)

The following variance decomposition is used: V(Y_star) = E( V(Y_star|f_star)**2 ) + V( E(Y_star|f_star) )**2

Parameters: Predictive_mean: mu – mean of posterior sigma – standard deviation of posterior output’s predictive mean, if None _predictive_mean function will be called.
samples(gp, Y_metadata=None)[source]

Returns a set of samples of observations based on a given value of the latent variable.

Parameters: gp – latent variable
to_dict()[source]

Convert the object into a json serializable dictionary.

Note: It uses the private method _save_to_input_dict of the parent.

Return dict: json serializable dictionary containing the needed information to instantiate the object
variational_expectations(Y, m, v, gh_points=None, Y_metadata=None)[source]

E_p(f) [ log p(y|f) ] d/dm E_p(f) [ log p(y|f) ] d/dv E_p(f) [ log p(y|f) ]

where p(f) is a Gaussian with mean m and variance v. The shapes of Y, m and v should match.

if no gh_points are passed, we construct them using defualt options

## GPy.likelihoods.binomial module¶

class Binomial(gp_link=None)[source]

Binomial likelihood

$p(y_{i}|\lambda(f_{i})) = \lambda(f_{i})^{y_{i}}(1-f_{i})^{1-y_{i}}$

Note

Y takes values in either {-1, 1} or {0, 1}. link function should have the domain [0, 1], e.g. probit (default) or Heaviside

d2logpdf_dlink2(inv_link_f, y, Y_metadata=None)[source]

Hessian at y, given inv_link_f, w.r.t inv_link_f the hessian will be 0 unless i == j i.e. second derivative logpdf at y given inverse link of f_i and inverse link of f_j w.r.t inverse link of f_i and inverse link of f_j.

$\frac{d^{2}\ln p(y_{i}|\lambda(f_{i}))}{d\lambda(f)^{2}} = \frac{-y_{i}}{\lambda(f)^{2}} - \frac{(N-y_{i})}{(1-\lambda(f))^{2}}$
Parameters: inv_link_f (Nx1 array) – latent variables inverse link of f. y (Nx1 array) – data Y_metadata – Y_metadata not used in binomial Diagonal of log hessian matrix (second derivative of log likelihood evaluated at points inverse link of f. Nx1 array

Note

Will return diagonal of hessian, since every where else it is 0, as the likelihood factorizes over cases (the distribution for y_i depends only on inverse link of f_i not on inverse link of f_(j!=i)

d3logpdf_dlink3(inv_link_f, y, Y_metadata=None)[source]

Third order derivative log-likelihood function at y given inverse link of f w.r.t inverse link of f

$\frac{d^{2}\ln p(y_{i}|\lambda(f_{i}))}{d\lambda(f)^{2}} = \frac{2y_{i}}{\lambda(f)^{3}} - \frac{2(N-y_{i})}{(1-\lambda(f))^{3}}$
Parameters: inv_link_f (Nx1 array) – latent variables inverse link of f. y (Nx1 array) – data Y_metadata – Y_metadata not used in binomial Diagonal of log hessian matrix (second derivative of log likelihood evaluated at points inverse link of f. Nx1 array

Note

Will return diagonal of hessian, since every where else it is 0, as the likelihood factorizes over cases (the distribution for y_i depends only on inverse link of f_i not on inverse link of f_(j!=i)

$\frac{d^{2}\ln p(y_{i}|\lambda(f_{i}))}{d\lambda(f)^{2}} = \frac{y_{i}}{\lambda(f)} - \frac{(N-y_{i})}{(1-\lambda(f))}$
Parameters: inv_link_f (Nx1 array) – latent variables inverse link of f. y (Nx1 array) – data Y_metadata – Y_metadata must contain ‘trials’ gradient of log likelihood evaluated at points inverse link of f. Nx1 array
exact_inference_gradients(dL_dKdiag, Y_metadata=None)[source]

Log Likelihood function given inverse link of f.

$\ln p(y_{i}|\lambda(f_{i})) = y_{i}\log\lambda(f_{i}) + (1-y_{i})\log (1-f_{i})$
Parameters: inv_link_f (Nx1 array) – latent variables inverse link of f. y (Nx1 array) – data Y_metadata – Y_metadata must contain ‘trials’ log likelihood evaluated at points inverse link of f. float
moments_match_ep(obs, tau, v, Y_metadata_i=None)[source]

Calculation of moments using quadrature :param obs: observed output :param tau: cavity distribution 1st natural parameter (precision) :param v: cavity distribution 2nd natural paramenter (mu*precision)

Likelihood function given inverse link of f.

$p(y_{i}|\lambda(f_{i})) = \lambda(f_{i})^{y_{i}}(1-f_{i})^{1-y_{i}}$
Parameters: inv_link_f (Nx1 array) – latent variables inverse link of f. y (Nx1 array) – data Y_metadata – Y_metadata must contain ‘trials’ likelihood evaluated for this point float
samples(gp, Y_metadata=None, **kw)[source]

Returns a set of samples of observations based on a given value of the latent variable.

Parameters: gp – latent variable
variational_expectations(Y, m, v, gh_points=None, Y_metadata=None)[source]

E_p(f) [ log p(y|f) ] d/dm E_p(f) [ log p(y|f) ] d/dv E_p(f) [ log p(y|f) ]

where p(f) is a Gaussian with mean m and variance v. The shapes of Y, m and v should match.

if no gh_points are passed, we construct them using defualt options

## GPy.likelihoods.exponential module¶

class Exponential(gp_link=None)[source]

Expoential likelihood Y is expected to take values in {0,1,2,…} —– $$L(x) = exp(lambda) * lambda**Y_i / Y_i!$$

d2logpdf_dlink2(link_f, y, Y_metadata=None)[source]

$\frac{d^{2} \ln p(y_{i}|\lambda(f_{i}))}{d^{2}\lambda(f)} = -\frac{1}{\lambda(f_{i})^{2}}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in exponential distribution Diagonal of hessian matrix (second derivative of likelihood evaluated at points f) Nx1 array

Note

Will return diagonal of hessian, since every where else it is 0, as the likelihood factorizes over cases (the distribution for y_i depends only on link(f_i) not on link(f_(j!=i))

d3logpdf_dlink3(link_f, y, Y_metadata=None)[source]

$\frac{d^{3} \ln p(y_{i}|\lambda(f_{i}))}{d^{3}\lambda(f)} = \frac{2}{\lambda(f_{i})^{3}}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in exponential distribution third derivative of likelihood evaluated at points f Nx1 array

$\frac{d \ln p(y_{i}|\lambda(f_{i}))}{d\lambda(f)} = \frac{1}{\lambda(f)} - y_{i}$
Parameters: link_f (Nx1 array) – latent variables (f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in exponential distribution gradient of likelihood evaluated at points Nx1 array

$\ln p(y_{i}|\lambda(f_{i})) = \ln \lambda(f_{i}) - y_{i}\lambda(f_{i})$
Parameters: link_f (Nx1 array) – latent variables (link(f)) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in exponential distribution likelihood evaluated for this point float

$p(y_{i}|\lambda(f_{i})) = \lambda(f_{i})\exp (-y\lambda(f_{i}))$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in exponential distribution likelihood evaluated for this point float
samples(gp, Y_metadata=None)[source]

Returns a set of samples of observations based on a given value of the latent variable.

Parameters: gp – latent variable

## GPy.likelihoods.gamma module¶

class Gamma(gp_link=None, beta=1.0)[source]

Gamma likelihood

$\begin{split}p(y_{i}|\lambda(f_{i})) = \frac{\beta^{\alpha_{i}}}{\Gamma(\alpha_{i})}y_{i}^{\alpha_{i}-1}e^{-\beta y_{i}}\\ \alpha_{i} = \beta y_{i}\end{split}$
d2logpdf_dlink2(link_f, y, Y_metadata=None)[source]

$\begin{split}\frac{d^{2} \ln p(y_{i}|\lambda(f_{i}))}{d^{2}\lambda(f)} = -\beta^{2}\frac{d\Psi(\alpha_{i})}{d\alpha_{i}}\\ \alpha_{i} = \beta y_{i}\end{split}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in gamma distribution Diagonal of hessian matrix (second derivative of likelihood evaluated at points f) Nx1 array

Note

Will return diagonal of hessian, since every where else it is 0, as the likelihood factorizes over cases (the distribution for y_i depends only on link(f_i) not on link(f_(j!=i))

d3logpdf_dlink3(link_f, y, Y_metadata=None)[source]

$\begin{split}\frac{d^{3} \ln p(y_{i}|\lambda(f_{i}))}{d^{3}\lambda(f)} = -\beta^{3}\frac{d^{2}\Psi(\alpha_{i})}{d\alpha_{i}}\\ \alpha_{i} = \beta y_{i}\end{split}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in gamma distribution third derivative of likelihood evaluated at points f Nx1 array

$\begin{split}\frac{d \ln p(y_{i}|\lambda(f_{i}))}{d\lambda(f)} = \beta (\log \beta y_{i}) - \Psi(\alpha_{i})\beta\\ \alpha_{i} = \beta y_{i}\end{split}$
Parameters: link_f (Nx1 array) – latent variables (f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in gamma distribution gradient of likelihood evaluated at points Nx1 array

$\begin{split}\ln p(y_{i}|\lambda(f_{i})) = \alpha_{i}\log \beta - \log \Gamma(\alpha_{i}) + (\alpha_{i} - 1)\log y_{i} - \beta y_{i}\\ \alpha_{i} = \beta y_{i}\end{split}$
Parameters: link_f (Nx1 array) – latent variables (link(f)) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in poisson distribution likelihood evaluated for this point float

$\begin{split}p(y_{i}|\lambda(f_{i})) = \frac{\beta^{\alpha_{i}}}{\Gamma(\alpha_{i})}y_{i}^{\alpha_{i}-1}e^{-\beta y_{i}}\\ \alpha_{i} = \beta y_{i}\end{split}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in poisson distribution likelihood evaluated for this point float

## GPy.likelihoods.gaussian module¶

A lot of this code assumes that the link function is the identity.

I think laplace code is okay, but I’m quite sure that the EP moments will only work if the link is identity.

Furthermore, exact Guassian inference can only be done for the identity link, so we should be asserting so for all calls which relate to that.

James 11/12/13

class Gaussian(gp_link=None, variance=1.0, name='Gaussian_noise')[source]

Gaussian likelihood

$\ln p(y_{i}|\lambda(f_{i})) = -\frac{N \ln 2\pi}{2} - \frac{\ln |K|}{2} - \frac{(y_{i} - \lambda(f_{i}))^{T}\sigma^{-2}(y_{i} - \lambda(f_{i}))}{2}$
Parameters: variance – variance value of the Gaussian distribution N (int) – Number of data points
betaY(Y, Y_metadata=None)[source]
d2logpdf_dlink2(link_f, y, Y_metadata=None)[source]

The hessian will be 0 unless i == j

$\frac{d^{2} \ln p(y_{i}|\lambda(f_{i}))}{d^{2}f} = -\frac{1}{\sigma^{2}}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata not used in gaussian Diagonal of log hessian matrix (second derivative of log likelihood evaluated at points link(f)) Nx1 array

Note

Will return diagonal of hessian, since every where else it is 0, as the likelihood factorizes over cases (the distribution for y_i depends only on link(f_i) not on link(f_(j!=i))

d2logpdf_dlink2_dtheta(f, y, Y_metadata=None)[source]
d2logpdf_dlink2_dvar(link_f, y, Y_metadata=None)[source]

$\frac{d}{d\sigma^{2}}(\frac{d^{2} \ln p(y_{i}|\lambda(f_{i}))}{d^{2}\lambda(f)}) = \frac{1}{\sigma^{4}}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata not used in gaussian derivative of log hessian evaluated at points link(f_i) and link(f_j) w.r.t variance parameter Nx1 array
d3logpdf_dlink3(link_f, y, Y_metadata=None)[source]

$\frac{d^{3} \ln p(y_{i}|\lambda(f_{i}))}{d^{3}\lambda(f)} = 0$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata not used in gaussian third derivative of log likelihood evaluated at points link(f) Nx1 array

$\frac{d \ln p(y_{i}|\lambda(f_{i}))}{d\lambda(f)} = \frac{1}{\sigma^{2}}(y_{i} - \lambda(f_{i}))$

Derivative of the dlogpdf_dlink w.r.t variance parameter (noise_variance)

$\frac{d}{d\sigma^{2}}(\frac{d \ln p(y_{i}|\lambda(f_{i}))}{d\lambda(f)}) = \frac{1}{\sigma^{4}}(-y_{i} + \lambda(f_{i}))$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata not used in gaussian derivative of log likelihood evaluated at points link(f) w.r.t variance parameter Nx1 array

Gradient of the log-likelihood function at y given link(f), w.r.t variance parameter (noise_variance)

$\frac{d \ln p(y_{i}|\lambda(f_{i}))}{d\sigma^{2}} = -\frac{N}{2\sigma^{2}} + \frac{(y_{i} - \lambda(f_{i}))^{2}}{2\sigma^{4}}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata not used in gaussian derivative of log likelihood evaluated at points link(f) w.r.t variance parameter float
ep_gradients(Y, cav_tau, cav_v, dL_dKdiag, Y_metadata=None, quad_mode='gk', boost_grad=1.0)[source]
exact_inference_gradients(dL_dKdiag, Y_metadata=None)[source]
gaussian_variance(Y_metadata=None)[source]
log_predictive_density(y_test, mu_star, var_star, Y_metadata=None)[source]

assumes independence

$\ln p(y_{i}|\lambda(f_{i})) = -\frac{N \ln 2\pi}{2} - \frac{\ln |K|}{2} - \frac{(y_{i} - \lambda(f_{i}))^{T}\sigma^{-2}(y_{i} - \lambda(f_{i}))}{2}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata not used in gaussian log likelihood evaluated for this point float
moments_match_ep(data_i, tau_i, v_i, Y_metadata_i=None)[source]

Moments match of the marginal approximation in EP algorithm

Parameters: i – number of observation (int) tau_i – precision of the cavity distribution (float) v_i – mean/variance of the cavity distribution (float)

$\ln p(y_{i}|\lambda(f_{i})) = -\frac{N \ln 2\pi}{2} - \frac{\ln |K|}{2} - \frac{(y_{i} - \lambda(f_{i}))^{T}\sigma^{-2}(y_{i} - \lambda(f_{i}))}{2}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata not used in gaussian likelihood evaluated for this point float
predictive_mean(mu, sigma)[source]

Quadrature calculation of the predictive mean: E(Y_star|Y) = E( E(Y_star|f_star, Y) )

Parameters: mu – mean of posterior sigma – standard deviation of posterior
predictive_quantiles(mu, var, quantiles, Y_metadata=None)[source]
predictive_values(mu, var, full_cov=False, Y_metadata=None)[source]

Compute mean, variance of the predictive distibution.

Parameters: mu – mean of the latent variable, f, of posterior var – variance of the latent variable, f, of posterior full_cov (Boolean) – whether to use the full covariance or just the diagonal
predictive_variance(mu, sigma, predictive_mean=None)[source]

Approximation to the predictive variance: V(Y_star)

The following variance decomposition is used: V(Y_star) = E( V(Y_star|f_star)**2 ) + V( E(Y_star|f_star) )**2

Parameters: Predictive_mean: mu – mean of posterior sigma – standard deviation of posterior output’s predictive mean, if None _predictive_mean function will be called.
samples(gp, Y_metadata=None)[source]

Returns a set of samples of observations based on a given value of the latent variable.

Parameters: gp – latent variable
to_dict()[source]

Convert the object into a json serializable dictionary.

Note: It uses the private method _save_to_input_dict of the parent.

Return dict: json serializable dictionary containing the needed information to instantiate the object
update_gradients(grad)[source]
variational_expectations(Y, m, v, gh_points=None, Y_metadata=None)[source]

E_p(f) [ log p(y|f) ] d/dm E_p(f) [ log p(y|f) ] d/dv E_p(f) [ log p(y|f) ]

where p(f) is a Gaussian with mean m and variance v. The shapes of Y, m and v should match.

if no gh_points are passed, we construct them using defualt options

class HeteroscedasticGaussian(Y_metadata, gp_link=None, variance=1.0, name='het_Gauss')[source]
exact_inference_gradients(dL_dKdiag, Y_metadata=None)[source]
gaussian_variance(Y_metadata=None)[source]
predictive_quantiles(mu, var, quantiles, Y_metadata=None)[source]
predictive_values(mu, var, full_cov=False, Y_metadata=None)[source]

Compute mean, variance of the predictive distibution.

Parameters: mu – mean of the latent variable, f, of posterior var – variance of the latent variable, f, of posterior full_cov (Boolean) – whether to use the full covariance or just the diagonal

## GPy.likelihoods.likelihood module¶

class Likelihood(gp_link, name)[source]

Likelihood base class, used to defing p(y|f).

All instances use _inverse_ link functions, which can be swapped out. It is expected that inheriting classes define a default inverse link function

To use this class, inherit and define missing functionality.

Inheriting classes must implement:
pdf_link : a bound method which turns the output of the link function into the pdf logpdf_link : the logarithm of the above
To enable use with EP, inheriting classes must define:
TODO: a suitable derivative function for any parameters of the class
It is also desirable to define:
moments_match_ep : a function to compute the EP moments If this isn’t defined, the moments will be computed using 1D quadrature.
To enable use with Laplace approximation, inheriting classes must define:
Some derivative functions AS TODO

For exact Gaussian inference, define JH TODO

MCMC_pdf_samples(fNew, num_samples=1000, starting_loc=None, stepsize=0.1, burn_in=1000, Y_metadata=None)[source]

Simple implementation of Metropolis sampling algorithm

Will run a parallel chain for each input dimension (treats each f independently) Thus assumes f*_1 independant of f*_2 etc.

Parameters: num_samples – Number of samples to take fNew – f at which to sample around starting_loc – Starting locations of the independant chains (usually will be conditional_mean of likelihood), often link_f stepsize – Stepsize for the normal proposal distribution (will need modifying) burnin – number of samples to use for burnin (will need modifying) Y_metadata – Y_metadata for pdf
conditional_mean(gp)[source]

The mean of the random variable conditioned on one value of the GP

conditional_variance(gp)[source]

The variance of the random variable conditioned on one value of the GP

d2logpdf_df2(*args, **kwargs)
d2logpdf_df2_dtheta(f, y, Y_metadata=None)[source]

TODO: Doc strings

d2logpdf_dlink2(inv_link_f, y, Y_metadata=None)[source]
d2logpdf_dlink2_dtheta(inv_link_f, y, Y_metadata=None)[source]
d3logpdf_df3(*args, **kwargs)
d3logpdf_dlink3(inv_link_f, y, Y_metadata=None)[source]
dlogpdf_df(f, y, Y_metadata=None)[source]

Evaluates the link function link(f) then computes the derivative of log likelihood using it Uses the Faa di Bruno’s formula for the chain rule

$\frac{d\log p(y|\lambda(f))}{df} = \frac{d\log p(y|\lambda(f))}{d\lambda(f)}\frac{d\lambda(f)}{df}$
Parameters: f (Nx1 array) – latent variables f y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution - not used derivative of log likelihood evaluated for this point 1xN array
dlogpdf_df_dtheta(f, y, Y_metadata=None)[source]

TODO: Doc strings

dlogpdf_dtheta(f, y, Y_metadata=None)[source]

TODO: Doc strings

ep_gradients(Y, cav_tau, cav_v, dL_dKdiag, Y_metadata=None, quad_mode='gk', boost_grad=1.0)[source]
exact_inference_gradients(dL_dKdiag, Y_metadata=None)[source]
static from_dict(input_dict)[source]

Instantiate an object of a derived class using the information in input_dict (built by the to_dict method of the derived class). More specifically, after reading the derived class from input_dict, it calls the method _build_from_input_dict of the derived class. Note: This method should not be overrided in the derived class. In case it is needed, please override _build_from_input_dict instate.

Parameters: input_dict (dict) – Dictionary with all the information needed to instantiate the object.
integrate_gh(Y, mu, sigma, Y_metadata_i=None, gh_points=None)[source]
integrate_gk(Y, mu, sigma, Y_metadata_i=None)[source]
log_predictive_density(y_test, mu_star, var_star, Y_metadata=None)[source]

Calculation of the log predictive density

Parameters: y_test ((Nx1) array) – test observations (y_{*}) mu_star ((Nx1) array) – predictive mean of gaussian p(f_{*}|mu_{*}, var_{*}) var_star ((Nx1) array) – predictive variance of gaussian p(f_{*}|mu_{*}, var_{*})
log_predictive_density_sampling(y_test, mu_star, var_star, Y_metadata=None, num_samples=1000)[source]

Calculation of the log predictive density via sampling

Parameters: y_test ((Nx1) array) – test observations (y_{*}) mu_star ((Nx1) array) – predictive mean of gaussian p(f_{*}|mu_{*}, var_{*}) var_star ((Nx1) array) – predictive variance of gaussian p(f_{*}|mu_{*}, var_{*}) num_samples (int) – num samples of p(f_{*}|mu_{*}, var_{*}) to take
logpdf(f, y, Y_metadata=None)[source]

Evaluates the link function link(f) then computes the log likelihood (log pdf) using it

Parameters: f (Nx1 array) – latent variables f y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution - not used log likelihood evaluated for this point float
logpdf_sum(f, y, Y_metadata=None)[source]

Convenience function that can overridden for functions where this could be computed more efficiently

moments_match_ep(obs, tau, v, Y_metadata_i=None)[source]

Parameters: obs – observed output tau – cavity distribution 1st natural parameter (precision) v – cavity distribution 2nd natural paramenter (mu*precision)
pdf(f, y, Y_metadata=None)[source]

Evaluates the link function link(f) then computes the likelihood (pdf) using it

Parameters: f (Nx1 array) – latent variables f y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution - not used likelihood evaluated for this point float
predictive_mean(mu, variance, Y_metadata=None)[source]

Quadrature calculation of the predictive mean: E(Y_star|Y) = E( E(Y_star|f_star, Y) )

Parameters: mu – mean of posterior sigma – standard deviation of posterior
predictive_quantiles(mu, var, quantiles, Y_metadata=None)[source]
predictive_values(mu, var, full_cov=False, Y_metadata=None)[source]

Compute mean, variance of the predictive distibution.

Parameters: mu – mean of the latent variable, f, of posterior var – variance of the latent variable, f, of posterior full_cov (Boolean) – whether to use the full covariance or just the diagonal
predictive_variance(mu, variance, predictive_mean=None, Y_metadata=None)[source]

Approximation to the predictive variance: V(Y_star)

The following variance decomposition is used: V(Y_star) = E( V(Y_star|f_star)**2 ) + V( E(Y_star|f_star) )**2

Parameters: Predictive_mean: mu – mean of posterior sigma – standard deviation of posterior output’s predictive mean, if None _predictive_mean function will be called.
request_num_latent_functions(Y)[source]

The likelihood should infer how many latent functions are needed for the likelihood

Default is the number of outputs

samples(gp, Y_metadata=None, samples=1)[source]

Returns a set of samples of observations based on a given value of the latent variable.

Parameters: gp – latent variable samples – number of samples to take for each f location
to_dict()[source]
update_gradients(partial)[source]
variational_expectations(Y, m, v, gh_points=None, Y_metadata=None)[source]

E_p(f) [ log p(y|f) ] d/dm E_p(f) [ log p(y|f) ] d/dv E_p(f) [ log p(y|f) ]

where p(f) is a Gaussian with mean m and variance v. The shapes of Y, m and v should match.

if no gh_points are passed, we construct them using defualt options

## GPy.likelihoods.loggaussian module¶

class LogGaussian(gp_link=None, sigma=1.0)[source]
$p(y_{i}|f_{i}, z_{i}) = \prod_{i=1}^{n} (\frac{ry^{r-1}}{\exp{f(x_{i})}})^{1-z_i} (1 + (\frac{y}{\exp(f(x_{i}))})^{r})^{z_i-2}$
d2logpdf_dlink2(link_f, y, Y_metadata=None)[source]


Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ Diagonal of hessian matrix (second derivative of likelihood evaluated at points f) Nx1 array

Note

Will return diagonal of hessian, since every where else it is 0, as the likelihood factorizes over cases (the distribution for y_i depends only on link(f_i) not on link(f_(j!=i))

d2logpdf_dlink2_dtheta(f, y, Y_metadata=None)[source]
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata not used in gaussian derivative of log likelihood evaluated at points link(f) w.r.t variance parameter Nx1 array
d2logpdf_dlink2_dvar(link_f, y, Y_metadata=None)[source]
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata not used in gaussian derivative of log likelihood evaluated at points link(f) w.r.t variance parameter Nx1 array
d3logpdf_dlink3(link_f, y, Y_metadata=None)[source]

Gradient of the log-likelihood function at y given f, w.r.t shape parameter


Parameters: inv_link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ derivative of likelihood evaluated at points f w.r.t variance parameter float

derivative of logpdf wrt link_f param .. math:

:param link_f: latent variables link(f)
:param y: data
:type y: Nx1 array
:param Y_metadata: includes censoring information in dictionary key 'censored'
:returns: likelihood evaluated for this point
:rtype: float

Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata not used in gaussian derivative of log likelihood evaluated at points link(f) w.r.t variance parameter Nx1 array
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata not used in gaussian derivative of log likelihood evaluated at points link(f) w.r.t variance parameter Nx1 array
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata not used in gaussian derivative of log likelihood evaluated at points link(f) w.r.t variance parameter Nx1 array

Gradient of the log-likelihood function at y given f, w.r.t variance parameter


Parameters: inv_link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ derivative of likelihood evaluated at points f w.r.t variance parameter float
Parameters: link_f (Nx1 array) – latent variables (link(f)) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ likelihood evaluated for this point float
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ likelihood evaluated for this point float
samples(gp, Y_metadata=None)[source]

Returns a set of samples of observations based on a given value of the latent variable.

Parameters: gp – latent variable
update_gradients(grads)[source]

Pull out the gradients, be careful as the order must match the order in which the parameters are added

## GPy.likelihoods.loglogistic module¶

class LogLogistic(gp_link=None, r=1.0)[source]
$p(y_{i}|f_{i}, z_{i}) = \prod_{i=1}^{n} (\frac{ry^{r-1}}{\exp{f(x_{i})}})^{1-z_i} (1 + (\frac{y}{\exp(f(x_{i}))})^{r})^{z_i-2}$
d2logpdf_dlink2(link_f, y, Y_metadata=None)[source]


Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ Diagonal of hessian matrix (second derivative of likelihood evaluated at points f) Nx1 array

Note

Will return diagonal of hessian, since every where else it is 0, as the likelihood factorizes over cases (the distribution for y_i depends only on link(f_i) not on link(f_(j!=i))

d2logpdf_dlink2_dr(inv_link_f, y, Y_metadata=None)[source]


Parameters: inv_link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ derivative of hessian evaluated at points f and f_j w.r.t variance parameter Nx1 array
d2logpdf_dlink2_dtheta(f, y, Y_metadata=None)[source]
d3logpdf_dlink3(link_f, y, Y_metadata=None)[source]


Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ third derivative of likelihood evaluated at points f Nx1 array


Parameters: link_f (Nx1 array) – latent variables (f) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ gradient of likelihood evaluated at points Nx1 array

Derivative of the dlogpdf_dlink w.r.t shape parameter


Parameters: inv_link_f (Nx1 array) – latent variables inv_link_f y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ derivative of likelihood evaluated at points f w.r.t variance parameter Nx1 array

Gradient of the log-likelihood function at y given f, w.r.t shape parameter


Parameters: inv_link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ derivative of likelihood evaluated at points f w.r.t variance parameter float


Parameters: link_f (Nx1 array) – latent variables (link(f)) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ likelihood evaluated for this point float


Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ likelihood evaluated for this point float
samples(gp, Y_metadata=None)[source]

Returns a set of samples of observations based on a given value of the latent variable.

Parameters: gp – latent variable
update_gradients(grads)[source]

Pull out the gradients, be careful as the order must match the order in which the parameters are added

## GPy.likelihoods.mixed_noise module¶

class MixedNoise(likelihoods_list, name='mixed_noise')[source]
betaY(Y, Y_metadata)[source]
exact_inference_gradients(dL_dKdiag, Y_metadata)[source]
gaussian_variance(Y_metadata)[source]
predictive_quantiles(mu, var, quantiles, Y_metadata)[source]
predictive_values(mu, var, full_cov=False, Y_metadata=None)[source]

Compute mean, variance of the predictive distibution.

Parameters: mu – mean of the latent variable, f, of posterior var – variance of the latent variable, f, of posterior full_cov (Boolean) – whether to use the full covariance or just the diagonal
predictive_variance(mu, sigma, Y_metadata)[source]

Approximation to the predictive variance: V(Y_star)

The following variance decomposition is used: V(Y_star) = E( V(Y_star|f_star)**2 ) + V( E(Y_star|f_star) )**2

Parameters: Predictive_mean: mu – mean of posterior sigma – standard deviation of posterior output’s predictive mean, if None _predictive_mean function will be called.
samples(gp, Y_metadata)[source]

Returns a set of samples of observations based on a given value of the latent variable.

Parameters: gp – latent variable
to_dict()[source]

Convert the object into a json serializable dictionary.

Note: It uses the private method _save_to_input_dict of the parent.

Return dict: json serializable dictionary containing the needed information to instantiate the object
update_gradients(gradients)[source]

## GPy.likelihoods.multioutput_likelihood module¶

class MultioutputLikelihood(likelihoods_list, name='multioutput_likelihood')[source]

CombinedLikelihood is used to combine different likelihoods for multioutput models, where different outputs have different observation models.

As input the likelihood takes a list of likelihoods used. The likelihood uses “output_index” in Y_metadata to connect observations to likelihoods.

d2logpdf_df2(f, y, Y_metadata)[source]
d2logpdf_df2_dtheta(f, y, Y_metadata=None)[source]

TODO: Doc strings

d2logpdf_dlink2(inv_link_f, y, Y_metadata=None)[source]
d3logpdf_df3(f, y, Y_metadata=None)[source]
d3logpdf_dlink3(inv_link_f, y, Y_metadata=None)[source]
dlogpdf_df(f, y, Y_metadata)[source]

Evaluates the link function link(f) then computes the derivative of log likelihood using it Uses the Faa di Bruno’s formula for the chain rule

$\frac{d\log p(y|\lambda(f))}{df} = \frac{d\log p(y|\lambda(f))}{d\lambda(f)}\frac{d\lambda(f)}{df}$
Parameters: f (Nx1 array) – latent variables f y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution - not used derivative of log likelihood evaluated for this point 1xN array
dlogpdf_df_dtheta(f, y, Y_metadata=None)[source]

TODO: Doc strings

dlogpdf_dtheta(f, y, Y_metadata=None)[source]

TODO: Doc strings

ep_gradients(Y, cav_tau, cav_v, dL_dKdiag, Y_metadata=None, quad_mode='gk', boost_grad=1.0)[source]
exact_inference_gradients(dL_dKdiag, Y_metadata)[source]
log_predictive_density(y_test, mu_star, var_star, Y_metadata=None)[source]

Calculation of the log predictive density

Parameters: y_test ((Nx1) array) – test observations (y_{*}) mu_star ((Nx1) array) – predictive mean of gaussian p(f_{*}|mu_{*}, var_{*}) var_star ((Nx1) array) – predictive variance of gaussian p(f_{*}|mu_{*}, var_{*})
logpdf(f, y, Y_metadata=None)[source]

Evaluates the link function link(f) then computes the log likelihood (log pdf) using it

Parameters: f (Nx1 array) – latent variables f y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution - not used log likelihood evaluated for this point float
moments_match_ep(data_i, tau_i, v_i, Y_metadata_i)[source]

Parameters: obs – observed output tau – cavity distribution 1st natural parameter (precision) v – cavity distribution 2nd natural paramenter (mu*precision)
pdf(f, y, Y_metadata=None)[source]

Evaluates the link function link(f) then computes the likelihood (pdf) using it

Parameters: f (Nx1 array) – latent variables f y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution - not used likelihood evaluated for this point float
predictive_values(mu, var, full_cov=False, Y_metadata=None)[source]

Compute mean, variance of the predictive distibution.

Parameters: mu – mean of the latent variable, f, of posterior var – variance of the latent variable, f, of posterior full_cov (Boolean) – whether to use the full covariance or just the diagonal
predictive_variance(mu, sigma, Y_metadata)[source]

Approximation to the predictive variance: V(Y_star)

The following variance decomposition is used: V(Y_star) = E( V(Y_star|f_star)**2 ) + V( E(Y_star|f_star) )**2

Parameters: Predictive_mean: mu – mean of posterior sigma – standard deviation of posterior output’s predictive mean, if None _predictive_mean function will be called.

## GPy.likelihoods.poisson module¶

class Poisson(gp_link=None)[source]

Poisson likelihood

$p(y_{i}|\lambda(f_{i})) = \frac{\lambda(f_{i})^{y_{i}}}{y_{i}!}e^{-\lambda(f_{i})}$

Note

Y is expected to take values in {0,1,2,…}

conditional_mean(gp)[source]

The mean of the random variable conditioned on one value of the GP

conditional_variance(gp)[source]

The variance of the random variable conditioned on one value of the GP

d2logpdf_dlink2(link_f, y, Y_metadata=None)[source]

$\frac{d^{2} \ln p(y_{i}|\lambda(f_{i}))}{d^{2}\lambda(f)} = \frac{-y_{i}}{\lambda(f_{i})^{2}}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in poisson distribution Diagonal of hessian matrix (second derivative of likelihood evaluated at points f) Nx1 array

Note

Will return diagonal of hessian, since every where else it is 0, as the likelihood factorizes over cases (the distribution for y_i depends only on link(f_i) not on link(f_(j!=i))

d3logpdf_dlink3(link_f, y, Y_metadata=None)[source]

$\frac{d^{3} \ln p(y_{i}|\lambda(f_{i}))}{d^{3}\lambda(f)} = \frac{2y_{i}}{\lambda(f_{i})^{3}}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in poisson distribution third derivative of likelihood evaluated at points f Nx1 array

$\frac{d \ln p(y_{i}|\lambda(f_{i}))}{d\lambda(f)} = \frac{y_{i}}{\lambda(f_{i})} - 1$
Parameters: link_f (Nx1 array) – latent variables (f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in poisson distribution gradient of likelihood evaluated at points Nx1 array

$\ln p(y_{i}|\lambda(f_{i})) = -\lambda(f_{i}) + y_{i}\log \lambda(f_{i}) - \log y_{i}!$
Parameters: link_f (Nx1 array) – latent variables (link(f)) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in poisson distribution likelihood evaluated for this point float

$p(y_{i}|\lambda(f_{i})) = \frac{\lambda(f_{i})^{y_{i}}}{y_{i}!}e^{-\lambda(f_{i})}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in poisson distribution likelihood evaluated for this point float
samples(gp, Y_metadata=None)[source]

Returns a set of samples of observations based on a given value of the latent variable.

Parameters: gp – latent variable

## GPy.likelihoods.student_t module¶

class StudentT(gp_link=None, deg_free=5, sigma2=2)[source]

Student T likelihood

For nomanclature see Bayesian Data Analysis 2003 p576

$p(y_{i}|\lambda(f_{i})) = \frac{\Gamma\left(\frac{v+1}{2}\right)}{\Gamma\left(\frac{v}{2}\right)\sqrt{v\pi\sigma^{2}}}\left(1 + \frac{1}{v}\left(\frac{(y_{i} - f_{i})^{2}}{\sigma^{2}}\right)\right)^{\frac{-v+1}{2}}$
conditional_mean(gp)[source]

The mean of the random variable conditioned on one value of the GP

conditional_variance(gp)[source]

The variance of the random variable conditioned on one value of the GP

d2logpdf_dlink2(inv_link_f, y, Y_metadata=None)[source]

$\frac{d^{2} \ln p(y_{i}|\lambda(f_{i}))}{d^{2}\lambda(f)} = \frac{(v+1)((y_{i}-\lambda(f_{i}))^{2} - \sigma^{2}v)}{((y_{i}-\lambda(f_{i}))^{2} + \sigma^{2}v)^{2}}$
Parameters: inv_link_f (Nx1 array) – latent variables inv_link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution Diagonal of hessian matrix (second derivative of likelihood evaluated at points f) Nx1 array

Note

Will return diagonal of hessian, since every where else it is 0, as the likelihood factorizes over cases (the distribution for y_i depends only on link(f_i) not on link(f_(j!=i))

d2logpdf_dlink2_dtheta(f, y, Y_metadata=None)[source]
d2logpdf_dlink2_dv(inv_link_f, y, Y_metadata=None)[source]
d2logpdf_dlink2_dvar(inv_link_f, y, Y_metadata=None)[source]

$\frac{d}{d\sigma^{2}}(\frac{d^{2} \ln p(y_{i}|\lambda(f_{i}))}{d^{2}f}) = \frac{v(v+1)(\sigma^{2}v - 3(y_{i} - \lambda(f_{i}))^{2})}{(\sigma^{2}v + (y_{i} - \lambda(f_{i}))^{2})^{3}}$
Parameters: inv_link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution derivative of hessian evaluated at points f and f_j w.r.t variance parameter Nx1 array
d3logpdf_dlink3(inv_link_f, y, Y_metadata=None)[source]

$\frac{d^{3} \ln p(y_{i}|\lambda(f_{i}))}{d^{3}\lambda(f)} = \frac{-2(v+1)((y_{i} - \lambda(f_{i}))^3 - 3(y_{i} - \lambda(f_{i})) \sigma^{2} v))}{((y_{i} - \lambda(f_{i})) + \sigma^{2} v)^3}$
Parameters: inv_link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution third derivative of likelihood evaluated at points f Nx1 array

$\frac{d \ln p(y_{i}|\lambda(f_{i}))}{d\lambda(f)} = \frac{(v+1)(y_{i}-\lambda(f_{i}))}{(y_{i}-\lambda(f_{i}))^{2} + \sigma^{2}v}$
Parameters: inv_link_f (Nx1 array) – latent variables (f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution gradient of likelihood evaluated at points Nx1 array

Derivative of the dlogpdf_dlink w.r.t variance parameter (t_noise)

$\frac{d}{d\sigma^{2}}(\frac{d \ln p(y_{i}|\lambda(f_{i}))}{df}) = \frac{-2\sigma v(v + 1)(y_{i}-\lambda(f_{i}))}{(y_{i}-\lambda(f_{i}))^2 + \sigma^2 v)^2}$
Parameters: inv_link_f (Nx1 array) – latent variables inv_link_f y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution derivative of likelihood evaluated at points f w.r.t variance parameter Nx1 array

Gradient of the log-likelihood function at y given f, w.r.t variance parameter (t_noise)

$\frac{d \ln p(y_{i}|\lambda(f_{i}))}{d\sigma^{2}} = \frac{v((y_{i} - \lambda(f_{i}))^{2} - \sigma^{2})}{2\sigma^{2}(\sigma^{2}v + (y_{i} - \lambda(f_{i}))^{2})}$
Parameters: inv_link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution derivative of likelihood evaluated at points f w.r.t variance parameter float

$\ln p(y_{i}|\lambda(f_{i})) = \ln \Gamma\left(\frac{v+1}{2}\right) - \ln \Gamma\left(\frac{v}{2}\right) - \ln \sqrt{v \pi\sigma^{2}} - \frac{v+1}{2}\ln \left(1 + \frac{1}{v}\left(\frac{(y_{i} - \lambda(f_{i}))^{2}}{\sigma^{2}}\right)\right)$
Parameters: inv_link_f (Nx1 array) – latent variables (link(f)) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution likelihood evaluated for this point float

$p(y_{i}|\lambda(f_{i})) = \frac{\Gamma\left(\frac{v+1}{2}\right)}{\Gamma\left(\frac{v}{2}\right)\sqrt{v\pi\sigma^{2}}}\left(1 + \frac{1}{v}\left(\frac{(y_{i} - \lambda(f_{i}))^{2}}{\sigma^{2}}\right)\right)^{\frac{-v+1}{2}}$
Parameters: inv_link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in student t distribution likelihood evaluated for this point float
predictive_mean(mu, sigma, Y_metadata=None)[source]

Quadrature calculation of the predictive mean: E(Y_star|Y) = E( E(Y_star|f_star, Y) )

Parameters: mu – mean of posterior sigma – standard deviation of posterior
predictive_variance(mu, variance, predictive_mean=None, Y_metadata=None)[source]

Approximation to the predictive variance: V(Y_star)

The following variance decomposition is used: V(Y_star) = E( V(Y_star|f_star)**2 ) + V( E(Y_star|f_star) )**2

Parameters: Predictive_mean: mu – mean of posterior sigma – standard deviation of posterior output’s predictive mean, if None _predictive_mean function will be called.
samples(gp, Y_metadata=None)[source]

Returns a set of samples of observations based on a given value of the latent variable.

Parameters: gp – latent variable
update_gradients(grads)[source]

Pull out the gradients, be careful as the order must match the order in which the parameters are added

## GPy.likelihoods.weibull module¶

class Weibull(gp_link=None, beta=1.0)[source]

Implementing Weibull likelihood function …

d2logpdf_dlink2(link_f, y, Y_metadata=None)[source]

$\begin{split}\frac{d^{2} \ln p(y_{i}|\lambda(f_{i}))}{d^{2}\lambda(f)} = -\beta^{2}\frac{d\Psi(\alpha_{i})}{d\alpha_{i}}\\ \alpha_{i} = \beta y_{i}\end{split}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in gamma distribution Diagonal of hessian matrix (second derivative of likelihood evaluated at points f) Nx1 array

Note

Will return diagonal of hessian, since every where else it is 0, as the likelihood factorizes over cases (the distribution for y_i depends only on link(f_i) not on link(f_(j!=i))

d2logpdf_dlink2_dr(link_f, y, Y_metadata=None)[source]

Derivative of hessian of loglikelihood wrt r-shape parameter. :param link_f: :param y: :param Y_metadata: :return:

d2logpdf_dlink2_dtheta(f, y, Y_metadata=None)[source]
Parameters: f – y – Y_metadata –
d3logpdf_dlink3(link_f, y, Y_metadata=None)[source]

$\begin{split}\frac{d^{3} \ln p(y_{i}|\lambda(f_{i}))}{d^{3}\lambda(f)} = -\beta^{3}\frac{d^{2}\Psi(\alpha_{i})}{d\alpha_{i}}\\ \alpha_{i} = \beta y_{i}\end{split}$
Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in gamma distribution third derivative of likelihood evaluated at points f Nx1 array
d3logpdf_dlink3_dr(link_f, y, Y_metadata=None)[source]

$\begin{split}\frac{d \ln p(y_{i}|\lambda(f_{i}))}{d\lambda(f)} = \beta (\log \beta y_{i}) - \Psi(\alpha_{i})\beta\\ \alpha_{i} = \beta y_{i}\end{split}$
Parameters: link_f (Nx1 array) – latent variables (f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in gamma distribution gradient of likelihood evaluated at points Nx1 array

First order derivative derivative of loglikelihood wrt r:shape parameter

Parameters: link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in gamma distribution third derivative of likelihood evaluated at points f Nx1 array
Parameters: f – y – Y_metadata –

Gradient of the log-likelihood function at y given f, w.r.t shape parameter


Parameters: inv_link_f (Nx1 array) – latent variables link(f) y (Nx1 array) – data Y_metadata – includes censoring information in dictionary key ‘censored’ derivative of likelihood evaluated at points f w.r.t variance parameter float
Parameters: f – y – Y_metadata –
exact_inference_gradients(dL_dKdiag, Y_metadata=None)[source]

$\begin{split}\ln p(y_{i}|\lambda(f_{i})) = \alpha_{i}\log \beta - \log \Gamma(\alpha_{i}) + (\alpha_{i} - 1)\log y_{i} - \beta y_{i}\\ \alpha_{i} = \beta y_{i}\end{split}$
Parameters: link_f (Nx1 array) – latent variables (link(f)) y (Nx1 array) – data Y_metadata – Y_metadata which is not used in poisson distribution likelihood evaluated for this point float

samples(gp, Y_metadata=None)[source]
update_gradients(grads)[source]