Bayesian Support Vector Machine

Machine Learning
Introduced by
Polson, N. G. & Scott, S. L.; Tipping, M. E.
Year
2001–2011
Type
Bayesian probabilistic classifier / regressor
Family
Machine learning

What does it do?

Bayesian SVM places a prior distribution over the weight vector of a support vector machine, so that inference yields a posterior distribution over weights rather than a single maximum-margin solution.

Polson and Scott (2011) show that the regularised SVM objective admits a latent-variable representation, which makes EM, ECME and Gibbs-sampling algorithms available for SVM parameters. The posterior therefore supports uncertainty statements about the decision function, although the cited abstract does not evaluate how well any resulting probabilities are calibrated.

The intuition behind the method

A standard SVM returns one maximum-margin decision boundary and a real-valued score for each point. A Bayesian SVM instead places a prior on the weights and considers the set of weight vectors that remain plausible given the training labels. Polson and Scott (2011) rewrite the SVM objective as the mode of a mean-variance mixture of normals, which lets standard Bayesian tools for Gaussian linear models be applied. The practical gain is a summary of how much the decision function could vary across plausible weight vectors, which a single point estimate does not provide.

History

The latent-variable representation of regularised SVMs that underlies the Bayesian SVM was presented by Polson and Scott (2011), who linked the SVM optimality criterion to the mode of a mean-variance mixture of normals and derived EM, ECME and Gibbs-sampling algorithms. Tipping (2001) introduced the sparse Bayesian relevance vector machine, a related but distinct kernel model. Earlier Bayesian treatments of kernel classifiers are not covered by the sources listed on this page.

When to use it

Consider a Bayesian SVM when a margin-based classifier is preferred and you want a posterior over the weights, for example to quantify uncertainty in the decision function or to incorporate prior knowledge when labelled data are limited. Because inference is sampling-based, it suits problems where the number of observations is moderate and the computation time is acceptable. For very large datasets the sampling cost is the main constraint, and a standard SVM or a variational alternative may be preferable. If your main requirement is a well-calibrated probability output, a model designed for probabilities, such as logistic regression or a Gaussian process classifier, may be a more direct choice. If individual feature effects are the goal, a Bayesian logistic regression is usually easier to explain.

Limitations and considerations

  • Sampling-based inference becomes computationally demanding as the number of observations grows; the cited work does not report scaling results, so the cost should be measured on the target data.
  • Because the SVM objective is identified with the mode of a pseudo-posterior, the uncertainty it reports is a property of the augmented construction and not necessarily of a full data-generating model; its calibration is not assessed in the cited abstract.
  • The choice of prior and kernel is a modelling decision that affects the posterior, and the cited sources give guidance only through the specific examples they implement.
  • Ready-made implementations may be limited; check whether the tool you use provides a sampler, or plan for custom code.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • The latent-variable representation of Polson and Scott (2011) makes EM, ECME and Gibbs-sampling algorithms applicable to the SVM objective, so posterior summaries can be obtained with tools developed for Gaussian linear models.
  • A prior on w lets structural assumptions such as sparsity enter the estimation directly; the cited paper implements spike-and-slab priors and runs them on a spam filtering data set.
  • The posterior over w yields a spread of predictive scores, so uncertainty about the decision function is available rather than only a single point estimate.
  • The model keeps the regularised SVM objective as its core, so it remains close to the standard SVM formulation rather than replacing it with a different loss.

Applications

  • Spam filtering, the data set on which Polson and Scott (2011) demonstrate Bayesian SVMs with spike-and-slab priors.
  • Classification problems with limited labelled data where prior information is available and a posterior over the decision function is required.
  • Sparse-prior variants of margin-based classification, as an alternative to the Relevance Vector Machine when an SVM-style formulation is preferred.
  • Settings in which uncertainty in the decision function is reported alongside predictions, provided calibration is checked on the target data.

How it works

How it works

1

A prior distribution is placed on the weight vector w. Polson and Scott (2011) implement spike-and-slab priors among their examples, while other choices, such as zero-mean Gaussian priors, are common in Bayesian linear models. Priors on kernel hyperparameters are a further modelling decision that the cited abstract does not analyse.

2

Latent scale variables are introduced so that the regularised SVM objective corresponds to the mode of a mean-variance mixture of normals pseudo-posterior, as shown by Polson and Scott (2011). Conditional on these latent variables the model is Gaussian in w, which is what permits Gibbs sampling and EM or ECME point estimates. The augmentation is a computational device; it does not by itself turn the hinge-loss SVM into a fully specified generative likelihood.

