mlpack.pca

pca(...)
Principal Components Analysis

>>> from mlpack import pca

This program performs principal components analysis on the given dataset using the exact, randomized, randomized block Krylov, or QUIC SVD method. It will transform the data onto its principal components, optionally performing dimensionality reduction by ignoring the principal components with the smallest eigenvalues.

Use the 'input' parameter to specify the dataset to perform PCA on. A desired new dimensionality can be specified with the 'new_dimensionality' parameter, or the desired variance to retain can be specified with the 'var_to_retain' parameter. If desired, the dataset can be scaled before running PCA with the 'scale' parameter.

Multiple different decomposition techniques can be used. The method to use can be specified with the 'decomposition_method' parameter, and it may take the values 'exact', 'randomized', or 'quic'.

For example, to reduce the dimensionality of the matrix 'data' to 5 dimensions using randomized SVD for the decomposition, storing the output matrix to 'data_mod', the following command can be used:

>>> pca(input=data, new_dimensionality=5, decomposition_method='randomized')
>>> data_mod = output['output']

input options

output options

The return value from the binding is a dict containing the following elements: