Skip to content
BIASED

The relevance vector machine

A precision per weight (ARD), choosing the precisions by maximizing the evidence, MacKay's updates $\gamma_i = 1 - \alpha_i \Sigma_{ii}$, $\alpha_i \leftarrow \gamma_i / m_i^2$, why useless functions are removed entirely, EM versus the fixed point, and how the RVM compares with the SVM.

One precision per weight

The topic Bayesian linear regression gave every weight the same prior N(0,α−1)\mathcal N(0, \alpha^{-1}) and chose α\alpha and β\beta by maximizing the evidence. One α\alpha shrinks all weights alike: a useful basis function and a useless one pay the same penalty. When we suspect that only a few of many basis functions matter, we want the data to tell us which.

The fix takes one line. Give each weight its own precision:

p(w∣α)=∏i=1MN(wi∣0,αi−1)=N(w∣0,A−1),A=diag⁡(α1,…,αM).p(w \mid \alpha) = \prod_{i=1}^{M} \mathcal N\big(w_i \mid 0, \alpha_i^{-1}\big) = \mathcal N\big(w \mid 0, A^{-1}\big), \qquad A = \operatorname{diag}(\alpha_1, \dots, \alpha_M).

This prior is called automatic relevance determination (ARD). A large αi\alpha_i is a narrow prior that holds wiw_i close to zero; a small αi\alpha_i is a wide one that lets wiw_i go wherever the data push it.

The rest of the model is unchanged: t=Φw+εt = \Phi w + \varepsilon with ε∼N(0,β−1I)\varepsilon \sim \mathcal N(0, \beta^{-1} I). The n×Mn \times M design matrix has entries Φki=φi(xk)\Phi_{ki} = \varphi_i(x_k): row kk is the feature vector φ(xk)⊤\varphi(x_k)^\top of object xkx_k, and column ϕi\phi_i is basis function φi\varphi_i evaluated on all nn objects. The posterior is computed exactly as before, with αI\alpha I replaced by AA:

p(w∣t)=N(w∣m,Σ),Σ=(A+β Φ⊤Φ)−1,m=β Σ Φ⊤t.p(w \mid t) = \mathcal N(w \mid m, \Sigma), \qquad \Sigma = \big(A + \beta\, \Phi^\top \Phi\big)^{-1}, \qquad m = \beta\, \Sigma\, \Phi^\top t.

These are SNS_N and mNm_N of the previous topic. We drop the subscript NN so that a subscript can name a weight: mim_i, Σii\Sigma_{ii}.

The running example is the three points of the topic Bayesian linear regression, x=(−1,0,1)x = (-1, 0, 1) and t=(−1,1,2)t = (-1, 1, 2), now with three basis functions: a constant, the slope and a quadratic term,

φ(x)=(1, x, 3x2−2),Φ=(1−1110−2111).\varphi(x) = \big(1,\ x,\ 3x^2 - 2\big), \qquad \Phi = \begin{pmatrix} 1 & -1 & 1 \\ 1 & 0 & -2 \\ 1 & 1 & 1 \end{pmatrix}.

The quadratic term is shifted so that its column is orthogonal to the other two. All three columns are orthogonal, so Φ⊤Φ=diag⁡(3,2,6)\Phi^\top \Phi = \operatorname{diag}(3, 2, 6), the matrix Σ\Sigma is diagonal, and every weight is computed on its own:

Σii=1αi+β∥ϕi∥2,mi=β ϕi⊤tαi+β∥ϕi∥2.\Sigma_{ii} = \frac{1}{\alpha_i + \beta \lVert \phi_i \rVert^2}, \qquad m_i = \frac{\beta\, \phi_i^\top t}{\alpha_i + \beta \lVert \phi_i \rVert^2}.

We index the weights w0,w1,w2w_0, w_1, w_2 for the constant, the slope and the quadratic term. Here Φ⊤t=(2,3,−1)\Phi^\top t = (2, 3, -1). Take β=1\beta = 1 and start every αi\alpha_i at 22. Then Σ=diag⁡(1/5,1/4,1/8)\Sigma = \operatorname{diag}(1/5, 1/4, 1/8) and m=(0.4, 0.75, −0.125)m = (0.4,\ 0.75,\ -0.125). Least squares would use all three weights, (2/3, 3/2, −1/6)(2/3,\ 3/2,\ -1/6), and pass through every point: three functions, three points. The question of this topic is whether the data justify the curvature.

