Kernel method

From Wikipedia, the free encyclopedia
  (Redirected from Kernel trick)
Jump to: navigation, search

In machine learning, kernel methods are a class of algorithms for pattern analysis, whose best known member is the support vector machine (SVM). The general task of pattern analysis is to find and study general types of relations (for example clusters, rankings, principal components, correlations, classifications) in datasets. For many algorithms that solve these tasks, the data in raw representation have to be explicitly transformed into feature vector representations via a user-specified feature map: in contrast, kernel methods require only a user-specified kernel, i.e., a similarity function over pairs of data points in raw representation.

Kernel methods owe their name to the use of kernel functions, which enable them to operate in a high-dimensional, implicit feature space without ever computing the coordinates of the data in that space, but rather by simply computing the inner products between the images of all pairs of data in the feature space. This operation is often computationally cheaper than the explicit computation of the coordinates. This approach is called the "kernel trick". Kernel functions have been introduced for sequence data, graphs, text, images, as well as vectors.

Algorithms capable of operating with kernels include the kernel perceptron, support vector machines (SVM), Gaussian processes, principal components analysis (PCA), canonical correlation analysis, ridge regression, spectral clustering, linear adaptive filters and many others. Any linear model can be turned into a non-linear model by applying the kernel trick to the model: replacing its features (predictors) by a kernel function.

Most kernel algorithms are based on convex optimization or eigenproblems and are statistically well-founded. Typically, their statistical properties are analyzed using statistical learning theory (for example, using Rademacher complexity).

Motivation and informal explanation[edit]

Kernel methods can be thought of as instance-based learners: rather than learning some fixed set of parameters corresponding to the features of their inputs, they instead "remember" the i-th training example (\mathbf{x}_i, y_i) by learning a corresponding weight w_i. Prediction for unlabeled inputs, i.e., those not in the training set, is treated by the application of a similarity function k, called a kernel, between the unlabeled input \mathbf{x'} and each of the training inputs \mathbf{x}_i. For instance, a kernelized binary classifier typically computes a weighted sum of similarities

\hat{y} = \sgn \sum_{i=1}^n w_i y_i k(\mathbf{x}_i, \mathbf{x'}),


  • \hat{y} \in \{-1, +1\} is the kernelized binary classifier's predicted label for the unlabeled input \mathbf{x'} whose hidden true label y is of interest;
  • k \colon \mathcal{X} \times \mathcal{X} \to \mathbb{R} is the kernel function that measures similarity between any pair of inputs \mathbf{x}, \mathbf{x'} \in \mathcal{X};
  • the sum ranges over the n labeled examples \{(\mathbf{x}_i, y_i)\}_{i=1}^n in the classifier's training set, with y_i \in \{-1, +1\};
  • the w_i \in \mathbb{R} are the weights for the training examples, as determined by the learning algorithm;
  • the sign function \sgn determines whether the predicted classification \hat{y} comes out positive or negative.

Kernel classifiers were described as early as the 1960s, with the invention of the kernel perceptron.[1] They rose to great prominence with the popularity of the support vector machine (SVM) in the 1990s, when the SVM was found to be competitive with neural networks on tasks such as handwriting recognition.


The kernel trick avoids the explicit mapping that is needed to get linear learning algorithms to learn a nonlinear function or decision boundary. For all \mathbf{x} and \mathbf{x'} in the input space \mathcal{X}, certain functions k(\mathbf{x}, \mathbf{x'}) can be expressed as an inner product in another space \mathcal{V}. The function k \colon \mathcal{X} \times \mathcal{X} \to \mathbb{R} is often referred to as a kernel or a kernel function; the word "kernel" is used in different ways throughout mathematics.

If one is insightful regarding a particular machine learning problem, one may manually construct a "feature map" \varphi\colon \mathcal{X} \to \mathcal{V} such that

k(\mathbf{x}, \mathbf{x'}) = \langle \varphi(\mathbf{x}), \varphi(\mathbf{x'}) \rangle_\mathcal{V}

and verify that  \langle \cdot, \cdot \rangle_\mathcal{V} is indeed an inner product. In fact, an explicit representation for \varphi is not required: it suffices to show that \mathcal{V} is an inner product space. Conveniently, based on Mercer's theorem, it suffices to equip \mathcal{X} with one's choice of measure and verify that k satisfies Mercer's condition.

Mercer's theorem is stated in a general mathematical setting with implications in the theory of integral equations. However, the general statement is more than what is required for understanding the kernel trick. Given a finite observation set X, one can select the counting measure  \mu(T) = |T| for all  T \subset X . Then the integral in Mercer's theorem reduces to a simple summation

 \sum_{i=1}^n\sum_{j=1}^n k(\mathbf{x}_i, \mathbf{x}_j) c_i c_j \geq 0

for all finite sequences of points (\mathbf{x}_1, \dotsc, \mathbf{x}_n) in \mathcal{X} and all choices of n real-valued coefficients (c_1, \dots, c_n) (cf. positive definite kernel).

Some algorithms that depend on arbitrary relationships in the native space \mathcal{X} would, in fact, have a linear interpretation in a different setting: the range space of \varphi. The linear interpretation gives us insight about the algorithm. Furthermore, there is often no need to compute \varphi directly during computation, as is the case with support vector machines. Some cite this running time shortcut as the primary benefit. Researchers also use it to justify the meanings and properties of existing algorithms.

Theoretically, a Gram matrix \mathbf{K} \in \mathbb{R}^{n \times n} with respect to \{\mathbf{x}_1, \dotsc, \mathbf{x}_n\} (sometimes also called a "kernel matrix"[2]), where \mathbf{K} = (k(\mathbf{x}_i, \mathbf{x}_j))_{ij}, must be positive semi-definite (PSD).[3] Empirically, for machine learning heuristics, choices of a function k that do not satisfy Mercer's condition may still perform reasonably if k at least approximates the intuitive idea of similarity.[4] Regardless of whether k is a Mercer kernel, k may still be referred to as a "kernel".

If the kernel function k is also a covariance function as used in Gaussian processes, then the Gram matrix \mathbf{K} can also be called a covariance matrix.[5]

Lastly, suppose \mathbf{K} is any square matrix, then \mathbf{K}^\mathrm{T}\mathbf{K} is a PSD matrix.


Application areas of kernel methods are diverse and include geostatistics,[6] kriging, inverse distance weighting, 3D reconstruction, bioinformatics, chemoinformatics, information extraction and handwriting recognition.

Popular kernels[edit]

See also[edit]


  1. ^ Aizerman, M. A.; Emmanuel M. Braverman; L. I. Rozoner (1964). "Theoretical foundations of the potential function method in pattern recognition learning". Automation and Remote Control 25: 821–837.  Cited in Guyon, Isabelle; B. Boser; Vladimir Vapnik (1993). Automatic capacity tuning of very large VC-dimension classifiers. Advances in neural information processing systems. 
  2. ^ Thomas Hofmann, Bernhard Scholkopf, Alexander J. Smola (2008) Kernel Methods in Machine Learning.
  3. ^ Mehryar Mohri, Afshin Rostamizadeh, Ameet Talwalkar (2012) Foundations of Machine Learning, The MIT Press ISBN 9780262018258.
  4. ^
  5. ^ C. E. Rasmussen, C. K. I. Williams (2006) Gaussian Processes for Machine Learning.
  6. ^ Honarkhah, M and Caers, J, 2010, Stochastic Simulation of Patterns Using Distance-Based Pattern Modeling, Mathematical Geosciences, 42: 487 - 517


  • J. Shawe-Taylor and N. Cristianini. Kernel Methods for Pattern Analysis. Cambridge University Press, 2004.
  • W. Liu, J. Principe and S. Haykin. Kernel Adaptive Filtering: A Comprehensive Introduction. Wiley, 2010.

External links[edit]