Support vector machine (SVM)

A support vector machine is a classic supervised learning method that separates classes with the boundary that leaves the widest possible margin to the nearest training examples.

Picture emails plotted as points according to their features, with spam on one side and genuine mail on the other. Many lines could separate the two groups. A support vector machine picks the one with the maximum margin: the boundary that stays as far as possible from the nearest points of each class. Those nearest points are the support vectors, and they alone fix the boundary; the other training points could move without changing it.

Real data rarely splits cleanly, so practical SVMs use a soft margin that allows some points on the wrong side, with a setting usually called C that trades a wider margin against training errors. The other key idea is the kernel trick. A kernel lets the method behave as if the data had been mapped into a much higher-dimensional space, where a straight boundary can separate classes that are tangled in the original space. The result is a curved boundary, computed without ever building the high-dimensional space explicitly. Choosing the kernel and its settings is usually done by grid search with cross-validation.

The method grew out of the statistical learning theory of Vladimir Vapnik and Alexey Chervonenkis, whose original maximum-margin algorithm dates to the 1960s, and was developed at AT&T Bell Laboratories. In 1992 Bernhard Boser, Isabelle Guyon and Vapnik applied the kernel trick to maximum-margin classifiers, and Corinna Cortes and Vapnik published the soft-margin version in 1995. A version for predicting numbers, support vector regression, followed in 1996.

SVMs have been used for text categorisation, image classification, handwritten character recognition and biology problems such as classifying proteins. The scikit-learn documentation lists their strengths: they work well in high-dimensional spaces, even when there are more features than examples, and they are memory efficient because the decision depends only on the support vectors.

Their limits explain why they are not the tool for large modern AI systems. Training a kernel SVM with the widely used libsvm-based solver scales between the square and the cube of the number of examples, which makes millions of examples hard, although linear SVMs scale almost linearly. They do not give probabilities directly; scikit-learn computes them with an extra, expensive cross-validation step. They are two-class methods at heart, and a trained model's parameters are hard to interpret. For small and medium datasets with well-chosen features, they remain a strong and standard choice.

Common questions

What is a support vector machine in simple terms?

It is a method for sorting data into classes by drawing the boundary that sits as far as possible from the closest examples of each class. Those closest examples are called support vectors. New items are classified by which side of the boundary they fall on.

What is the kernel trick?

The kernel trick lets an SVM find curved boundaries by acting as if the data had been mapped into a higher-dimensional space where the classes can be separated by a flat boundary. It does this using a kernel function that measures similarity between pairs of points, so the high-dimensional mapping never has to be computed directly.

Are support vector machines still used?

Yes. They remain a standard tool in libraries such as scikit-learn and suit problems with many features and relatively few examples, such as some text and biology data. Training cost makes kernel SVMs hard to use with millions of examples, so very large datasets usually call for linear SVMs or other methods.

What is the difference between an SVM and a neural network?

An SVM finds a single maximum-margin boundary, and its training problem has one best solution. A neural network learns many layers of features from raw data and is trained by gradient descent, which scales to far larger datasets. SVMs rely more on well-chosen input features and kernels.

Finding more

Search for "support vector machine", "kernel trick", "soft margin SVM" or "SVM vs logistic regression" to learn how the method works and when to use it. Good sources include the scikit-learn user guide, university machine learning course notes and textbooks on statistical learning. Library documentation is the most reliable guide to practical limits such as training time and probability estimates.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.