ConjugateModel#
- class gpjax.gps.ConjugateModel(prior, likelihood)[source]#
Bases:
JointModel[M,K,GL]A joint model with Gaussian likelihood: conditioning is exact.
For a Gaussian process prior \(p(\mathbf{f})\) and a Gaussian likelihood \(p(y | \mathbf{f}) = \mathcal{N}(y\mid \mathbf{f}, \sigma^2))\), the latent function can be analytically integrated out. Conditioning returns the closed-form posterior
\[\begin{split}\begin{aligned} p(\mathbf{f}^{\star}\mid \mathbf{y}) & =\mathcal{N}(\mathbf{f}^{\star}; \boldsymbol{\mu}_{\mid \mathbf{y}}, \boldsymbol{\Sigma}_{\mid \mathbf{y}}),\\ \boldsymbol{\mu}_{\mid \mathbf{y}} & = k(\mathbf{x}^{\star}, \mathbf{x})\left(k(\mathbf{x}, \mathbf{x}')+\sigma^2\mathbf{I}_n\right)^{-1}\mathbf{y}, \\ \boldsymbol{\Sigma}_{\mid \mathbf{y}} & =k(\mathbf{x}^{\star}, \mathbf{x}^{\star\prime}) -k(\mathbf{x}^{\star}, \mathbf{x})\left( k(\mathbf{x}, \mathbf{x}') + \sigma^2\mathbf{I}_n \right)^{-1}k(\mathbf{x}, \mathbf{x}^{\star}). \end{aligned}\end{split}\]Example
>>> import gpjax as gpx >>> import jax.numpy as jnp >>> >>> xtrain = jnp.linspace(0, 1).reshape(-1, 1) >>> D = gpx.Dataset(X=xtrain, y=jnp.sin(xtrain)) >>> >>> prior = gpx.gps.Prior( ... mean_function = gpx.mean_functions.Zero(), ... kernel = gpx.kernels.RBF() ... ) >>> model = prior * gpx.likelihoods.Gaussian() >>> posterior = model.condition(D) >>> predictive = posterior(xtrain) >>> evidence = posterior.log_marginal_likelihood
- condition(train_data)[source]#
Condition on data exactly.
- Returns:
- The closed-form posterior process, with the
training-covariance factorisation cached. Exposes the predictive (via
__call__),log_marginal_likelihood,looandsample_approx.
- Return type:
- Parameters:
train_data (Dataset)