---
title: Sparse Variational Bayesian GAMs
url: https://www.emergentmind.com/topics/sparse-variational-bayesian-gams
type: topic
---

# Sparse Variational Bayesian GAMs

Sparse Variational Bayesian Generalized Additive Models (GAMs) are a scalable and interpretable Bayesian framework for modeling nonparametric additive functions, leveraging Gaussian process (GP) priors and sparse variational inference. Each additive component is modeled independently with a GP, enabling rich, flexible modeling while preserving interpretability. Sparse variational approximations ensure tractable inference even in high dimensions or with large datasets by exploiting the structure of the GAM and the efficiency of inducing-point methods. This framework—detailed by Adam et al. (2018)—retains full posterior coupling among additive components, delivering well-calibrated uncertainty, interpretable function decompositions, and favorable scaling properties [1812.11106].

## 1. Model Formulation

The generative model considers inputs $x_n = (x_{n1},\dots,x_{nD}) \in \mathbb{R}^D$ and outputs $y_n \in \mathbb{R}$ for $n=1,\dots,N$, with an additive predictor:
\[
f(x_n) = \sum_{d=1}^D f_d(x_{nd}),
\]
where each $f_d$ represents an unknown smooth function. The conditional likelihood factorizes:
\[
p(y_n \mid f(x_n)) = p(y_n \mid \rho_n), \quad \rho_n = \sum_{d=1}^D f_d(x_{nd}).
\]
Each additive component is assigned an independent zero-mean GP prior:
\[
f_d \sim \mathcal{GP}(0, k_d(\cdot, \cdot; \theta_d)),
\]
with $\theta_d$ denoting kernel hyperparameters.

## 2. Sparse Gaussian Process Representation

To facilitate scalable inference, each $f_d$ is represented via $M$ inducing points $Z_d = (z_d^{(1)}, \dots, z_d^{(M)})$. The associated inducing variables are
\[
u_d = [f_d(z_d^{(1)}), \dots, f_d(z_d^{(M)})]^\top \in \mathbb{R}^M,
\]
and the collection $U = [u_1^\top, \dots, u_D^\top]^\top \in \mathbb{R}^{MD}$. The joint prior over function values and inducing variables factorizes:
\[
p(f_d, u_d) = p(u_d)\,p(f_d \mid u_d),
\]
where $p(u_d) = \mathcal{N}(u_d; 0, K_{d,ZZ})$ and
\[
p(f_d(x) \mid u_d) = \mathcal{N}\left( f_d(x);\, K_{d,xZ} K_{d,ZZ}^{-1} u_d,\; k_d(x,x) - K_{d,xZ} K_{d,ZZ}^{-1} K_{d,Zx} \right).
\]
Here, $K_{d,ZZ}$ is the $M \times M$ kernel matrix over inducing locations; $K_{d,xZ}$ is a row vector of cross-covariances for test input $x$.

## 3. Variational Posterior Structure

Posterior inference is addressed by variational approximation. The true posterior $p(f_{1:D}, U \mid y_{1:N})$ is approximated with
\[
q(f_{1:D}, U) = q(U) \prod_{d=1}^D p(f_d \mid u_d),
\]
so that only the inducing variables $U$ have free variational parameters. The variational distribution is taken as
\[
q(U) = \mathcal{N}(U; \mu_U, \Sigma_U).
\]
Direct fully-coupled posteriors $\Sigma_U \in \mathbb{R}^{MD \times MD}$ are computationally infeasible. Instead, Adam et al. parameterize the inverse covariance (precision) in an additive low-rank form:
\[
\Sigma_U^{-1} = K_{UU}^{-1} + B B^\top, \quad B \in \mathbb{R}^{(MD) \times R},
\]
with $R = M \ll MD$. This structure ensures tractable $O(DM^2)$ storage while capturing cross-component posterior dependencies.

## 4. Objective and Predictive Quantities

Variational parameters are optimized by maximizing the evidence lower bound (ELBO):
\[
\mathcal{L} = \sum_{n=1}^N \mathbb{E}_q \left[ \log p(y_n \mid \rho_n) \right] - \mathrm{KL}\left[ q(U)\,\|\,p(U) \right].
\]
For Gaussian likelihoods, the expectation can be computed exactly; for non-Gaussian cases, one uses quadrature or stochastic sampling.

