watex.analysis.kPCA#
- watex.analysis.kPCA(X, n_components=None, *, return_X=True, kernel='rbf', reconstruct_pre_image=False, **kpca_kws)[source]#
Kernel PCA
kPCA performs complex nonlinear projections for dimentionality reduction.
Commonly the kernel tricks is a mathematically technique that implicitly maps instances into a very high-dimensionality space(called the feature space), enabling non linear classification or regression with SVMs. Recall that a linear decision boundary in the high dimensional feature space corresponds to a complex non-linear decison boundary in the original space.
- Parameters
X (Ndarray ( M x N matrix where
M=m-samples, &N=n-features)) – Training set; Denotes data that is observed at training and prediction time, used as independent variables in learning. When a matrix, each sample may be represented by a feature vector, or a vector of precomputed (dis)similarity with each training sample.Xmay also not be a matrix, and may require a feature extractor or a pairwise metric to turn it into one before learning a model.n_components (int, optional) – Number of dimension to preserve. If`n_components` is ranged between float 0. to 1., it indicated the number of variance ratio to preserve. If
Noneas default value the number of variance to preserve is95%.return_X (bool, default =True ,) – return the train set transformed with most representative varaince ratio.
kernel ({'linear', 'poly', 'rbf', 'sigmoid', 'cosine', 'precomputed'}, default='rbf') – Kernel used for PCA.
kpca_kws (dict,) – Additional keyword arguments passed to
sklearn.decomposition.KernelPCA
- Returns
The transformed training set or the kPCA container attributes for plotting purposes.
- Return type
X (NDArray) or kPCA object,
Examples
>>> from watex.analysis.dimensionality import kPCA >>> from watex.datasets import fetch_data >>> X, _=fetch_data('Bagoue analysis data') >>> Xtransf=kPCA(X,n_components=None,kernel='rbf', gamma=0.04, view=True)