non_conjugate_mll#
- gpjax.objectives.non_conjugate_mll(posterior, data)#
The log-posterior density of a non-conjugate Gaussian process. This is sometimes referred to as the marginal log-likelihood.
Evaluate the log-posterior density of a Gaussian process.
Compute the marginal log-likelihood, or log-posterior density of the Gaussian process. The returned function can then be used for gradient based optimisation of the model’s parameters or for model comparison. The implementation given here is general and will work for any likelihood support by GPJax.
Unlike the marginal_log_likelihood function of the
ConjugatePosteriorobject, the marginal_log_likelihood function of theNonConjugatePosteriorobject does not provide an exact marginal log-likelihood function. Instead, theNonConjugatePosteriorobject represents the posterior distributions as a function of the model’s hyperparameters and the latent function. Markov chain Monte Carlo, variational inference, or Laplace approximations can then be used to sample from, or optimise an approximation to, the posterior distribution.Example
>>> import gpjax as gpx >>> import jax.numpy as jnp
>>> xtrain = jnp.linspace(0, 1).reshape(-1, 1) >>> ytrain = jnp.sin(xtrain) >>> D = gpx.Dataset(X=xtrain, y=ytrain)
>>> meanf = gpx.mean_functions.Constant() >>> kernel = gpx.kernels.RBF() >>> likelihood = gpx.likelihoods.Bernoulli(num_datapoints=D.n) >>> prior = gpx.gps.Prior(mean_function=meanf, kernel=kernel) >>> posterior = prior * likelihood
>>> gpx.objectives.log_posterior_density(posterior, D)- Parameters:
posterior (NonConjugatePosterior) – The posterior distribution for which we want to compute the marginal log-likelihood.
data (Dataset) – The training dataset used to compute the marginal log-likelihood.
- Returns:
The log-posterior density of the Gaussian process.
- Return type: