Using Principal Component Analysis to find things that matter
Kernel PCA, in contrast to the PCA method that we just introduced, uses a user-defined kernel function to map the dataset with n dimensions to an m-dimensional feature space. PCA uses a linear function for the mapping and is equivalent to Kernel PCA with a linear kernel.
Kernel PCA can be especially useful if the data cannot be linearly separable so various nonlinear kernels can be used to map your data to higher dimensions.
Getting ready
To execute this recipe, you will need pandas
and Scikit
. No other prerequisites are required.
How to do it…
Once again, we wrap our model in a method so that we can track how long it takes for the model to converge. With Kernel PCA, you should expect significantly longer estimation times (the reduce_kernelPCA.py
file):
@hlp.timeit def reduce_KernelPCA(x, **kwd_params): ''' Reduce the dimensions using Principal Component Analysis with different kernels ''' # create the PCA...