- Introduced by
- Scholkopf et al. (base OCSVM); Bayesian extension via Tipping and others
- Year
- 2001–2010
- Type
- Probabilistic anomaly detection
- Family
- Machine learning
What does it do?
Bayesian one-class SVM applies Bayesian inference to the one-class support vector machine, which estimates a region enclosing normal training data so that points outside it can be flagged as anomalous.
The Bayesian formulation aims to replace a binary inlier/outlier decision with a probabilistic score, so that the degree of anomaly can be ranked and thresholded. Because the model is trained only on normal-class data, it suits settings where anomalous examples are absent or rare.
The intuition behind the method
The one-class SVM, introduced by Scholkopf et al. (2001), fits a kernel expansion that is positive on the region where normal data lie and negative elsewhere. Its standard output is a signed value and a binary decision, with no direct statement of how confident the model is near the boundary. The Bayesian version places a prior over the parameters of this decision function and infers a posterior given the training data. Predictions for a new point then average over parameter uncertainty, so points well inside the learned region should receive higher normality scores than points near the boundary. Whether these scores are well calibrated depends on the prior and the data, and should be checked on held-out normal data.
History
The one-class SVM was introduced by Scholkopf et al. (2001) as a method for estimating the support of a distribution from examples of one class. The Bayesian one-class variant is a development of that method. Its originator and date are not documented in the sources for this entry, so the Bayesian formulation should be understood as an extension of the original one-class SVM rather than as a separately dated method.
When to use it
Choose Bayesian one-class SVM when only normal-class examples are available for training, for example in fraud, fault or medical screening, and when you need a graded score to rank cases or to set a threshold on an acceptable false-positive rate rather than only a binary flag. It is most relevant when the feature space is low to medium dimensional and the training set is small enough for kernel methods with Bayesian inference to be fitted within the available compute. Do not use it when labelled anomalies are available in sufficient numbers, since a two-class classifier then usually performs better. It is also a poor fit for very high-dimensional raw inputs without dimensionality reduction, or when scores cannot be checked on held-out normal data. Where simple, fully documented decision rules are required, a plain one-class SVM or a rule-based approach is easier to explain.
Limitations and considerations
- Bayesian inference adds substantial computational overhead over standard OCSVM, especially for large training sets.
- Kernel choice and the nu hyperparameter still require tuning; poor choices lead to over- or under-inclusive boundaries regardless of the Bayesian wrapper.
- Scales poorly to very high-dimensional raw data without prior dimensionality reduction.
- Posterior calibration quality depends on the adequacy of the chosen prior; a misspecified prior can produce overconfident or underconfident probabilities.
- Assumes the training data are representative, independently drawn samples of normal behaviour; anomalies present in the training data widen the learned region and weaken detection.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Produces a graded score for each point that can be ranked and thresholded, rather than only a signed distance or a binary flag.
- Combines the regularisation of the one-class SVM, which controls the length of the weight vector, with a Bayesian prior; the effect on boundary stability should be verified on held-out normal data.
- Depending on the prior chosen, sparse priors may prune many training points from the expansion, giving a leaner model; whether this occurs must be checked for the specific fit.
- Represents uncertainty over the parameters, so borderline points are not treated with the same confidence as clear inliers.
- Suited to one-class settings where anomaly examples are absent during training.
Applications
- Fraud detection and credit-card anomaly scoring where normal transaction patterns are well characterised but fraud examples are rare.
- Industrial fault detection on sensor streams where only normal operational data is available at training time.
- Medical screening and rare-disease detection using normal patient cohorts.
- Network intrusion detection where normal traffic distributions are modelled and deviations are scored probabilistically.
- Quality control in manufacturing where only defect-free samples are available for training.
How it works
How it works
Input features are implicitly mapped into a reproducing kernel Hilbert space through a kernel function; the radial basis function kernel is a common default. The kernel allows nonlinear boundaries to be learned without computing the high-dimensional coordinates explicitly. The choice of kernel and its bandwidth therefore largely determines the shape of the region that can be enclosed.
The decision function is a kernel expansion, found by solving a quadratic programming problem, that is positive on the estimated region of normal data and negative on its complement. The expansion is regularised by controlling the length of the weight vector in the associated feature space. The parameter nu sets the a priori fraction of training points allowed to fall outside this region, so its value directly constrains how tight the boundary is. Its effect should be checked empirically for each dataset.
A prior distribution is placed over the expansion coefficients of the decision function, and the posterior given the training data is computed, for example by a variational or evidence-based approximation. Whether the prior regularises the boundary in a stable way, and whether it drives coefficients toward zero so that only a subset of training points remains influential, depends on the chosen prior and approximation. Both effects should be verified for the specific model rather than assumed.
For a new point, the predictive distribution integrates over the posterior of the parameters to give a probability that the point is consistent with the normal class. Such a probability can be thresholded on held-out normal data to set a chosen false-positive level. Its usefulness depends on the adequacy of the prior and of the posterior approximation, so calibration should be checked before the scores are read as frequencies.
Common pitfalls
- Training on contaminated data: if anomalies are present in the 'normal' training set, the learned boundary will be artificially wide and anomaly scores will be deflated.
- Skipping kernel hyperparameter search and accepting RBF defaults without validating on a held-out normal set.
- Interpreting the probability score as a frequency of anomaly in the population without accounting for the prior class prevalence.
- Neglecting to normalise or standardise features before kernel mapping, causing the RBF bandwidth to be dominated by high-variance features.
Frequently asked questions
How does Bayesian one-class SVM differ from plain one-class SVM?
Plain OCSVM returns a signed distance from the boundary and a binary inlier/outlier flag. The Bayesian version places a prior over the model parameters and computes a posterior, yielding a probability score for each observation. This probability can support threshold selection based on acceptable false-positive rates and communicates uncertainty about borderline cases.
What prior should I use?
The choice of prior is method-dependent, and the cited sources do not establish a standard prior for a Bayesian one-class SVM. One option is a zero-mean Gaussian prior on the weight vector, which parallels the regularisation by controlling the length of the weight vector in the one-class SVM. Sparse priors, such as the automatic relevance determination prior used in the relevance vector machine, may prune coefficients, but the benefit depends on the data and should be validated.
How do I choose the nu parameter?
Nu gives the a priori fraction of training points allowed to fall outside the estimated region, a value between 0 and 1. If contamination of the training data is suspected, an estimate of it is a reasonable starting point. Choose nu and the kernel bandwidth together using a validation criterion. Where labelled anomalies exist, detection performance can be measured on them; threshold checks on held-out normal data alone only assess the false-positive side.
Can I use this method when I have some labelled anomaly examples?
If labelled anomaly examples are available, a two-class classifier (e.g., logistic regression, gradient boosting, or standard SVM with both classes) will usually outperform a one-class method. Bayesian one-class SVM is most valuable when anomaly labels are absent or too few to define a second class reliably.
What kernel works best?
The radial basis function (RBF) kernel is a common default. Because the decision function is a kernel expansion, the RBF kernel yields a flexible boundary in input space whose shape is not restricted to a sphere and depends on the data. Search the bandwidth (gamma) jointly with nu, since together they determine how tightly the boundary fits the normal data. Polynomial kernels are an alternative, and their suitability should be checked on the data at hand.
Related methods
Sources
Scholkopf, B., Platt, J. C., Shawe-Taylor, J., Smola, A. J., & Williamson, R. C. (2001). Estimating the support of a high-dimensional distribution. Neural Computation, 13(7), 1443–1471.
Open DOI referenceTipping, M. E. (2001). Sparse Bayesian learning and the relevance vector machine. Journal of Machine Learning Research, 1, 211–244.
Open publication reference