The evidence and a razor for every function

Precisions are hyperparameters, and the topic Bayesian model selection told us how to choose those: by the evidence. Integrate the weights out. Since t=Φw+εt = \Phi w + \varepsilon is a sum of independent Gaussians,

p(t∣α,β)=N(t∣0,C),C=β−1I+ΦA−1Φ⊤=β−1I+∑i=1Mαi−1 ϕiϕi⊤.p(t \mid \alpha, \beta) = \mathcal N(t \mid 0, C), \qquad C = \beta^{-1} I + \Phi A^{-1} \Phi^\top = \beta^{-1} I + \sum_{i=1}^{M} \alpha_i^{-1}\, \phi_i \phi_i^\top .

Mind the sizes: CC is the n×nn \times n covariance of the targets, while Σ\Sigma is the M×MM \times M covariance of the weights. The log-evidence is

log⁡p(t∣α,β)=−12[nlog⁡2π+log⁡det⁡C+t⊤C−1t].\log p(t \mid \alpha, \beta) = -\frac12 \Big[ n \log 2\pi + \log\det C + t^\top C^{-1} t \Big].

Each basis function adds the term αi−1ϕiϕi⊤\alpha_i^{-1} \phi_i \phi_i^\top to CC: it spreads the targets the model expects along the direction ϕi\phi_i. Two parts of the formula pull in opposite directions.

  • The fit term t⊤C−1tt^\top C^{-1} t gets smaller when CC stretches in the direction where the observed tt actually lies.
  • The volume term log⁡det⁡C\log\det C grows with every stretch. Adding a positive semidefinite matrix such as αi−1ϕiϕi⊤\alpha_i^{-1} \phi_i \phi_i^\top can never decrease it.

This is the automatic Occam's razor of Bayesian model selection, now applied to each basis function separately. A function whose column does not help explain tt costs volume and buys no fit. Its best precision is αi=∞\alpha_i = \infty: its term leaves CC, and the model becomes exactly the model without that function.

Choosing α\alpha and β\beta this way is type-II maximum likelihood, also called empirical Bayes. The weights are integrated out; the hyperparameters get point estimates. It is not full Bayes: nobody integrates over α\alpha. On the running example, maximizing the evidence raises it from −5.67-5.67 at the start α=(2,2,2)\alpha = (2, 2, 2) to −4.74-4.74, and the optimum indeed sends one precision to infinity. Which one, and how to get there, is the next two blocks.

MacKay's fixed-point updates

The determinant and the inverse of CC are awkward to differentiate directly. The previous topic rewrote the log-evidence in terms of the posterior; with AA in place of αI\alpha I it reads

log⁡p(t∣α,β)=12∑ilog⁡αi+n2log⁡β−β2∥t−Φm∥2−12 m⊤A m+12log⁡det⁡Σ−n2log⁡2π.\log p(t \mid \alpha, \beta) = \frac12 \sum_{i} \log \alpha_i + \frac n2 \log \beta - \frac{\beta}{2} \lVert t - \Phi m \rVert^2 - \frac12\, m^\top A\, m + \frac12 \log\det \Sigma - \frac n2 \log 2\pi .

Differentiate in αi\alpha_i. Three pieces contribute:

  • 12log⁡αi\frac12 \log \alpha_i gives 12αi\frac{1}{2\alpha_i};
  • Σ−1=A+βΦ⊤Φ\Sigma^{-1} = A + \beta \Phi^\top \Phi depends on αi\alpha_i through one diagonal entry, and ∂∂αilog⁡det⁡Σ=−Σii\frac{\partial}{\partial \alpha_i} \log\det \Sigma = -\Sigma_{ii};
  • mm minimizes β2∥t−Φw∥2+12w⊤Aw\frac{\beta}{2}\lVert t - \Phi w \rVert^2 + \frac12 w^\top A w over ww, so moving mm does not change this minimum to first order. Only the explicit αi\alpha_i counts, giving −12mi2-\frac12 m_i^2.
∂∂αilog⁡p(t∣α,β)=12αi−12 Σii−12 mi2=0.\frac{\partial}{\partial \alpha_i} \log p(t \mid \alpha, \beta) = \frac{1}{2\alpha_i} - \frac12\, \Sigma_{ii} - \frac12\, m_i^2 = 0 .

