Likelihoods
AbstractLikelihood
AbstractLikelihood(
num_datapoints: int,
integrator: AbstractIntegrator = GHQuadratureIntegrator(),
)
Bases: Module
Abstract base class for likelihoods.
All likelihoods must inherit from this class and implement the predict and
link_function methods.
Parameters:
-
num_datapoints(int) βthe number of data points.
-
integrator(AbstractIntegrator, default:GHQuadratureIntegrator()) βThe integrator to be used for computing expected log likelihoods. Must be an instance of
AbstractIntegrator.
__call__
Evaluate the likelihood function at a given predictive distribution.
Parameters:
-
dist(Union[MultivariateNormal, GaussianDistribution]) βThe predictive distribution to evaluate the likelihood at.
Returns:
-
DistributionβThe predictive distribution.
predict
abstractmethod
Evaluate the likelihood function at a given predictive distribution.
Parameters:
-
dist(Union[MultivariateNormal, GaussianDistribution]) βThe predictive distribution to evaluate the likelihood at.
Returns:
-
Distributionβnpd.Distribution: The predictive distribution.
link_function
abstractmethod
Return the link function of the likelihood function.
Parameters:
-
f(Float[Array, '...']) βthe latent Gaussian process values.
Returns:
-
Distributionβnpd.Distribution: The distribution of observations, y, given values of the Gaussian process, f.
expected_log_likelihood
expected_log_likelihood(
y: Float[Array, "N D"],
mean: Float[Array, "N D"],
variance: Float[Array, "N D"],
mean_g: Optional[Float[Array, "N D"]] = None,
variance_g: Optional[Float[Array, "N D"]] = None,
**_: Any,
) -> Float[Array, " N"]
Compute the expected log likelihood.
For a variational distribution and a likelihood , compute the expected log likelihood:
Parameters:
-
y(Float[Array, 'N D']) βThe observed response variable.
-
mean(Float[Array, 'N D']) βThe variational mean.
-
variance(Float[Array, 'N D']) βThe variational variance.
-
mean_g(Float[Array, 'N D'], default:None) βOptional moments of the latent noise process for heteroscedastic likelihoods.
-
variance_g(Float[Array, 'N D'], default:None) βOptional moments of the latent noise process for heteroscedastic likelihoods.
-
**_(Any, default:{}) βUnused extra arguments for compatibility with specialised likelihoods.
Returns:
-
ScalarFloat(Float[Array, ' N']) βThe expected log likelihood.
AbstractNoiseTransform
Bases: Module
Abstract base class for noise transformations.
LogNormalTransform
SoftplusTransform
AbstractHeteroscedasticLikelihood
AbstractHeteroscedasticLikelihood(
num_datapoints: int,
noise_prior: Prior,
noise_transform: Union[
AbstractNoiseTransform,
Callable[[Float[Array, ...]], Float[Array, ...]],
] = SoftplusTransform(),
integrator: AbstractIntegrator = GHQuadratureIntegrator(),
)
Bases: AbstractLikelihood
Base class for heteroscedastic likelihoods with latent noise processes.
supports_tight_bound
Return whether the tighter bound from LΓ‘zaro-Gredilla & Titsias (2011) is applicable.
noise_statistics
Moment matching of the transformed noise process.
Parameters:
-
mean(Float[Array, 'N D']) βMean of the latent noise GP.
-
variance(Float[Array, 'N D']) βVariance of the latent noise GP.
Returns:
-
NoiseMoments(NoiseMoments) βExpected log variance, inverse variance, and variance.
predict
abstractmethod
Evaluate the likelihood function at a given predictive distribution.
Parameters:
-
dist(Union[MultivariateNormal, GaussianDistribution]) βThe predictive distribution to evaluate the likelihood at.
Returns:
-
Distributionβnpd.Distribution: The predictive distribution.
link_function
abstractmethod
Return the link function of the likelihood function.
Parameters:
-
f(Float[Array, '...']) βthe latent Gaussian process values.
Returns:
-
Distributionβnpd.Distribution: The distribution of observations, y, given values of the Gaussian process, f.
Gaussian
Gaussian(
num_datapoints: int,
obs_stddev: Union[
ScalarFloat, Float[Array, "#N"], NonNegativeReal
] = 1.0,
integrator: AbstractIntegrator = AnalyticalGaussianIntegrator(),
)
Bases: AbstractLikelihood
Gaussian likelihood object.
Parameters:
-
num_datapoints(int) βthe number of data points.
-
obs_stddev(Union[ScalarFloat, Float[Array, '#N']], default:1.0) βthe standard deviation of the Gaussian observation noise.
-
integrator(AbstractIntegrator, default:AnalyticalGaussianIntegrator()) βThe integrator to be used for computing expected log likelihoods. Must be an instance of
AbstractIntegrator. For the Gaussian likelihood, this defaults to theAnalyticalGaussianIntegrator, as the expected log likelihood can be computed analytically.
link_function
The link function of the Gaussian likelihood.
Parameters:
-
f(Float[Array, '...']) βFunction values.
Returns:
-
Normalβnpd.Normal: The likelihood function.
predict
Evaluate the Gaussian likelihood.
Evaluate the Gaussian likelihood function at a given predictive distribution. Computationally, this is equivalent to summing the observation noise term to the diagonal elements of the predictive distribution's covariance matrix.
Parameters:
-
dist(Distribution) βThe Gaussian process posterior, evaluated at a finite set of test points.
Returns:
-
MultivariateNormalβnpd.Distribution: The predictive distribution.
noise_vector
Per-observation noise variance vector (scalar broadcast for single-output).
prepare_targets
prepare_targets(
y: Float[Array, "N 1"], mx: Float[Array, "N 1"]
) -> tuple[Float[Array, "N 1"], Float[Array, "N 1"]]
Return targets and mean in the format expected by the unified predict/MLL path.
__call__
Evaluate the likelihood function at a given predictive distribution.
Parameters:
-
dist(Union[MultivariateNormal, GaussianDistribution]) βThe predictive distribution to evaluate the likelihood at.
Returns:
-
DistributionβThe predictive distribution.
expected_log_likelihood
expected_log_likelihood(
y: Float[Array, "N D"],
mean: Float[Array, "N D"],
variance: Float[Array, "N D"],
mean_g: Optional[Float[Array, "N D"]] = None,
variance_g: Optional[Float[Array, "N D"]] = None,
**_: Any,
) -> Float[Array, " N"]
Compute the expected log likelihood.
For a variational distribution and a likelihood , compute the expected log likelihood:
Parameters:
-
y(Float[Array, 'N D']) βThe observed response variable.
-
mean(Float[Array, 'N D']) βThe variational mean.
-
variance(Float[Array, 'N D']) βThe variational variance.
-
mean_g(Float[Array, 'N D'], default:None) βOptional moments of the latent noise process for heteroscedastic likelihoods.
-
variance_g(Float[Array, 'N D'], default:None) βOptional moments of the latent noise process for heteroscedastic likelihoods.
-
**_(Any, default:{}) βUnused extra arguments for compatibility with specialised likelihoods.
Returns:
-
ScalarFloat(Float[Array, ' N']) βThe expected log likelihood.
MultiOutputGaussian
MultiOutputGaussian(
num_datapoints: int,
num_outputs: int,
obs_stddev: Union[float, Float[Array, " P"]] = 1.0,
)
Bases: Gaussian
Gaussian likelihood with per-output noise variance.
Parameters:
-
num_datapoints(int) βTotal number of observations (N, not N*P).
-
num_outputs(int) βNumber of output dimensions (P).
-
obs_stddev(Union[float, Float[Array, ' P']], default:1.0) βPer-output noise standard deviation. Scalar broadcasts to [P].
noise_vector
Per-observation noise variance in output-major (Kronecker) order.
Returns sigma_p^2 with each output's variance repeated N times, concatenated across outputs: [ΟβΒ²...ΟβΒ², ΟβΒ²...ΟβΒ², ...].
prepare_targets
prepare_targets(
y: Float[Array, "N P"], mx: Float[Array, "N 1"]
) -> tuple[Float[Array, "NP 1"], Float[Array, "NP 1"]]
Reshape multi-output targets to output-major long format.
__call__
Evaluate the likelihood function at a given predictive distribution.
Parameters:
-
dist(Union[MultivariateNormal, GaussianDistribution]) βThe predictive distribution to evaluate the likelihood at.
Returns:
-
DistributionβThe predictive distribution.
predict
Evaluate the Gaussian likelihood.
Evaluate the Gaussian likelihood function at a given predictive distribution. Computationally, this is equivalent to summing the observation noise term to the diagonal elements of the predictive distribution's covariance matrix.
Parameters:
-
dist(Distribution) βThe Gaussian process posterior, evaluated at a finite set of test points.
Returns:
-
MultivariateNormalβnpd.Distribution: The predictive distribution.
link_function
The link function of the Gaussian likelihood.
Parameters:
-
f(Float[Array, '...']) βFunction values.
Returns:
-
Normalβnpd.Normal: The likelihood function.
expected_log_likelihood
expected_log_likelihood(
y: Float[Array, "N D"],
mean: Float[Array, "N D"],
variance: Float[Array, "N D"],
mean_g: Optional[Float[Array, "N D"]] = None,
variance_g: Optional[Float[Array, "N D"]] = None,
**_: Any,
) -> Float[Array, " N"]
Compute the expected log likelihood.
For a variational distribution and a likelihood , compute the expected log likelihood:
Parameters:
-
y(Float[Array, 'N D']) βThe observed response variable.
-
mean(Float[Array, 'N D']) βThe variational mean.
-
variance(Float[Array, 'N D']) βThe variational variance.
-
mean_g(Float[Array, 'N D'], default:None) βOptional moments of the latent noise process for heteroscedastic likelihoods.
-
variance_g(Float[Array, 'N D'], default:None) βOptional moments of the latent noise process for heteroscedastic likelihoods.
-
**_(Any, default:{}) βUnused extra arguments for compatibility with specialised likelihoods.
Returns:
-
ScalarFloat(Float[Array, ' N']) βThe expected log likelihood.
Bernoulli
Bases: AbstractLikelihood
Parameters:
-
num_datapoints(int) βthe number of data points.
-
integrator(AbstractIntegrator, default:GHQuadratureIntegrator()) βThe integrator to be used for computing expected log likelihoods. Must be an instance of
AbstractIntegrator.
link_function
The probit link function of the Bernoulli likelihood.
Parameters:
-
f(Float[Array, '...']) βFunction values.
Returns:
-
BernoulliProbsβnpd.Bernoulli: The likelihood function.
predict
Evaluate the pointwise predictive distribution.
Evaluate the pointwise predictive distribution, given a Gaussian process posterior and likelihood parameters.
Parameters:
-
dist([npd.MultivariateNormal, GaussianDistribution].) βThe Gaussian process posterior, evaluated at a finite set of test points.
Returns:
-
BernoulliProbsβnpd.Bernoulli: The pointwise predictive distribution.
__call__
Evaluate the likelihood function at a given predictive distribution.
Parameters:
-
dist(Union[MultivariateNormal, GaussianDistribution]) βThe predictive distribution to evaluate the likelihood at.
Returns:
-
DistributionβThe predictive distribution.
expected_log_likelihood
expected_log_likelihood(
y: Float[Array, "N D"],
mean: Float[Array, "N D"],
variance: Float[Array, "N D"],
mean_g: Optional[Float[Array, "N D"]] = None,
variance_g: Optional[Float[Array, "N D"]] = None,
**_: Any,
) -> Float[Array, " N"]
Compute the expected log likelihood.
For a variational distribution and a likelihood , compute the expected log likelihood:
Parameters:
-
y(Float[Array, 'N D']) βThe observed response variable.
-
mean(Float[Array, 'N D']) βThe variational mean.
-
variance(Float[Array, 'N D']) βThe variational variance.
-
mean_g(Float[Array, 'N D'], default:None) βOptional moments of the latent noise process for heteroscedastic likelihoods.
-
variance_g(Float[Array, 'N D'], default:None) βOptional moments of the latent noise process for heteroscedastic likelihoods.
-
**_(Any, default:{}) βUnused extra arguments for compatibility with specialised likelihoods.
Returns:
-
ScalarFloat(Float[Array, ' N']) βThe expected log likelihood.
Poisson
Bases: AbstractLikelihood
Parameters:
-
num_datapoints(int) βthe number of data points.
-
integrator(AbstractIntegrator, default:GHQuadratureIntegrator()) βThe integrator to be used for computing expected log likelihoods. Must be an instance of
AbstractIntegrator.
link_function
The link function of the Poisson likelihood.
Parameters:
-
f(Float[Array, '...']) βFunction values.
Returns:
-
Poissonβnpd.Poisson: The likelihood function.
predict
Evaluate the pointwise predictive distribution.
Evaluate the pointwise predictive distribution, given a Gaussian process posterior and likelihood parameters.
Parameters:
-
dist(Union[MultivariateNormal, GaussianDistribution]) βThe Gaussian process posterior, evaluated at a finite set of test points.
Returns:
-
Poissonβnpd.Poisson: The pointwise predictive distribution.
__call__
Evaluate the likelihood function at a given predictive distribution.
Parameters:
-
dist(Union[MultivariateNormal, GaussianDistribution]) βThe predictive distribution to evaluate the likelihood at.
Returns:
-
DistributionβThe predictive distribution.
expected_log_likelihood
expected_log_likelihood(
y: Float[Array, "N D"],
mean: Float[Array, "N D"],
variance: Float[Array, "N D"],
mean_g: Optional[Float[Array, "N D"]] = None,
variance_g: Optional[Float[Array, "N D"]] = None,
**_: Any,
) -> Float[Array, " N"]
Compute the expected log likelihood.
For a variational distribution and a likelihood , compute the expected log likelihood:
Parameters:
-
y(Float[Array, 'N D']) βThe observed response variable.
-
mean(Float[Array, 'N D']) βThe variational mean.
-
variance(Float[Array, 'N D']) βThe variational variance.
-
mean_g(Float[Array, 'N D'], default:None) βOptional moments of the latent noise process for heteroscedastic likelihoods.
-
variance_g(Float[Array, 'N D'], default:None) βOptional moments of the latent noise process for heteroscedastic likelihoods.
-
**_(Any, default:{}) βUnused extra arguments for compatibility with specialised likelihoods.
Returns:
-
ScalarFloat(Float[Array, ' N']) βThe expected log likelihood.