Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 1.43 KB

File metadata and controls

17 lines (13 loc) · 1.43 KB

PCA

Kernel PCA

We know the kernel trick, a mathematical technique that implicitlymaps instances into a very high-dimensional space (called the feature space), enabling nonlinear classification and regression with Support Vector Machines. Recall that a linear decision boundary in the high-dimensional feature space corresponds to a complex nonlinear decision boundary in the original space.

It turns out that the same trick can be applied to PCA, making it possible to perform complex nonlinear projections for dimensionality reduction. This is called Kernel PCA (kPCA). It is often good at preserving clusters of instances after projection, or sometimes even unrolling datasets that lie close to a twisted manifold.

For example, the following code uses Scikit-Learn’s KernelPCA class to perform kPCA with an RBF kernel:

  from sklearn.decomposition import KernelPCA
  rbf_pca = KernelPCA(n_components = 2, kernel="rbf", gamma=0.04)
  X_reduced = rbf_pca.fit_transform(X)

In below Figure shows the Swiss roll, reduced to two dimensions using a linear kernel (equivalent to simply using the PCA class), an RBF kernel, and a sigmoid kernel (Logistic).

image Figure. Swiss roll reduced to 2D using kPCA with various kernels