In machine learning, the radial basis function kernel, or RBF kernel, is a popular kernel function used in various kernelized learning algorithms. In particular, it is commonly used in support vector machine classification.
The RBF kernel on two samples
, represented as feature vectors in some input space, is defined as
%3D%5Cexp%20%5Cleft(-%7B%5Cfrac%20%7B%5C%7C%5Cmathbf%20%7Bx%7D%20-%5Cmathbf%20%7Bx%26apos%3B%7D%20%5C%7C%5E%7B2%7D%7D%7B2%5Csigma%20%5E%7B2%7D%7D%7D%5Cright)%7D%3C%2Ftitle%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22transparent%22%2F%3E%3C%2Fsvg%3E)
may be recognized as the squared Euclidean distance between the two feature vectors.
is a free parameter. An equivalent definition involves a parameter
:
%3D%5Cexp(-%5Cgamma%20%5C%7C%5Cmathbf%20%7Bx%7D%20-%5Cmathbf%20%7Bx%26apos%3B%7D%20%5C%7C%5E%7B2%7D)%7D%3C%2Ftitle%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22transparent%22%2F%3E%3C%2Fsvg%3E)
Since the value of the RBF kernel decreases with distance and ranges between zero (in the infinite-distance limit) and one (when x = x'), it has a ready interpretation as a similarity measure.
The feature space of the kernel has an infinite number of dimensions; for
, its expansion using the multinomial theorem is:
![{\displaystyle {\begin{alignedat}{2}\exp \left(-{\frac {1}{2}}\|\mathbf {x} -\mathbf {x'} \|^{2}\right)&=\exp \left({\frac {2}{2}}\mathbf {x} ^{\top }\mathbf {x'} -{\frac {1}{2}}\|\mathbf {x} \|^{2}-{\frac {1}{2}}\|\mathbf {x'} \|^{2}\right)\\[5pt]&=\exp \left(\mathbf {x} ^{\top }\mathbf {x'} \right)\exp \left(-{\frac {1}{2}}\|\mathbf {x} \|^{2}\right)\exp \left(-{\frac {1}{2}}\|\mathbf {x'} \|^{2}\right)\\[5pt]&=\sum _{j=0}^{\infty }{\frac {(\mathbf {x} ^{\top }\mathbf {x'} )^{j}}{j!}}\exp \left(-{\frac {1}{2}}\|\mathbf {x} \|^{2}\right)\exp \left(-{\frac {1}{2}}\|\mathbf {x'} \|^{2}\right)\\[5pt]&=\sum _{j=0}^{\infty }\quad \sum _{n_{1}+n_{2}+\dots +n_{k}=j}\exp \left(-{\frac {1}{2}}\|\mathbf {x} \|^{2}\right){\frac {x_{1}^{n_{1}}\cdots x_{k}^{n_{k}}}{\sqrt {n_{1}!\cdots n_{k}!}}}\exp \left(-{\frac {1}{2}}\|\mathbf {x'} \|^{2}\right){\frac {{x'}_{1}^{n_{1}}\cdots {x'}_{k}^{n_{k}}}{\sqrt {n_{1}!\cdots n_{k}!}}}\\[5pt]&=\langle \varphi (\mathbf {x} ),\varphi (\mathbf {x'} )\rangle \end{alignedat}}}](data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%221%22%20height%3D%221%22%20viewBox%3D%220%200%201%201%22%20preserveAspectRatio%3D%22none%22%3E%3Ctitle%3E%7B%5Cdisplaystyle%20%7B%5Cbegin%7Balignedat%7D%7B2%7D%5Cexp%20%5Cleft(-%7B%5Cfrac%20%7B1%7D%7B2%7D%7D%5C%7C%5Cmathbf%20%7Bx%7D%20-%5Cmathbf%20%7Bx%26apos%3B%7D%20%5C%7C%5E%7B2%7D%5Cright)%26amp%3B%3D%5Cexp%20%5Cleft(%7B%5Cfrac%20%7B2%7D%7B2%7D%7D%5Cmathbf%20%7Bx%7D%20%5E%7B%5Ctop%20%7D%5Cmathbf%20%7Bx%26apos%3B%7D%20-%7B%5Cfrac%20%7B1%7D%7B2%7D%7D%5C%7C%5Cmathbf%20%7Bx%7D%20%5C%7C%5E%7B2%7D-%7B%5Cfrac%20%7B1%7D%7B2%7D%7D%5C%7C%5Cmathbf%20%7Bx%26apos%3B%7D%20%5C%7C%5E%7B2%7D%5Cright)%5C%5C%5B5pt%5D%26amp%3B%3D%5Cexp%20%5Cleft(%5Cmathbf%20%7Bx%7D%20%5E%7B%5Ctop%20%7D%5Cmathb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%3B%7D%20%5C%7C%5E%7B2%7D%5Cright)%7B%5Cfrac%20%7B%7Bx%26apos%3B%7D_%7B1%7D%5E%7Bn_%7B1%7D%7D%5Ccdots%20%7Bx%26apos%3B%7D_%7Bk%7D%5E%7Bn_%7Bk%7D%7D%7D%7B%5Csqrt%20%7Bn_%7B1%7D!%5Ccdots%20n_%7Bk%7D!%7D%7D%7D%5C%5C%5B5pt%5D%26amp%3B%3D%5Clangle%20%5Cvarphi%20(%5Cmathbf%20%7Bx%7D%20)%2C%5Cvarphi%20(%5Cmathbf%20%7Bx%26apos%3B%7D%20)%5Crangle%20%5Cend%7Balignedat%7D%7D%7D%3C%2Ftitle%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22transparent%22%2F%3E%3C%2Fsvg%3E)
where
,
%7D%3D%7B%5Cfrac%20%7Bx_%7B1%7D%5E%7Bn_%7B1%7D%7D%5Ccdots%20x_%7Bk%7D%5E%7Bn_%7Bk%7D%7D%7D%7B%5Csqrt%20%7Bn_%7B1%7D!%5Ccdots%20n_%7Bk%7D!%7D%7D%7D%5Cquad%20%7C%5Cquad%20n_%7B1%7D%2Bn_%7B2%7D%2B%5Cdots%20%2Bn_%7Bk%7D%3Dj%5Cwedge%201%5Cleq%20%5Cell%20%5Cleq%20%5Cell%20_%7Bj%7D%7D%3C%2Ftitle%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22transparent%22%2F%3E%3C%2Fsvg%3E)