Likelihoods
gpjax.likelihoods
tfb = tfp.bijectors
module-attribute
tfd = tfp.distributions
module-attribute
NonGaussian = Union[Poisson, Bernoulli]
module-attribute
__all__ = ['AbstractLikelihood', 'NonGaussian', 'Gaussian', 'Bernoulli', 'Poisson', 'inv_probit']
module-attribute
AbstractLikelihood
dataclass
Bases: Module
Abstract base class for likelihoods.
num_datapoints: int = static_field()
class-attribute
instance-attribute
integrator: AbstractIntegrator = static_field(GHQuadratureIntegrator())
class-attribute
instance-attribute
__init_subclass__(mutable: bool = False)
replace(**kwargs: Any) -> Self
replace_meta(**kwargs: Any) -> Self
update_meta(**kwargs: Any) -> Self
replace_trainable(**kwargs: Dict[str, bool]) -> Self
Replace the trainability status of local nodes of the Module.
replace_bijector(**kwargs: Dict[str, tfb.Bijector]) -> Self
Replace the bijectors of local nodes of the Module.
constrain() -> Self
unconstrain() -> Self
stop_gradient() -> Self
trainables() -> Self
__init__(num_datapoints: int = static_field(), integrator: AbstractIntegrator = static_field(GHQuadratureIntegrator())) -> None
__call__(*args: Any, **kwargs: Any) -> tfd.Distribution
Evaluate the likelihood function at a given predictive distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Arguments to be passed to the likelihood's |
()
|
**kwargs |
Any
|
Keyword arguments to be passed to the likelihood's
|
{}
|
Returns
tfd.Distribution: The predictive distribution.
predict(*args: Any, **kwargs: Any) -> tfd.Distribution
abstractmethod
Evaluate the likelihood function at a given predictive distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Arguments to be passed to the likelihood's |
()
|
**kwargs |
Any
|
Keyword arguments to be passed to the likelihood's
|
{}
|
Returns
tfd.Distribution: The predictive distribution.
link_function(f: Float[Array, ...]) -> tfd.Distribution
abstractmethod
expected_log_likelihood(y: Float[Array, 'N D'], mean: Float[Array, 'N D'], variance: Float[Array, 'N D']) -> Float[Array, ' N']
Compute the expected log likelihood.
For a variational distribution and a likelihood , compute the expected log likelihood:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y |
Float[Array, 'N D']
|
The observed response variable. |
required |
mean |
Float[Array, 'N D']
|
The variational mean. |
required |
variance |
Float[Array, 'N D']
|
The variational variance. |
required |
Returns:
Name | Type | Description |
---|---|---|
ScalarFloat |
Float[Array, ' N']
|
The expected log likelihood. |
Gaussian
dataclass
Bases: AbstractLikelihood
Gaussian likelihood object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obs_stddev |
Union[ScalarFloat, Float[Array, '#N']]
|
the standard deviation of the Gaussian observation noise. |
param_field(array(1.0), bijector=Softplus())
|
num_datapoints: int = static_field()
class-attribute
instance-attribute
obs_stddev: Union[ScalarFloat, Float[Array, '#N']] = param_field(jnp.array(1.0), bijector=tfb.Softplus())
class-attribute
instance-attribute
integrator: AbstractIntegrator = static_field(AnalyticalGaussianIntegrator())
class-attribute
instance-attribute
__init_subclass__(mutable: bool = False)
replace(**kwargs: Any) -> Self
replace_meta(**kwargs: Any) -> Self
update_meta(**kwargs: Any) -> Self
replace_trainable(**kwargs: Dict[str, bool]) -> Self
Replace the trainability status of local nodes of the Module.
replace_bijector(**kwargs: Dict[str, tfb.Bijector]) -> Self
Replace the bijectors of local nodes of the Module.
constrain() -> Self
unconstrain() -> Self
stop_gradient() -> Self
trainables() -> Self
__call__(*args: Any, **kwargs: Any) -> tfd.Distribution
Evaluate the likelihood function at a given predictive distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Arguments to be passed to the likelihood's |
()
|
**kwargs |
Any
|
Keyword arguments to be passed to the likelihood's
|
{}
|
Returns
tfd.Distribution: The predictive distribution.
expected_log_likelihood(y: Float[Array, 'N D'], mean: Float[Array, 'N D'], variance: Float[Array, 'N D']) -> Float[Array, ' N']
Compute the expected log likelihood.
For a variational distribution and a likelihood , compute the expected log likelihood:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y |
Float[Array, 'N D']
|
The observed response variable. |
required |
mean |
Float[Array, 'N D']
|
The variational mean. |
required |
variance |
Float[Array, 'N D']
|
The variational variance. |
required |
Returns:
Name | Type | Description |
---|---|---|
ScalarFloat |
Float[Array, ' N']
|
The expected log likelihood. |
__init__(num_datapoints: int = static_field(), integrator: AbstractIntegrator = static_field(AnalyticalGaussianIntegrator()), obs_stddev: Union[ScalarFloat, Float[Array, '#N']] = param_field(jnp.array(1.0), bijector=tfb.Softplus())) -> None
link_function(f: Float[Array, ...]) -> tfd.Normal
The link function of the Gaussian likelihood.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f |
Float[Array, ...]
|
Function values. |
required |
Returns
tfd.Normal: The likelihood function.
predict(dist: Union[tfd.MultivariateNormalTriL, GaussianDistribution]) -> tfd.MultivariateNormalFullCovariance
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:
Name | Type | Description | Default |
---|---|---|---|
dist |
Distribution
|
The Gaussian process posterior, evaluated at a finite set of test points. |
required |
Returns
tfd.Distribution: The predictive distribution.
Bernoulli
dataclass
Bases: AbstractLikelihood
num_datapoints: int = static_field()
class-attribute
instance-attribute
integrator: AbstractIntegrator = static_field(GHQuadratureIntegrator())
class-attribute
instance-attribute
__init_subclass__(mutable: bool = False)
replace(**kwargs: Any) -> Self
replace_meta(**kwargs: Any) -> Self
update_meta(**kwargs: Any) -> Self
replace_trainable(**kwargs: Dict[str, bool]) -> Self
Replace the trainability status of local nodes of the Module.
replace_bijector(**kwargs: Dict[str, tfb.Bijector]) -> Self
Replace the bijectors of local nodes of the Module.
constrain() -> Self
unconstrain() -> Self
stop_gradient() -> Self
trainables() -> Self
__call__(*args: Any, **kwargs: Any) -> tfd.Distribution
Evaluate the likelihood function at a given predictive distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Arguments to be passed to the likelihood's |
()
|
**kwargs |
Any
|
Keyword arguments to be passed to the likelihood's
|
{}
|
Returns
tfd.Distribution: The predictive distribution.
expected_log_likelihood(y: Float[Array, 'N D'], mean: Float[Array, 'N D'], variance: Float[Array, 'N D']) -> Float[Array, ' N']
Compute the expected log likelihood.
For a variational distribution and a likelihood , compute the expected log likelihood:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y |
Float[Array, 'N D']
|
The observed response variable. |
required |
mean |
Float[Array, 'N D']
|
The variational mean. |
required |
variance |
Float[Array, 'N D']
|
The variational variance. |
required |
Returns:
Name | Type | Description |
---|---|---|
ScalarFloat |
Float[Array, ' N']
|
The expected log likelihood. |
__init__(num_datapoints: int = static_field(), integrator: AbstractIntegrator = static_field(GHQuadratureIntegrator())) -> None
link_function(f: Float[Array, ...]) -> tfd.Distribution
The probit link function of the Bernoulli likelihood.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f |
Float[Array, ...]
|
Function values. |
required |
Returns
tfd.Distribution: The likelihood function.
predict(dist: tfd.Distribution) -> tfd.Distribution
Evaluate the pointwise predictive distribution.
Evaluate the pointwise predictive distribution, given a Gaussian process posterior and likelihood parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dist |
Distribution
|
The Gaussian process posterior, evaluated at a finite set of test points. |
required |
Returns
tfd.Distribution: The pointwise predictive distribution.
Poisson
dataclass
Bases: AbstractLikelihood
num_datapoints: int = static_field()
class-attribute
instance-attribute
integrator: AbstractIntegrator = static_field(GHQuadratureIntegrator())
class-attribute
instance-attribute
__init_subclass__(mutable: bool = False)
replace(**kwargs: Any) -> Self
replace_meta(**kwargs: Any) -> Self
update_meta(**kwargs: Any) -> Self
replace_trainable(**kwargs: Dict[str, bool]) -> Self
Replace the trainability status of local nodes of the Module.
replace_bijector(**kwargs: Dict[str, tfb.Bijector]) -> Self
Replace the bijectors of local nodes of the Module.
constrain() -> Self
unconstrain() -> Self
stop_gradient() -> Self
trainables() -> Self
__call__(*args: Any, **kwargs: Any) -> tfd.Distribution
Evaluate the likelihood function at a given predictive distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Arguments to be passed to the likelihood's |
()
|
**kwargs |
Any
|
Keyword arguments to be passed to the likelihood's
|
{}
|
Returns
tfd.Distribution: The predictive distribution.
expected_log_likelihood(y: Float[Array, 'N D'], mean: Float[Array, 'N D'], variance: Float[Array, 'N D']) -> Float[Array, ' N']
Compute the expected log likelihood.
For a variational distribution and a likelihood , compute the expected log likelihood:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y |
Float[Array, 'N D']
|
The observed response variable. |
required |
mean |
Float[Array, 'N D']
|
The variational mean. |
required |
variance |
Float[Array, 'N D']
|
The variational variance. |
required |
Returns:
Name | Type | Description |
---|---|---|
ScalarFloat |
Float[Array, ' N']
|
The expected log likelihood. |
__init__(num_datapoints: int = static_field(), integrator: AbstractIntegrator = static_field(GHQuadratureIntegrator())) -> None
link_function(f: Float[Array, ...]) -> tfd.Distribution
The link function of the Poisson likelihood.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f |
Float[Array, ...]
|
Function values. |
required |
Returns:
Type | Description |
---|---|
Distribution
|
tfd.Distribution: The likelihood function. |
predict(dist: tfd.Distribution) -> tfd.Distribution
Evaluate the pointwise predictive distribution.
Evaluate the pointwise predictive distribution, given a Gaussian process posterior and likelihood parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dist |
Distribution
|
The Gaussian process posterior, evaluated at a finite set of test points. |
required |
Returns:
Type | Description |
---|---|
Distribution
|
tfd.Distribution: The pointwise predictive distribution. |
inv_probit(x: Float[Array, ' *N']) -> Float[Array, ' *N']
Compute the inverse probit function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Float[Array, '*N']
|
A vector of values. |
required |
Returns
Float[Array, "*N"]: The inverse probit of the input vector.