So at the optimum 1/αi=mi2+Σii1/\alpha_i = m_i^2 + \Sigma_{ii}: the prior variance equals the posterior second moment E[wi2]\mathbb E[w_i^2]. This is not a closed form, because mim_i and Σii\Sigma_{ii} depend on α\alpha themselves. MacKay multiplied it by αi\alpha_i and named one piece:

γi=1−αiΣii,αimi2=γi,αi←γimi2.\gamma_i = 1 - \alpha_i \Sigma_{ii}, \qquad \alpha_i m_i^2 = \gamma_i, \qquad \alpha_i \leftarrow \frac{\gamma_i}{m_i^2}.

γi\gamma_i lies between 00 and 11 and says how well the data determine wiw_i. If the data pin wiw_i down, Σii≪1/αi\Sigma_{ii} \ll 1/\alpha_i and γi≈1\gamma_i \approx 1; if the posterior is just the prior, Σii≈1/αi\Sigma_{ii} \approx 1/\alpha_i and γi≈0\gamma_i \approx 0. The sum ∑iγi\sum_i \gamma_i is the effective number of parameters.

The noise precision is handled the same way. Its derivative is

∂∂βlog⁡p(t∣α,β)=n2β−12∥t−Φm∥2−12tr⁡(Σ Φ⊤Φ),βtr⁡(Σ Φ⊤Φ)=∑iγi,\frac{\partial}{\partial \beta} \log p(t \mid \alpha, \beta) = \frac{n}{2\beta} - \frac12 \lVert t - \Phi m \rVert^2 - \frac12 \operatorname{tr}\big(\Sigma\, \Phi^\top \Phi\big), \qquad \beta \operatorname{tr}\big(\Sigma\, \Phi^\top \Phi\big) = \sum_i \gamma_i ,

where the identity follows from βΦ⊤Φ=Σ−1−A\beta \Phi^\top \Phi = \Sigma^{-1} - A.

Training repeats one round. Build Φ\Phi and pick starting values of α\alpha and β\beta. With them, compute the posterior Σ\Sigma and mm. From the posterior get the γi\gamma_i. Use the γi\gamma_i to update every αi\alpha_i and β\beta. Basis functions whose αi\alpha_i has passed a large threshold, say 10910^9, are removed with their columns, and the round starts again until the precisions stop changing.

On the running example, one round from α=(2,2,2)\alpha = (2, 2, 2): for the constant, γ0=1−2⋅15=0.6\gamma_0 = 1 - 2 \cdot \tfrac15 = 0.6 and α0←0.6/0.42=3.75\alpha_0 \leftarrow 0.6 / 0.4^2 = 3.75; for the slope, γ1=0.5\gamma_1 = 0.5 and α1←0.5/0.752≈0.89\alpha_1 \leftarrow 0.5/0.75^2 \approx 0.89.

Why precisions run off to infinity

Why do so many precisions run off to infinity instead of settling at some large number? Look at the evidence as a function of one αi\alpha_i with all the others fixed. Split off the term of basis function ii: C=C−i+αi−1ϕiϕi⊤C = C_{-i} + \alpha_i^{-1} \phi_i \phi_i^\top. Two numbers describe how ϕi\phi_i relates to the rest of the model:

si=ϕi⊤C−i−1ϕi,qi=ϕi⊤C−i−1t.s_i = \phi_i^\top C_{-i}^{-1} \phi_i, \qquad q_i = \phi_i^\top C_{-i}^{-1} t .

sis_i, the sparsity factor, measures how much room ϕi\phi_i still has, given the noise and the other functions. qiq_i, the quality factor, measures how well ϕi\phi_i is aligned with the targets. The determinant lemma and the Sherman–Morrison formula turn log⁡det⁡C\log\det C and t⊤C−1tt^\top C^{-1} t into those of C−iC_{-i} plus a correction:

log⁡p(t∣α,β)=log⁡p(t∣α−i,β)+12[log⁡αi−log⁡(αi+si)+qi2αi+si].\log p(t \mid \alpha, \beta) = \log p(t \mid \alpha_{-i}, \beta) + \frac12 \left[ \log \alpha_i - \log(\alpha_i + s_i) + \frac{q_i^2}{\alpha_i + s_i} \right].

As αi→∞\alpha_i \to \infty the bracket tends to 00: we recover the model without φi\varphi_i. Setting the derivative to zero gives si(αi+si)=qi2αis_i(\alpha_i + s_i) = q_i^2 \alpha_i, hence

αi∗=si2qi2−siif qi2>si,αi∗=∞if qi2≤si.\alpha_i^* = \frac{s_i^2}{q_i^2 - s_i} \quad \text{if } q_i^2 > s_i, \qquad \alpha_i^* = \infty \quad \text{if } q_i^2 \le s_i .

In the second case the derivative is positive for every αi\alpha_i, so the evidence keeps growing all the way to infinity. There is no "small but nonzero" weight: a basis function either earns its place, qi2>siq_i^2 > s_i, or is removed entirely. Only the size of qiq_i matters, not its sign.

The same two numbers give the posterior of the weight in general: Σii=1/(αi+si)\Sigma_{ii} = 1/(\alpha_i + s_i) and mi=qi/(αi+si)m_i = q_i/(\alpha_i + s_i). For orthogonal columns C−i−1ϕi=βϕiC_{-i}^{-1}\phi_i = \beta \phi_i, so si=β∥ϕi∥2s_i = \beta \lVert \phi_i \rVert^2 and qi=β ϕi⊤tq_i = \beta\, \phi_i^\top t, which matches the first block. On the running example with β=1\beta = 1:

basis function sis_i qiq_i qi2q_i^2 vs sis_i
constant 11 33 22 4>34 > 3
slope xx 22 33 9>29 > 2
quadratic 3x2−23x^2 - 2 66 −1-1 1<61 < 6

The constant stays with α0∗=32/(4−3)=9\alpha_0^* = 3^2/(4 - 3) = 9, a prior standard deviation of 1/31/3. The quadratic term goes: its column is long (s2=6s_2 = 6), so it would add a lot of volume, but the data barely lean along it. With the quadratic term removed and the other two precisions at their optimum, the evidence is about 1.91.9 times larger than with α2=2\alpha_2 = 2.

EM versus the fixed point

The same evidence can also be maximized by EM, treating ww as a latent variable (EM gets its own topic later; here we need only its two steps). The E-step computes the posterior N(m,Σ)\mathcal N(m, \Sigma) at the current α,β\alpha, \beta. The M-step maximizes the expected complete-data log-likelihood E[log⁡p(t,w∣α,β)]\mathbb E\big[\log p(t, w \mid \alpha, \beta)\big]. In αi\alpha_i it contains 12log⁡αi−12αi E[wi2]\frac12 \log \alpha_i - \frac12 \alpha_i\, \mathbb E[w_i^2], and the maximum is at

αinew=1mi2+Σii,1βnew=∥t−Φm∥2+tr⁡(ΦΣΦ⊤)n.\alpha_i^{\text{new}} = \frac{1}{m_i^2 + \Sigma_{ii}}, \qquad \frac{1}{\beta^{\text{new}}} = \frac{\lVert t - \Phi m \rVert^2 + \operatorname{tr}\big(\Phi \Sigma \Phi^\top\big)}{n}.

Compare with the previous block: the stationarity condition was 1/αi=mi2+Σii1/\alpha_i = m_i^2 + \Sigma_{ii}. EM reads it as an update directly; MacKay first rearranges it into αimi2=γi\alpha_i m_i^2 = \gamma_i. Both rules therefore have the same fixed points. Do not call MacKay's γ\gamma-updates "the E- and M-steps": they are a different iteration toward the same optimum.

They travel very differently. EM never decreases the evidence, a property MacKay's rule lacks. But MacKay's rule removes useless functions much faster. With one basis function in the orthogonal form, mi=qi/(αi+si)m_i = q_i/(\alpha_i + s_i) and γi=si/(αi+si)\gamma_i = s_i/(\alpha_i + s_i), so

αi←γimi2=si(αi+si)qi2≈siqi2 αifor large αi.\alpha_i \leftarrow \frac{\gamma_i}{m_i^2} = \frac{s_i(\alpha_i + s_i)}{q_i^2} \approx \frac{s_i}{q_i^2}\, \alpha_i \quad \text{for large } \alpha_i .

When qi2<siq_i^2 < s_i the precision is multiplied by a constant greater than one: geometric growth. Do the same substitution in the EM update and you will find that for large αi\alpha_i it adds roughly si−qi2s_i - q_i^2 per step: linear growth. On the running example the quadratic term (s2=6s_2 = 6, q22=1q_2^2 = 1) goes 2→48→324→1980→…2 \to 48 \to 324 \to 1980 \to \dots under MacKay and passes 10910^9 after 1111 steps. EM moves it 2→7.1→12.2→17.2→…2 \to 7.1 \to 12.2 \to 17.2 \to \dots and needs about 2⋅1082 \cdot 10^8 steps.

