Online Support Vector Machine

Machine Learning
Introduced by
Shalev-Shwartz, Singer, et al. (Pegasos); Bordes, Bottou et al. (LASVM)
Year
2005–2011
Type
Online kernel classifier
Family
Machine learning

What does it do?

Online SVM adapts the support vector machine to data that arrive sequentially.

It updates the decision boundary one example at a time instead of solving the full batch quadratic program. Algorithms such as Pegasos and LASVM use this approach, keeping the margin-maximising idea of SVMs without storing and reprocessing the whole dataset.

The intuition behind the method

A standard SVM needs all training data at once to solve its optimisation problem. An online SVM handles one observation at a time. When a new example arrives, the model checks whether it is classified correctly with sufficient margin, and if not, it moves the hyperplane to accommodate it. Old examples are not revisited unless the method keeps a cache of support vectors. With a suitable step-size schedule, the sequence of updates is designed to approach the maximum-margin solution that the batch problem defines, although a finite stream may leave the model short of that solution.

History

Online kernel methods build on mistake-driven, perceptron-style updates, which were later extended to kernel classifiers. LASVM (Bordes et al., 2005) applies online updates to kernel SVMs. Pegasos (Shalev-Shwartz et al., Mathematical Programming, 2011) gives a primal sub-gradient formulation of the linear SVM, and its step-size schedule is the example used in the update step above.

When to use it

Choose Online SVM when examples arrive as a stream, when the full dataset is too large to hold in memory, or when retraining a batch SVM on each new batch would be too costly. Typical applications include text classification, click-through prediction and intrusion or fraud detection. Do not use it when an exact kernel solution is required and the number of support vectors would grow without a budget, when classes are strongly imbalanced and losses have not been reweighted, or when you need calibrated probabilities. In those cases logistic regression or gradient-boosted trees are usually more convenient. The convergence results for Pegasos-type methods assume that examples are drawn from a stationary distribution and that the step size decays over time. When the stream is non-stationary, the decaying step size slows adaptation, and the weights do not track a moving optimum without an explicit adaptation mechanism.

Limitations and considerations

  • Exact kernel SVMs must store the support vectors, so memory grows with their number; budget approximations trade some accuracy for bounded memory.
  • Hyperparameter tuning (lambda, kernel bandwidth) requires a held-out window or periodic validation batches, since cross-validation over a stream needs extra bookkeeping.
  • Does not output calibrated probabilities; Platt scaling must be applied separately if probabilities are needed.
  • Multiclass problems need one-vs-one or one-vs-rest decompositions, which multiply the training cost.

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

Strengths

  • Processes one example per update, with O(d) cost per update for linear kernels (d being the number of features), so memory does not grow with the number of examples.
  • Can keep learning as new labelled examples arrive, without retraining on the full history of the stream.
  • Works on the same regularised hinge-loss objective as the batch SVM, so it targets the same kind of maximum-margin boundary. Pegasos-type solvers are analysed for convergence to the optimum of that objective.
  • For kernel variants, memory can be bounded by budget techniques that cap the number of support vectors, at some cost in accuracy.

Applications

  • Large-scale text and document classification where the corpus cannot fit in RAM.
  • Click-through rate prediction in online advertising with continuously arriving impression logs.
  • Intrusion and fraud detection on high-velocity network or transaction streams.
  • Sentiment analysis pipelines updated incrementally as new reviews arrive.
  • Adaptive spam filtering that responds to new spammer tactics without full retraining.

How it works

How it works

1

The weight vector w is set to zero or warm-started from an earlier model. The bias b is initialised to zero or dropped altogether, depending on the implementation (see update-weights). The regularisation parameter lambda sets the trade-off between margin width and hinge loss, playing a role similar to C in the batch formulation.

2

One labelled observation (x_t, y_t) arrives at each time step t. The model evaluates the current decision function on this example without access to earlier examples. This is what makes the procedure online and keeps memory use low.

3

The hinge loss is zero when the functional margin y_t times (w dot x_t) is at least 1, meaning the example is correctly classified outside the margin. Otherwise the loss is positive and the update is triggered.

Formula
\ell(w; x_t, y_t) = \max(0,\, 1 - y_t \langle w, x_t \rangle)
4

When a margin violation occurs, w is shrunk by the factor (1 - eta_t lambda) and moved toward the misclassified example by eta_t y_t x_t. When there is no violation, only the shrinkage applies. In Pegasos the step size eta_t is set to 1/(lambda t), so later steps are smaller. Other algorithms use different step-size schedules, so the schedule should be taken from the specific solver. Bias handling also varies: some implementations omit b, some append a constant feature to x so that the bias is learned as part of w, and some update b separately. Check which convention the solver uses before interpreting w and b.

Formula
w_{t+1} = (1 - \eta_t \lambda)\, w_t + \eta_t y_t x_t \cdot \mathbf{1}[\text{margin violated}]
5

After each update, or at any later time, the model predicts a label by taking the sign of the inner product of w with the input features plus the bias. For kernel variants, the prediction is a weighted sum over the cached support vectors instead of an explicit dot product.

Formula
\hat{y} = \operatorname{sign}(\langle w, x \rangle + b)

Common pitfalls

  • Using a constant step size instead of a decaying schedule. The iterates then tend to fluctuate around the optimum rather than settle on it.
  • Forgetting to normalise or standardise features. In the linear case, the margin and the weight-based regularisation depend on feature scale.
  • Ignoring class imbalance. Loss re-weighting or minority-class oversampling is needed when the stream is skewed.
  • Treating the hinge-loss score as a probability. The score is a margin, not a calibrated probability.
  • Letting the support vector set grow without a budget in kernel mode. Prediction cost is linear in the number of support vectors, so each prediction becomes more expensive as the set grows.

Frequently asked questions

Is Online SVM the same as stochastic gradient descent on hinge loss?

For the linear case the two are closely related: Pegasos is a stochastic sub-gradient method on the regularised hinge loss. They differ mainly in the regularisation schedule and in the convergence analysis. Both aim at the same maximum-margin hyperplane that the batch SVM targets.

How do I choose the regularisation parameter lambda?

Lambda is inversely related to the classical C parameter (lambda = 1/(n*C), where n is the number of examples). The exact relation depends on how the objective is scaled. Use a held-out stream window or periodic validation batches to tune it.

Can Online SVM handle non-linear boundaries?

Yes, via kernel tricks (Gaussian, polynomial), but the support vector set may grow without bound. Budget SVM methods or the Nyström random feature approximation keep cost manageable, at the price of approximate kernels.

How does Online SVM compare to online logistic regression?

Online SVM maximises a geometric margin and handles non-separable data through hinge loss, while online logistic regression maximises log-likelihood and directly outputs probabilities. Both can reach similar accuracy on linearly separable data. Choose logistic regression if you need calibrated probabilities, and the SVM if margin-based decision scores are sufficient.

Does concept drift break the model?

The decaying step size 1/(lambda t) makes later updates smaller, so the model responds more slowly to new data. It is therefore not a drift-tracking mechanism by itself. Under drift, an explicit approach is needed, such as a change-detection signal that resets or restarts the weight vector and its schedule. The specific mechanism depends on the implementation.

Related methods

Sources

  1. Shalev-Shwartz, S., Singer, Y., Srebro, N., & Cotter, A. (2011). Pegasos: Primal estimated sub-gradient solver for SVM. Mathematical Programming, 127(1), 3–30.

    Open DOI reference
  2. Bordes, A., Ertekin, S., Weston, J., & Bottou, L. (2005). Fast kernel classifiers with online and active learning. Journal of Machine Learning Research, 6, 1579–1619.

    Open publication reference