Lably
Skip to content

Radial basis function kernel

  • 1 min read
  • 1 chapter

Related on Lably

Through Machine learning and Euclidean distance

The RBF kernel on two samples x∈Rk and x′, represented as feature vectors in some input space, is defined as

K(x,x′)=exp⁡(−‖x−x′‖22σ2)

‖x−x′‖2 may be recognized as the squared Euclidean distance between the two feature vectors. σ is a free parameter. An equivalent definition involves a parameter γ=12σ2:

K(x,x′)=exp⁡(−γ‖x−x′‖2)

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 σ=1, its expansion using the multinomial theorem is:

exp⁡(−12‖x−x′‖2)=exp⁡(22x⊤x′−12‖x‖2−12‖x′‖2)=exp⁡(x⊤x′)exp⁡(−12‖x‖2)exp⁡(−12‖x′‖2)=∑j=0∞(x⊤x′)jj!exp⁡(−12‖x‖2)exp⁡(−12‖x′‖2)=∑j=0∞∑n1+n2+⋯+nk=jexp⁡(−12‖x‖2)x1n1⋯xknkn1!⋯nk!exp⁡(−12‖x′‖2)x′1n1⋯x′knkn1!⋯nk!=⟨φ(x),φ(x′)⟩
φ(x)=exp⁡(−12‖x‖2)(aℓ0(0),a1(1),…,aℓ1(1),…,a1(j),…,aℓj(j),…)

where ℓj=(k+j−1j),

aℓ(j)=x1n1⋯xknkn1!⋯nk!|n1+n2+⋯+nk=j∧1≤ℓ≤ℓj

Approximations

Because support vector machines and other models employing the kernel trick do not scale well to large numbers of training samples or large numbers of features in the input space, several approximations to the RBF kernel (and similar kernels) have been introduced. Typically, these take the form of a function z that maps a single vector to a vector of higher dimensionality, approximating the kernel:

⟨z(x),z(x′)⟩≈⟨φ(x),φ(x′)⟩=K(x,x′)

where φ is the implicit mapping embedded in the RBF kernel.

Fourier random features


One way to construct such a z is to randomly sample from the Fourier transformation of the kernelφ(x)=1D[cos⁡⟨w1,x⟩,sin⁡⟨w1,x⟩,…,cos⁡⟨wD,x⟩,sin⁡⟨wD,x⟩]Twhere w1,...,wD are independent samples from the normal distribution N(0,σ−2I).

Theorem: E⁡[⟨φ(x),φ(y)⟩]=e‖x−y‖2/(2σ2).

Proof: It suffices to prove the case of D=1. Use the trigonometric identity cos⁡(a−b)=cos⁡(a)cos⁡(b)+sin⁡(a)sin⁡(b), the spherical symmetry of gaussian distribution, then evaluate the integral

∫−∞∞cos⁡(kx)e−x2/22πdx=e−k2/2.

Theorem: Var⁡[⟨φ(x),φ(y)⟩]=O(D−1). (Appendix A.2).

Nyström method

Another approach uses the Nyström method to approximate the eigendecomposition of the Gram matrix K, using only a random sample of the training set.

More in Statistics