- Introduced by
- Laskov, P. et al. (incremental extension); Scholkopf, B. et al. (original OC-SVM)
- Year
- 2006 (incremental/online variant); 1999 (base method)
- Type
- Online anomaly detection / novelty detection
- Family
- Machine learning
What does it do?
Online One-Class SVM is an incremental extension of the classical One-Class Support Vector Machine that updates its decision boundary as new data arrive one sample at a time, making it suitable for streaming environments and real-time anomaly or novelty detection without retraining from scratch.
The intuition behind the method
The classical One-Class SVM draws a tight hypersphere or hyperplane around normal training data in a kernel feature space; anything outside that boundary is flagged as an anomaly. The online variant keeps this idea but updates the support vectors and dual coefficients incrementally as each new observation arrives, so the boundary is revised without refitting on the full dataset. Each update works on the current support vector set, so its cost depends on the number of support vectors rather than only on the boundary points. Whether the model follows gradual changes in normal behaviour depends on how older information is weighted or removed, which the basic incremental update does not provide on its own.
History
One-Class SVM was introduced by Scholkopf et al. at NIPS in 1999 as a kernel method for novelty detection that uses only unlabeled normal-class data. Laskov et al. (2006) analysed, implemented and applied incremental support vector learning, which addresses the same problem of updating an SVM as new samples arrive. The online one-class variant is therefore best understood as an incremental extension of the 1999 method rather than as a single originating publication.
When to use it
Use Online One-Class SVM when data arrive as a stream and the normal class is well-defined but anomalies are rare, unlabeled, or unpredictable — for example, intrusion detection, sensor fault detection, or credit-card fraud monitoring. It suits moderate-dimensional continuous feature spaces and situations where new normal samples keep arriving and may gradually differ from the initial batch, provided a forgetting or windowing strategy is in place. Avoid it when the data are very high-dimensional (the kernel matrix grows large), when a full historical retraining is feasible, or when an explicit two-class boundary can be learnt; in those cases, full batch One-Class SVM, Isolation Forest, or a supervised classifier are better alternatives.
Limitations and considerations
- Computational cost per update scales with the number of support vectors, which grows with the stream unless pruning or merging strategies are applied.
- Sensitive to the choice of kernel and its hyperparameters (gamma for RBF), requiring careful tuning.
- Performance degrades in very high-dimensional spaces due to the curse of dimensionality in the kernel feature space.
- Requires a clean, anomaly-free (or nearly so) initial batch for proper initialization.
- Without a forgetting or windowing strategy, older support vectors can keep dominating the boundary after the normal behaviour has changed.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Processes data incrementally without full retraining, making it practical for real-time and streaming applications.
- Inherits the strong theoretical foundations of One-Class SVM, including kernel-based nonlinear boundaries.
- The nu hyperparameter gives intuitive control over the expected outlier fraction in training data.
- Can be updated with new samples as the normal behaviour changes; tracking gradual drift well requires an explicit forgetting, windowing, or pruning strategy, which the basic update does not include.
- Makes no parametric assumption about the form of the data distribution; however, the kernel choice and nu still encode modelling assumptions about what counts as normal.
Applications
- Network intrusion and cybersecurity anomaly detection on continuous traffic streams.
- Sensor fault detection in streaming industrial or IoT data.
- Credit-card and transaction-stream fraud monitoring.
- Monitoring applications where new normal samples arrive over time and may gradually change, provided the model is updated with a forgetting or windowing strategy.
How it works
How it works
The model is seeded on an initial batch of normal (unlabeled) data. A standard One-Class SVM is fitted to this batch, establishing an initial set of support vectors and the bias term rho that defines the decision boundary in the kernel feature space.
Each incoming sample is mapped into a high-dimensional feature space via a kernel function, typically the RBF kernel. The kernel similarity to existing support vectors determines where the new point sits relative to the current boundary without explicitly computing the high-dimensional representation.
Formula
K(x_i, x_j) = \exp(-\gamma \|x_i - x_j\|^2)
When a new sample arrives, the incremental algorithm adjusts the dual coefficients of existing support vectors and possibly adds the new point as a support vector, following the Karush-Kuhn-Tucker conditions. Points that fall well inside the boundary have zero weight; those near or outside the boundary influence the updated decision surface. Because each update touches the current support vector set, the cost per update grows with the size of that set; the exact update rule depends on the implementation used.
The decision function f(x) is computed as the weighted sum of kernel evaluations with all current support vectors minus the bias rho. A positive score places the point inside the learned boundary (normal); a negative score signals a potential anomaly or novelty.
Formula
f(x) = \sum_{i} \alpha_i K(x_i, x) - \rhoThe sign of f(x) determines the label: positive means inlier (normal), negative means outlier (anomaly or novelty). The hyperparameter nu is an upper bound on the fraction of training points that may lie outside the boundary (treated as outliers) and a lower bound on the fraction that are support vectors. A smaller nu allows fewer training points outside the boundary, giving a looser region that encloses more of the data; a larger nu tolerates more training points outside and gives a tighter region. The raw value of f(x) is not on a fixed scale: it depends on gamma and on the training data, and it is not a calibrated probability. In practice the alerting threshold should be chosen on held-out data rather than fixed at zero.
Formula
\hat{y} = \text{sign}(f(x))Common pitfalls
- Treating the sign of f(x) as a calibrated decision: the score scale depends on gamma and the training data, so the alerting threshold should be chosen on held-out data rather than fixed at zero.
- Contaminating the initial training batch with anomalies, which skews the boundary toward including outliers.
- Failing to apply feature scaling: the RBF kernel is distance-based and is highly sensitive to feature magnitude differences.
- Ignoring support vector budget management: without pruning, memory and runtime grow with the data stream length.
- Treating nu as the exact anomaly rate rather than an upper bound on training outliers and lower bound on support vectors.
- Comparing to two-class classifiers using metrics designed for balanced supervised problems rather than anomaly detection metrics (AUROC, precision-recall).
Frequently asked questions
How does Online One-Class SVM differ from the standard batch One-Class SVM?
The standard One-Class SVM trains once on a fixed dataset. The online variant incrementally adjusts its support vectors and decision boundary as each new sample arrives, making it suitable for streaming data without full retraining.
What does the nu parameter control?
Nu is an upper bound on the fraction of training points that can lie outside the boundary (potential outliers) and a lower bound on the fraction of points that are support vectors. Because a smaller nu allows fewer training points outside, it gives a looser boundary that encloses more of the data; a larger nu allows more training points outside and gives a tighter boundary. Nu is not the exact anomaly rate of new data.
How should I handle the growing support vector set?
Without budget management, the support vector set grows with the stream, increasing memory and per-update computation. Practical options include removing support vectors with the smallest dual coefficients, merging nearby support vectors, or limiting the training window to recent samples. Each option trades memory and speed against the approximation error of the boundary. Monitor the support vector count over the stream, since the available strategies depend on the implementation used.
Is Online One-Class SVM suitable for high-dimensional data like raw text or images?
Generally not directly: kernel methods scale poorly with dimensionality. A common workaround is to first reduce dimensionality via PCA or an autoencoder and then apply Online OC-SVM on the compact representation.
What evaluation metric should I use?
Because anomalies are rare, accuracy is misleading. Use AUROC (area under the ROC curve) and the precision-recall curve, which give a reliable picture of performance across different detection thresholds. Choose the final alerting threshold on held-out data, since the raw decision score is not calibrated.
Related methods
Sources
Laskov, P., Gehl, C., Krueger, S., & Muller, K.-R. (2006). Incremental support vector learning: Analysis, implementation and applications. Journal of Machine Learning Research, 7, 1909–1936.
Open publication referenceScholkopf, B., Williamson, R., Smola, A., Shawe-Taylor, J., & Platt, J. (1999). Support vector method for novelty detection. Advances in Neural Information Processing Systems (NIPS), 12, 582–588.
Open publication reference