Svm

Support Vector Machine (SVM) is a supervised machine learning algorithm that finds the optimal hyperplane separating classes with the maximum margin — where the "support vectors" are the data points closest to the decision boundary that define the margin, and the "kernel trick" enables SVMs to handle non-linearly separable data by projecting it into higher-dimensional spaces where a linear separator exists, providing strong theoretical guarantees and excellent performance on small-to-medium datasets with high-dimensional features.

What Is an SVM?

  • Definition: A classification (and regression) algorithm that finds the hyperplane that maximizes the margin between classes — the "best" separator is the one with the widest gap between the closest data points of each class.
  • Intuition: Imagine fitting a straight line between two groups of points on a 2D plane. Many lines could separate them, but the SVM finds the line with the widest possible margin — the one that would be hardest for new data points to cross accidentally.
  • Support Vectors: The critical data points that lie closest to the decision boundary — they "support" the hyperplane's position. All other data points are irrelevant to the model. This makes SVMs memory-efficient.

Key Concepts

ConceptExplanationVisual Intuition
HyperplaneThe decision boundary (line in 2D, plane in 3D, hyperplane in higher-D)The wall between two groups
MarginDistance between the hyperplane and the nearest data pointsThe gap between the wall and the closest people
Support VectorsData points closest to the hyperplaneThe people standing right at the edge of the gap
Hard MarginNo data points allowed inside the marginOnly works for perfectly separable data
Soft Margin (C)Allows some misclassification (controlled by parameter C)Tolerates some overlap for robustness

The Kernel Trick

When data isn't linearly separable (you can't draw a straight line between classes), kernels project the data into a higher dimension where linear separation is possible:

KernelWhen to UseExample
LinearData is linearly separableText classification (high-D, sparse)
RBF (Radial Basis Function)General-purpose non-linearMost common default
PolynomialPolynomial decision boundariesImage features
SigmoidSimilar to neural networksRarely used in practice

RBF Kernel Intuition: Imagine concentric circles of Class A surrounded by Class B — linear separation is impossible in 2D. The RBF kernel maps points to a 3D space (adding a "height" feature based on distance from center) where a flat plane separates the lifted Class A from Class B.

SVM vs. Modern Alternatives

FeatureSVMRandom ForestXGBoostNeural Network
Small datasets (<10K)ExcellentGoodGoodPoor (overfits)
Large datasets (>100K)Slow (O(N²-N³))GoodExcellentExcellent
High-dimensional (text, genomics)ExcellentGoodGoodExcellent
InterpretabilityModerate (support vectors)Good (feature importance)GoodPoor (black box)
Training timeSlow for large NFastFastVariable

When to Use SVM

  • Text Classification: High-dimensional sparse features (TF-IDF vectors) with relatively few samples — SVM's strength.
  • Bioinformatics: Gene expression classification — few samples, thousands of features.
  • Small Datasets: When you have <10,000 samples and need strong generalization.
  • NOT for: Large datasets (>100K samples) where training time becomes prohibitive — use XGBoost or neural networks instead.

Support Vector Machines are the mathematically elegant algorithm for classification with maximum-margin separation — providing strong generalization guarantees through the margin-maximizing objective, efficient handling of high-dimensional data through the kernel trick, and memory-efficient models that depend only on support vectors, making them the algorithm of choice for small datasets with high-dimensional features.

Take svm further

Ask the copilot about this term, or have our engineers assess it against your process.