3

Inference targets a pseudo-posterior of w: the SVM pseudo-likelihood (the exponential of the negative hinge-loss criterion) multiplied by the prior p(w). Its mode coincides with the regularised SVM solution. One samples from the pseudo-posterior of w and the latent variables by Gibbs sampling, or obtains point estimates by EM or ECME. The pseudo-posterior collects the weight vectors that are consistent with the training data and the prior. Variational approximations are an alternative to sampling, but the cited abstract does not discuss them.

Formula
p(\mathbf{w} \mid \mathbf{X}, \mathbf{y}) \propto \exp\{-2\sum_{i} \max(1 - y_i \mathbf{x}_i^{\top}\mathbf{w},\, 0)\}\, p(\mathbf{w})
4

For a new point x*, the predictive quantity integrates the decision function over the pseudo-posterior of w, as in the formula above. Averaging over posterior samples gives a real-valued predictive score. A natural decision rule is to assign the class given by the sign of the posterior mean score; its magnitude indicates distance from the boundary, and the spread of the score across samples reflects uncertainty in w (for example, report the proportion of samples with a positive score, or an interval for the score). This is a score rather than a class probability: converting it into a probability is a separate step, and the cited sources do not establish that the result is calibrated without checking it on held-out data.

Formula
p(y^* \mid \mathbf{x}^*, \mathbf{X}, \mathbf{y}) = \int p(y^* \mid \mathbf{x}^*, \mathbf{w}) \, p(\mathbf{w} \mid \mathbf{X}, \mathbf{y}) \, d\mathbf{w}

Common pitfalls

  • Treating posterior predictive scores as calibrated probabilities without checking calibration on held-out data; the cited abstract does not evaluate calibration.
  • Ignoring Gibbs sampler convergence diagnostics such as trace plots, effective sample size and R-hat across chains, which can hide non-convergence and yield overconfident summaries.
  • Using a vague prior when labelled data are few, so that the posterior is largely determined by the arbitrary shape of the prior rather than by the data.
  • Reporting EM or ECME point estimates as if they were posterior summaries, which discards the uncertainty that motivates the Bayesian treatment.
  • Conflating Bayesian SVM with the Relevance Vector Machine. Tipping (2001) introduced the RVM, which uses a sparsity-inducing automatic relevance determination prior; the two are related but are not the same model.

Frequently asked questions

How does Bayesian SVM differ from a standard SVM with Platt scaling?

Platt scaling fits a logistic function to SVM scores after training and does not change the weights. Bayesian SVM places a prior on the weights and infers a posterior, so uncertainty is part of the fitted model. Calibration of either approach has to be checked on data; the cited abstract does not evaluate it.

Is the Relevance Vector Machine the same as Bayesian SVM?

They are related but distinct. The RVM introduced by Tipping (2001) uses an automatic relevance determination prior that drives many weights to zero. In the Polson and Scott (2011) formulation the SVM objective is kept and augmented with latent variables; sparsity arises only if a sparsity-inducing prior, such as spike-and-slab, is chosen.

Can I use Bayesian SVM on large datasets?

Sampling-based inference becomes slow as the number of observations grows, so test the computation time on your own data. For larger problems consider variational approximations, a Gaussian process classifier, or a standard SVM with Platt scaling.

What kernel should I use?

The radial basis function (RBF) kernel is a common starting point. A linear kernel is often considered first when the number of features is large relative to the number of observations. Choose between kernels by cross-validation or held-out performance. In a Bayesian treatment the kernel bandwidth can in principle receive a prior and be integrated out, but this substantially increases computational cost.

How do I assess whether my MCMC sampler has converged?

Inspect trace plots for each weight component, compute the Gelman-Rubin R-hat statistic across multiple chains (values near 1.0 indicate convergence), and report the effective sample size. Low ESS suggests strong autocorrelation and the need for more iterations or thinning.

Related methods

Sources

  1. Polson, N. G., & Scott, S. L. (2011). Data augmentation for support vector machines. Bayesian Analysis, 6(1), 1–23.

    Open DOI reference
  2. Tipping, M. E. (2001). Sparse Bayesian learning and the relevance vector machine. Journal of Machine Learning Research, 1, 211–244.

    Open publication reference