|
enum | AnalysisMode { MAX_VARIANCE =0,
MAX_NUM_PCS
} |
|
|
bool | computeFeatureVector_ (const MatrixDouble &data, UINT analysisMode) |
|
double | SQR (const double &x) const |
|
GRT::PrincipalComponentAnalysis::PrincipalComponentAnalysis |
( |
| ) |
|
GRT::PrincipalComponentAnalysis::~PrincipalComponentAnalysis |
( |
| ) |
|
|
virtual |
bool GRT::PrincipalComponentAnalysis::computeFeatureVector |
( |
const MatrixDouble & |
data, |
|
|
double |
maxVariance = 0.95 , |
|
|
bool |
normData = false |
|
) |
| |
Runs the principal component analysis algorithm on the input data and builds the resulting feature vector so new data can be projected onto the principal subspace (using the project function). The number of principal components is automatically computed by selecting the minimum number of components that reach the maxVariance value. This should be a value between [0 1], the default value of 0.95 represents 95% of the variance in the original dataset.
- Parameters
-
const | MatrixDouble &data: a matrix containing the data from which the principal components will be computed. This should be an [M N] matrix, where M==samples and N==dimensions. |
double | maxVariance: sets the variance that should represented by the top K principal components. This should be a value between [0 1]. Default value=0.95 |
bool | normData: sets if the data will be z-normalized before running the PCA algorithm. Default value=false |
- Returns
- returns true if the principal components of the input matrix could be computed, false otherwise value
Definition at line 46 of file PrincipalComponentAnalysis.cpp.
bool GRT::PrincipalComponentAnalysis::computeFeatureVector |
( |
const MatrixDouble & |
data, |
|
|
UINT |
numPrincipalComponents, |
|
|
bool |
normData = false |
|
) |
| |
Runs the principal component analysis algorithm on the input data and builds the resulting feature vector so new data can be projected onto the principal subspace (using the project function). The number of principal components should be set be the user and must be less than or equal to the number of dimensions in the input data.
- Parameters
-
const | MatrixDouble &data: a matrix containing the data from which the principal components will be computed. This should be an [M N] matrix, where M==samples and N==dimensions |
UINT | numPrincipalComponents: sets the number of principal components. This must be a value be less than or equal to the number of dimensions in the input data |
bool | normData: sets if the data will be z-normalized before running the PCA algorithm. Default value=false |
- Returns
- returns true if the principal components of the input matrix could be computed, false otherwise value
Definition at line 53 of file PrincipalComponentAnalysis.cpp.
VectorDouble GRT::PrincipalComponentAnalysis::getComponentWeights |
( |
| ) |
const |
|
inline |
Returns the weights for each principal component, these weights sum to 1.
- Returns
- returns a vector of the weights for each principal component, these weights sum to 1
Definition at line 162 of file PrincipalComponentAnalysis.h.
VectorDouble GRT::PrincipalComponentAnalysis::getEigenValues |
( |
| ) |
const |
|
inline |
Returns the raw eigen values (these are not sorted).
- Returns
- returns a vector of the raw eigen values
Definition at line 168 of file PrincipalComponentAnalysis.h.
MatrixDouble GRT::PrincipalComponentAnalysis::getEigenVectors |
( |
| ) |
const |
Returns a matrix containing the eigen vectors.
- Returns
- returns a matrix containing the raw eigen vectors
Definition at line 277 of file PrincipalComponentAnalysis.cpp.
double GRT::PrincipalComponentAnalysis::getMaxVariance |
( |
| ) |
const |
|
inline |
Returns the maxVariance parameter, set by the user when the computeFeatureVector was called. returns the maxVariance parameter, set by the user when the computeFeatureVector was called
Definition at line 141 of file PrincipalComponentAnalysis.h.
VectorDouble GRT::PrincipalComponentAnalysis::getMeanVector |
( |
| ) |
const |
|
inline |
Returns the mean shift vector, computed during the computeFeatureVector function. New data will be subtracted by this value before it is projected onto the principal subspace.
- Returns
- returns the mean shift vector, computed during the computeFeatureVector function
Definition at line 148 of file PrincipalComponentAnalysis.h.
bool GRT::PrincipalComponentAnalysis::getNormData |
( |
| ) |
const |
|
inline |
Returns true if z-normalization is being applied to new data.
- Returns
- returns true if the normData is true, false otherwise
Definition at line 123 of file PrincipalComponentAnalysis.h.
UINT GRT::PrincipalComponentAnalysis::getNumInputDimensions |
( |
| ) |
const |
|
inline |
Returns the number of input dimensions in the original input data.
- Returns
- returns the numInputDimensions parameter.
Definition at line 129 of file PrincipalComponentAnalysis.h.
UINT GRT::PrincipalComponentAnalysis::getNumPrincipalComponents |
( |
| ) |
const |
|
inline |
Returns the number of principal components that was required to reach the maxVariance parameter.
- Returns
- returns the number of principal components that was required to reach the maxVariance parameter
Definition at line 135 of file PrincipalComponentAnalysis.h.
VectorDouble GRT::PrincipalComponentAnalysis::getStdDevVector |
( |
| ) |
const |
|
inline |
Returns the standard deviation vector that is used to normalize new data, this is computed during the computeFeatureVector function. This is only used id the normData parameter is true. If true, new data will be z-normalized by this value before it is projected onto the principal subspace.
- Returns
- returns the stdDev vector, computed during the computeFeatureVector function
Definition at line 156 of file PrincipalComponentAnalysis.h.
bool GRT::PrincipalComponentAnalysis::getTrained |
( |
| ) |
const |
|
inline |
Returns true if the module was trained.
- Returns
- returns true if the module has been trained, false otherwise
Definition at line 117 of file PrincipalComponentAnalysis.h.
bool GRT::PrincipalComponentAnalysis::print |
( |
string |
title = "" | ) |
const |
|
virtual |
A helper function that prints the PCA info. If the user sets the title string, then this will be written in addition with the PCA data.
Definition at line 252 of file PrincipalComponentAnalysis.cpp.
Projects the input data matrix onto the principal subspace. The new projected data will be stored in the prjData matrix. The computeFeatureVector function should have been called at least once before this function is called. The number of the columns in the data matrix must match the numInputDimensions parameter. The function will return true if the projection was successful, false otherwise.
- Parameters
-
const | MatrixDouble &data: The data that should be projected onto the principal subspace. This should be an [M N] matrix, where N must equal the numInputDimensions value (there are no restrictions on M). |
MatrixDouble | &prjData: A matrix into which the projected data will be stored. This matrix will be resized to [M K], where M is the number of rows in the data matrix and K is the numPrincipalComponents. |
- Returns
- returns true if the projection was successful, false otherwise
Definition at line 178 of file PrincipalComponentAnalysis.cpp.
bool GRT::PrincipalComponentAnalysis::project |
( |
const VectorDouble & |
data, |
|
|
VectorDouble & |
prjData |
|
) |
| |
Projects the input data vector onto the principal subspace. The new projected data will be stored in the prjData vector. The computeFeatureVector function should have been called at least once before this function is called. The size of the data vector must match the numInputDimensions parameter. The function will return true if the projection was successful, false otherwise.
- Parameters
-
const | VectorDouble &data: The data that should be projected onto the principal subspace. This should be an N-dimensional vector, where N must equal the numInputDimensions value. |
VectorDouble | &prjData: A vector into which the projected data will be stored. This vector will be resized to K, where K is the numPrincipalComponents. |
- Returns
- returns true if the projection was successful, false otherwise
Definition at line 216 of file PrincipalComponentAnalysis.cpp.
The documentation for this class was generated from the following files: