Likelihood Classes

Bernoulli Bernoulli likelihood class for (binary) classification tasks.
Binomial Binomial likelihood class.
Gaussian([var, bounds, shape]) A univariate Gaussian likelihood for general regression tasks.
Poisson([tranfcn]) A Poisson likelihood, useful for various Poisson process tasks.

Likelihood objects for inference within the GLM framework.

class revrand.likelihoods.Bernoulli

Bernoulli likelihood class for (binary) classification tasks.

A logistic transformation function is used to map the latent function from the GLM prior into a probability.

p(yi|fi)=σ(fi)yi(1σ(fi))1yi

where yi is a target, fi the value of the latent function corresponding to the target, and σ() is the logistic sigmoid.

Ey(f)

Expected value of the Bernoulli likelihood.

Parameters:f (ndarray) – latent function from the GLM prior (f=Φw)
Returns:Ey – expected value of y, E[y|f].
Return type:ndarray
cdf(y, f)

Cumulative density function of the likelihood.

Parameters:
  • y (ndarray) – query quantiles, i.e. P(Yy).
  • f (ndarray) – latent function from the GLM prior (f=Φw)
Returns:

cdf – Cumulative density function evaluated at y.

Return type:

ndarray

df(y, f)

Derivative of Bernoulli log likelihood w.r.t. f.

Parameters:
  • y (ndarray) – array of 0, 1 valued integers of targets
  • f (ndarray) – latent function from the GLM prior (f=Φw)
Returns:

df – the derivative logp(y|f)/f

Return type:

ndarray

dp(y, f, *args)

Derivative of Bernoulli log likelihood w.r.t.the parameters, θ.

Parameters:
  • y (ndarray) – array of 0, 1 valued integers of targets
  • f (ndarray) – latent function from the GLM prior (f=Φw)
Returns:

dp – the derivative logp(y|f,θ)/θ for each parameter. If there is only one parameter, this is not a list.

Return type:

list, float or ndarray

loglike(y, f)

Bernoulli log likelihood.

Parameters:
  • y (ndarray) – array of 0, 1 valued integers of targets
  • f (ndarray) – latent function from the GLM prior (f=Φw)
Returns:

logp – the log likelihood of each y given each f under this likelihood.

Return type:

ndarray

params

Get this object’s Parameter types.

class revrand.likelihoods.Binomial

Binomial likelihood class.

A logistic transformation function is used to map the latent function from the GLM prior into a probability.

p(yi|fi)=(nyi)σ(fi)yi(1σ(fi))nyi

where yi is a target, fi the value of the latent function corresponding to the target, n is the total possible count, and σ() is the logistic sigmoid. n can also be applied per observation.

Ey(f, n)

Expected value of the Binomial likelihood.

Parameters:
  • f (ndarray) – latent function from the GLM prior (f=Φw)
  • n (ndarray) – the total number of observations
Returns:

Ey – expected value of y, E[y|f].

Return type:

ndarray

cdf(y, f, n)

Cumulative density function of the likelihood.

Parameters:
  • y (ndarray) – query quantiles, i.e. P(Yy).
  • f (ndarray) – latent function from the GLM prior (f=Φw)
  • n (ndarray) – the total number of observations
Returns:

cdf – Cumulative density function evaluated at y.

Return type:

ndarray

df(y, f, n)

Derivative of Binomial log likelihood w.r.t. f.

Parameters:
  • y (ndarray) – array of 0, 1 valued integers of targets
  • f (ndarray) – latent function from the GLM prior (f=Φw)
  • n (ndarray) – the total number of observations
Returns:

df – the derivative logp(y|f)/f

Return type:

ndarray

loglike(y, f, n)

Binomial log likelihood.

Parameters:
  • y (ndarray) – array of 0, 1 valued integers of targets
  • f (ndarray) – latent function from the GLM prior (f=Φw)
  • n (ndarray) – the total number of observations
Returns:

logp – the log likelihood of each y given each f under this likelihood.

Return type:

ndarray

class revrand.likelihoods.Gaussian(var=Parameter(value=1.0, bounds=Positive(upper=None), shape=()))

A univariate Gaussian likelihood for general regression tasks.

No transformation function is needed since this is (conditionally) conjugate to the GLM prior.

p(yi|fi)=12πσ2exp((yifi)22σ2)

where yi is a target, fi the value of the latent function corresponding to the target and σ is the observation noise (standard deviation).

Parameters:var (Parameter, optional) – A scalar Parameter describing the initial point and bounds for an optimiser to learn the variance parameter of this object.
Ey(f, var)

Expected value of the Gaussian likelihood.

Parameters:
  • f (ndarray) – latent function from the GLM prior (f=Φw)
  • var (float, ndarray, optional) – The variance of the distribution, if not input, the initial value of variance is used.
Returns:

Ey – expected value of y, E[y|f].

Return type:

ndarray

cdf(y, f, var)

Cumulative density function of the likelihood.

Parameters:
  • y (ndarray) – query quantiles, i.e. P(Yy).
  • f (ndarray) – latent function from the GLM prior (f=Φw)
  • var (float, ndarray, optional) – The variance of the distribution, if not input, the initial value of variance is used.
Returns:

cdf – Cumulative density function evaluated at y.

Return type:

ndarray

df(y, f, var)

Derivative of Gaussian log likelihood w.r.t. f.

Parameters:
  • y (ndarray) – array of 0, 1 valued integers of targets
  • f (ndarray) – latent function from the GLM prior (f=Φw)
  • var (float, ndarray, optional) – The variance of the distribution, if not input, the initial value of variance is used.
Returns:

df – the derivative logp(y|f)/f

Return type:

ndarray

dp(y, f, var)

Derivative of Gaussian log likelihood w.r.t.the variance σ2.

Parameters:
  • y (ndarray) – array of 0, 1 valued integers of targets
  • f (ndarray) – latent function from the GLM prior (f=Φw)
  • var (float, ndarray, optional) – The variance of the distribution, if not input, the initial value of variance is used.
Returns:

dp – the derivative logp(y|f,σ2)/σ2 where sigma2 is the variance.

Return type:

float

loglike(y, f, var=None)

Gaussian log likelihood.

Parameters:
  • y (ndarray) – array of 0, 1 valued integers of targets
  • f (ndarray) – latent function from the GLM prior (f=Φw)
  • var (float, ndarray, optional) – The variance of the distribution, if not input, the initial value of variance is used.
Returns:

logp – the log likelihood of each y given each f under this likelihood.

Return type:

ndarray

class revrand.likelihoods.Poisson(tranfcn='exp')

A Poisson likelihood, useful for various Poisson process tasks.

An exponential transformation function and a softplus transformation function have been implemented.

p(yi|fi)=g(fi)yieg(fi)yi!

where yi is a target, fi the value of the latent function corresponding to the target, and g() is the tranformation function, which can be either an exponential function, or a softplus function (log(1+exp(fi)).

Parameters:tranfcn (string, optional) – this may be ‘exp’ for an exponential transformation function, or ‘softplus’ for a softplut transformation function.
Ey(f)

Expected value of the Poisson likelihood.

Parameters:f (ndarray) – latent function from the GLM prior (f=Φw)
Returns:Ey – expected value of y, E[y|f].
Return type:ndarray
cdf(y, f)

Cumulative density function of the likelihood.

Parameters:
  • y (ndarray) – query quantiles, i.e. P(Yy).
  • f (ndarray) – latent function from the GLM prior (f=Φw)
Returns:

cdf – Cumulative density function evaluated at y.

Return type:

ndarray

df(y, f)

Derivative of Poisson log likelihood w.r.t. f.

Parameters:
  • y (ndarray) – array of 0, 1 valued integers of targets
  • f (ndarray) – latent function from the GLM prior (f=Φw)
Returns:

df – the derivative logp(y|f)/f

Return type:

ndarray

loglike(y, f)

Poisson log likelihood.

Parameters:
  • y (ndarray) – array of integer targets
  • f (ndarray) – latent function from the GLM prior (f=Φw)
Returns:

logp – the log likelihood of each y given each f under this likelihood.

Return type:

ndarray