The predictive mean and variance for input $x_n$ are
\[
m_n = \sum_{d=1}^D k_{d, x_{nd} Z_d} K_{d,ZZ}^{-1} \mu_{u_d},
\]
\[
s_n^2 = \sum_{d,d'} k_{d, x_{nd} Z_d} K_{d,ZZ}^{-1} \Sigma_{u_d,u_{d'}} K_{d', ZZ}^{-1} k_{d', Z_{d'} x_{nd}}
+ \sum_{d=1}^D \Big[ k_d(x_{nd}, x_{nd}) - K_{d, x_{nd} Z_d} K_{d,ZZ}^{-1} K_{d, Z_d x_{nd}} \Big].
\]
The KL divergence term is
\[
\mathrm{KL}[q(U)\,\|\,p(U)] = \frac{1}{2} \left[ \log \frac{ \det K_{UU} }{ \det \Sigma_U } - MD + \operatorname{tr}(K_{UU}^{-1} \Sigma_U) + \mu_U^\top K_{UU}^{-1} \mu_U \right].
\]
With the structured precision, this is evaluated in $O(DM^3)$ time.

## 5. Optimization and Computational Complexity

All variational parameters $\{ \mu_U, B \}$ and kernel hyperparameters $\{ \theta_d \}$ are learned via (stochastic) gradient ascent on the ELBO, typically using automatic differentiation. If $p(y \mid f)$ factorizes over datapoints, mini-batches of size $B \ll N$ facilitate efficient stochastic optimization.

Computational cost per iteration (full batch) is:
- Storage: $O(DM^2)$ for $B$.
- KL evaluation: $O(DM^3)$, dominated by Cholesky factorization.
- ELBO expectation: $O(ND^2M^2)$ (for predictive variances across all $n$ and cross-component terms).

With mini-batching ($B$ data points per step, $R=M$), the likelihood expectation costs $O(BD^2M^2)$ per stochastic gradient update.

## 6. Calibration, Uncertainty, and Interpretability

Given variational parameters $(\mu_U, \Sigma_U)$, the posterior for each $f_d(x)$ is Gaussian:
\[
\mathbb{E}[f_d(x)] = k_{d, x Z_d} K_{d, ZZ}^{-1} \mu_{u_d},
\]
\[
\operatorname{Var}[f_d(x)] = k_d(x, x) - k_{d, x Z_d} K_{d, ZZ}^{-1} \left[K_{d, ZZ} - \Sigma_{u_d,u_d}\right] K_{d, ZZ}^{-1} k_{d, Z_d x}.
\]
Summing the component posteriors gives the marginal over $\rho(x)$. Calibration and uncertainty quantification are conducted via posterior credible-interval coverage, CRPS, and empirical residual analysis. The additive decomposition preserves interpretable component-wise contributions to predictions.

## 7. Empirical Evaluation and Comparative Summary

Adam et al. demonstrate the methodology on a synthetic six-dimensional regression task:
\[
f(x) = 10 \sin(\pi x_1 x_2) + 20(x_3-0.5)^2 + 10 x_4 + 5 x_5,
\]
for $x \in [0,1]^6$ and $N = 5000$ samples with $\sigma^2 = 1$. The kernel is constructed in ANOVA fashion:
\[
\sigma_0 + \sum_{i=1}^6 s_i(x_i, y_i) + s_7(x_1, y_1) s_8(x_2, y_2),
\]
with $s_i$ being centered SE kernels. Univariate kernels use $16$ inducing points; the interaction term uses a $4 \times 4$ grid.

Empirical findings indicate the proposed method matches or betters predictive log-likelihood and RMSE versus mean-field sparse GPs (Saul et al. 2016) and fully-coupled precision-parameter GPs (Adam et al. 2017), yields well-calibrated credible intervals, and scales linearly with $N$ and quadratically with $D$ in the expectation step. The additive structure retains full interpretability.

By leveraging additive model structure, per-component inducing variables, and a structured low-rank variational precision ($\Sigma_U^{-1} = K_{UU}^{-1} + B B^\top$), the approach achieves effective and interpretable Bayesian sparse GP GAM inference, with the ELBO and associated gradients computable in $O(DM^3 + ND^2M^2)$ time and $O(DM^2)$ space, while preserving calibrated uncertainty and interpretable component-wise posterior estimates [1812.11106].

Source: https://www.emergentmind.com/topics/sparse-variational-bayesian-gams