notesonly.in

One notebook for every subject — open it anywhere.

Log in

Support Vector Machines: Complete Beginner's Guide

A support vector machine classifies by drawing the best dividing line — hyperplane — between two classes: the one with the largest margin, the widest empty gap to the nearest points of each class. Those nearest points are the support vectors; they alone determine the boundary.

Max-margin is a principled way to generalize: a boundary far from all training points misclassifies fewer new ones. With the kernel trick — implicitly mapping data into higher dimensions where curved boundaries become straight — SVMs excel on text, images, and biological data, especially when training data is limited.

Key Concepts

  • Hyperplane: the decision boundary; a line in 2D, a plane in 3D, and beyond.
  • Margin: the distance from the boundary to the nearest training point; SVMs maximize it.
  • Support vectors: the points lying exactly on the margin edge; only they define the boundary.
  • Hard vs soft margin: soft margin (parameter C) allows a few misclassifications.
  • Kernel trick: curved boundaries via implicit high-dimensional similarity (linear, polynomial, RBF kernels).
  • C parameter: small C favors wide margins; large C favors fitting the training data.

Formulas

  • Hyperplane: w dot x + b = 0, where w is perpendicular to the boundary. Points with w dot x + b above 0 are one class, below 0 the other.
  • Margin width: 2 divided by the length of w — the total gap between margin edges. Maximizing it equals minimizing the length of w with every point correctly placed. Units match the feature-space distances.
  • Decision function: f(x) = sign(w dot x + b). A linear kernel assumes the true boundary is roughly straight.

Worked Example

Classify points on a number line: class A at x = 1 and x = 2; class B at x = 4 and x = 5. The widest-gap boundary sits at x = 3: nearest A point at distance |3 − 2| = 1, nearest B point at |3 − 4| = 1 — total margin width 2. In hyperplane form, w = 1 and b = −3 gives 1 times x − 3 = 0, that is, x = 3. Check: x = 2 gives −1 (class A); x = 4 gives +1 (class B). Formula check: 2 divided by the length of w = 2 divided by 1 = 2. The support vectors are x = 2 and x = 4 — remove any other point and the boundary does not move.

Common Misconceptions

  • SVMs need linearly separable data. Soft margins tolerate overlap and kernels bend the boundary.
  • SVMs are outdated. On small and medium tabular or text data they often match neural networks with far less tuning.
  • More support vectors means better. Few support vectors usually signal a clean, confident boundary.

Real-World Applications

  • Text classification: spam filtering and topic tagging on sparse, high-dimensional data.
  • Image recognition: face and object classification on modest datasets.
  • Bioinformatics: classifying genes and proteins from high-dimensional measurements.
  • Handwriting recognition: digit classifiers that long powered postal sorting.

A support vector machine finds the hyperplane w dot x + b = 0 with maximum margin 2 divided by the length of w, defined solely by its support vectors, with kernels extending it to curved boundaries. Elegant, data-efficient, and strong on limited data.