mlpack::pca::PCA(3) This class implements principal components analysis (PCA).

SYNOPSIS


Public Member Functions


PCA (const bool scaleData=false)
Create the PCA object, specifying if the data should be scaled in each dimension by standard deviation when PCA is performed.
void Apply (const arma::mat &data, arma::mat &transformedData, arma::vec &eigval, arma::mat &eigvec) const
Apply Principal Component Analysis to the provided data set.
void Apply (const arma::mat &data, arma::mat &transformedData, arma::vec &eigVal) const
Apply Principal Component Analysis to the provided data set.
double Apply (arma::mat &data, const size_t newDimension) const
Use PCA for dimensionality reduction on the given dataset.
double Apply (arma::mat &data, const int newDimension) const
This overload is here to make sure int gets casted right to size_t.
double Apply (arma::mat &data, const double varRetained) const
Use PCA for dimensionality reduction on the given dataset.
bool ScaleData () const
Get whether or not this PCA object will scale (by standard deviation) the data when PCA is performed.
bool & ScaleData ()
Modify whether or not this PCA object will scale (by standard deviation) the data when PCA is performed.
std::string ToString () const

Private Attributes


bool scaleData
Whether or not the data will be scaled by standard deviation when PCA is performed.

Detailed Description

This class implements principal components analysis (PCA).

This is a common, widely-used technique that is often used for either dimensionality reduction or transforming data into a better basis. Further information on PCA can be found in almost any statistics or machine learning textbook, and all over the internet.

Definition at line 38 of file pca.hpp.

Constructor & Destructor Documentation

mlpack::pca::PCA::PCA (const boolscaleData = false)

Create the PCA object, specifying if the data should be scaled in each dimension by standard deviation when PCA is performed.

Parameters:

scaleData Whether or not to scale the data.

Member Function Documentation

void mlpack::pca::PCA::Apply (const arma::mat &data, arma::mat &transformedData, arma::vec &eigval, arma::mat &eigvec) const

Apply Principal Component Analysis to the provided data set. It is safe to pass the same matrix reference for both data and transformedData.

Parameters:

data Data matrix.
transformedData Matrix to put results of PCA into.
eigval Vector to put eigenvalues into.
eigvec Matrix to put eigenvectors (loadings) into.

Referenced by Apply().

void mlpack::pca::PCA::Apply (const arma::mat &data, arma::mat &transformedData, arma::vec &eigVal) const

Apply Principal Component Analysis to the provided data set. It is safe to pass the same matrix reference for both data and transformedData.

Parameters:

data Data matrix.
transformedData Matrix to store results of PCA in.
eigval Vector to put eigenvalues into.

double mlpack::pca::PCA::Apply (arma::mat &data, const size_tnewDimension) const

Use PCA for dimensionality reduction on the given dataset. This will save the newDimension largest principal components of the data and remove the rest. The parameter returned is the amount of variance of the data that is retained; this is a value between 0 and 1. For instance, a value of 0.9 indicates that 90% of the variance present in the data was retained.

Parameters:

data Data matrix.
newDimension New dimension of the data.

Returns:

Amount of the variance of the data retained (between 0 and 1).

double mlpack::pca::PCA::Apply (arma::mat &data, const intnewDimension) const [inline]

This overload is here to make sure int gets casted right to size_t.

Definition at line 89 of file pca.hpp.

References Apply().

double mlpack::pca::PCA::Apply (arma::mat &data, const doublevarRetained) const

Use PCA for dimensionality reduction on the given dataset. This will save as many dimensions as necessary to retain at least the given amount of variance (specified by parameter varRetained). The amount should be between 0 and 1; if the amount is 0, then only 1 dimension will be retained. If the amount is 1, then all dimensions will be retained.

The method returns the actual amount of variance retained, which will always be greater than or equal to the varRetained parameter.

Parameters:

data Data matrix.
varRetained Lower bound on amount of variance to retain; should be between 0 and 1.

Returns:

Actual amount of variance retained (between 0 and 1).

bool mlpack::pca::PCA::ScaleData () const [inline]

Get whether or not this PCA object will scale (by standard deviation) the data when PCA is performed.

Definition at line 113 of file pca.hpp.

References scaleData.

bool& mlpack::pca::PCA::ScaleData () [inline]

Modify whether or not this PCA object will scale (by standard deviation) the data when PCA is performed.

Definition at line 116 of file pca.hpp.

References scaleData.

std::string mlpack::pca::PCA::ToString () const

Member Data Documentation

bool mlpack::pca::PCA::scaleData [private]

Whether or not the data will be scaled by standard deviation when PCA is performed.

Definition at line 124 of file pca.hpp.

Referenced by ScaleData().

Author

Generated automatically by Doxygen for MLPACK from the source code.