Kernels, relevance vectors and the SVM

So far the basis functions were fixed in advance. The relevance vector machine (Tipping, 2001) takes one per training object. With a kernel kk, for example the Gaussian k(x,x′)=exp⁡(−(x−x′)2/(2r2))k(x, x') = \exp\big(-(x - x')^2 / (2r^2)\big),

φj(x)=k(x,xj),j=1,…,n,\varphi_j(x) = k(x, x_j), \qquad j = 1, \dots, n,

plus a constant, so M=n+1M = n + 1. ARD switches most of them off. The training objects whose functions survive are the relevance vectors, and they give the method its name. A new input is predicted from them alone:

p(t∗∣x∗,t)=N(t∗ ∣ m⊤φ∗,  β−1+φ∗⊤Σ φ∗),φ∗=φ(x∗).p(t_* \mid x_*, t) = \mathcal N\Big(t_* \ \Big|\ m^\top \varphi_*,\ \ \beta^{-1} + \varphi_*^\top \Sigma\, \varphi_*\Big), \qquad \varphi_* = \varphi(x_*).

The variance is noise plus weight uncertainty, as in Bayesian linear regression.

An experiment: 100100 points with xx uniform on [−10,10][-10, 10], t=sin⁡(x)/xt = \sin(x)/x plus noise of standard deviation 0.10.1, the Gaussian kernel with r=1.5r = 1.5. MacKay's updates keep 88 of the 101101 basis functions (the constant is among those removed), estimate the noise standard deviation as 0.0940.094, and recover the true curve with root-mean-square error 0.0430.043. Support vector regression with the same kernel, at the best CC and ε\varepsilon of a small grid, reaches the same error with 3535 support vectors; with a narrower tube, ε=0.05\varepsilon = 0.05, it keeps 5757.

What the comparison with the SVM comes down to:

  • Sparser. Usually far fewer relevance vectors than support vectors, so prediction is cheaper.
  • Probabilistic. A predictive distribution instead of a point, with error bars.
  • Fewer knobs. No CC or ε\varepsilon to cross-validate: α\alpha and β\beta come from the evidence. The kernel width rr is still chosen outside, for instance by cross-validation.
  • Any basis. The φj\varphi_j need not come from a positive definite (Mercer) kernel.
  • Training is harder. The SVM solves a convex quadratic program with a unique optimum. The RVM maximizes a non-concave evidence, and its early iterations invert an (n+1)×(n+1)(n+1) \times (n+1) matrix: O(n3)O(n^3) time and O(n2)O(n^2) memory.

Where the RVM breaks and what comes next

The RVM is exact Bayesian inference over ww, but it is not free of approximations, and they show.

  • Overconfident far from the data. Gaussian kernels vanish away from their centres, so φ∗→0\varphi_* \to 0 and the predictive variance falls to the noise level β−1\beta^{-1}. In the sinc experiment the predictive standard deviation is 0.0970.097 at x=0x = 0 and exactly the noise estimate 0.0940.094 at x=15x = 15, outside the data. The model is most sure where it knows least. A Gaussian process (a later topic) with the same kernel goes back to the prior variance there instead.
  • Point estimates of precisions. α\alpha is maximized, not integrated over. The exact zeros are a product of that shortcut: full Bayes over α\alpha would not remove any function with certainty.
  • Local optima. The evidence is not concave in α\alpha. Different starting points, thresholds and stopping rules can leave different relevance vectors, and nothing guarantees one survivor per group of correlated functions. An exact copy of a column is never removed, since the evidence cannot tell how to split the prior variance between the two; in the sinc run two kept centres sit at −7.02-7.02 and −6.99-6.99, almost the same function.
  • Cost. O(n3)O(n^3) per iteration at the start, until most functions are gone.

One more limitation sets the next topic. Everything here was exact because a Gaussian likelihood times a Gaussian prior is Gaussian. For classification the likelihood becomes a product of sigmoids. The posterior over ww is no longer Gaussian, and the evidence p(t∣α)p(t \mid \alpha) has no closed form, so neither the posterior nor the updates of this topic can be written down. The topic The Laplace approximation and Bayesian classification replaces that posterior with a Gaussian at its mode, and with it brings back both the evidence and the relevance vectors.

Check your understanding

The same questions as in Pulse. Answers are shared between modes.

Full notes

Answers are saved on the server and tied to this browser until you sign in.