conjugate_mll#
- gpjax.objectives.conjugate_mll(posterior, data)[source]#
Evaluate the marginal log-likelihood of the Gaussian process.
Compute the marginal log-likelihood function 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 enables exact estimation of the Gaussian process’ latent function values.
For a training dataset \(\{x_n, y_n\}_{n=1}^N\), set of test inputs \(\mathbf{x}^{\star}\) the corresponding latent function evaluations are given by \(\mathbf{f}=f(\mathbf{x})\) and \(\mathbf{f}^{\star}f(\mathbf{x}^{\star})\), the marginal log-likelihood is given by:
\[\begin{split}\begin{aligned} \log p(\mathbf{y}) & = \int p(\mathbf{y}\mid\mathbf{f}) p(\mathbf{f}, \mathbf{f}^{\star})\mathrm{d}\mathbf{f}^{\star}\\ & = 0.5\left(-\mathbf{y}^{\top}\left(k(\mathbf{x}, \mathbf{x}') + \sigma^2\mathbf{I}_N\right)^{-1}\mathbf{y} \right.\\ & \quad\left. -\log\lvert k(\mathbf{x}, \mathbf{x}') + \sigma^2\mathbf{I}_N\rvert - n\log 2\pi \right). \end{aligned}\end{split}\]Example
>>> import gpjax as gpx>>> 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.Gaussian(num_datapoints=D.n) >>> prior = gpx.gps.Prior(mean_function = meanf, kernel=kernel) >>> posterior = prior * likelihood
>>> gpx.objectives.conjugate_mll(posterior, D)Our goal is to maximise the marginal log-likelihood. Therefore, when optimising the model’s parameters with respect to the parameters, we use the negative marginal log-likelihood. This can be realised through
>>> nmll = lambda p, d: -gpx.objectives.conjugate_mll(p, d)- Parameters:
posterior (ConjugatePosterior) – 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 marginal log-likelihood of the Gaussian process.
- Return type:
Expand for references to
gpjax.objectives.conjugate_mll