Motivation: Nonlinear decision boundaries

Linear methods fail when the true boundary is curved (e.g. a circle, or XOR). Lift the data into higher-dimensional space where it becomes linearly separable.

Key Idea

Transform to a higher dimensional space.

Input space: the space where the points are located Feature space: the space of after transformation

Linear operation in the feature space is equivalent to non-linear operation in the input space

XOR

The map makes XOR separable: the product coordinate captures the interaction.

, where , ,

In the original 2D space on the left, the yellow and purple points form concentric circles. A standard SVM cannot draw a straight line to separate these two classes.

So we apply a feature map that maps the 2D coordinates into a 3D feature space using specific polynomial transformation. In this new 3D space shown in the middle, the data is now linearly separable. The SVM can easily insert a flat 2D plane to slice between the points.

When that flat 3D decision boundary is translated back to the original 2D space, it forms the perfect circular boundary seen in the right plot.

The kernel trick and Gram matrix

The kernel method lets linear algorithms (like SVM) to operate in very high (even infinite-dimensional) feature spaces without ever explicitly computing the feature map.

In the dual representation of SVMs, the solution is expressed using a Gram matrix.

  • Instead of computing standard dot products , the algorithm replaces them with a kernel function:
  • If the algorithm depends exclusively on this Gram matrix, we never have to compute or know the actual high-dimensional features of .

What's the kernel trick buying us?

Nonlinear decision boundaries at linear-algorithm prices: skip the explicit high-dimensional lift while getting its expressive power.

Another POV: kernel function, being an inner product, is really a similarity measure between the objects

Properties of a valid kernel

To use a shortcut function as a kernel, it must be a symmetric function where matrices formed by any finite subset of points are positive semi-definite

Theorem

A function can be written as where is a feature map iff satisfies the semi-definiteness property.

Symmetric: the order of the inputs does not matter.

Positive semi-definite (PSD): a matrix is PSD if multiplying it by our test vector and its transpose always results in a number , no matter what number are in the vector.

So all of this allows us to check if is a proper kernel without needing to know the feature map, i.e. using only properties of itself.

Common Kernels

  • Linear: (inner product)
  • Polynomial: (inner product, degree i.e. polynomial order)
  • Gaussian:
  • RBF (Radial Basis Function):
    • if is very small the model considers all data to be dissimilar, which leads to over-fitting
    • if is very large the model considers all data to be very similar, which leads to under-fitting.

Predicting a new point : we don’t need explicitly. The model evaluates the sign of the decision function:

Each non-zero indicates that corresponding is a support vector.

Complexity

  • Linear-kernel SVM: training, test time
  • General-kernel SVM: to build the Gram matrix at training, test time (loop over support vectors)

So kernels aren’t free: there’s a dataset-size penalty. Worth it when is small or moderate and the true boundary is nonlinear.