![]() |
latest version v1.9 - last update 10 Apr 2010 |
![]() |
Functor for sequentially computing a principal component analysis. More...
#include <ltiSerialPCA.h>
Classes | |
class | parameters |
the parameters for the class serialPCA More... | |
Public Member Functions | |
serialPCA () | |
serialPCA (const serialPCA &other) | |
virtual | ~serialPCA () |
virtual const char * | getTypeName () const |
bool | consider (const matrix< T > &data) |
bool | consider (const vector< T > &data) |
bool | reset () |
bool | apply (const matrix< T > &src, matrix< T > &dest) |
bool | apply (matrix< T > &srcdest) |
bool | apply (const vector< T > &src, vector< T > &result) |
bool | transform (const vector< T > &src, vector< T > &result) |
bool | transform (const matrix< T > &src, matrix< T > &result) |
bool | getTransformMatrix (matrix< T > &result) const |
const matrix< T > & | getTransformMatrix () const |
bool | getEigenValues (vector< T > &result) const |
const vector< T > & | getEigenValues () const |
bool | getEigenVectors (matrix< T > &result) const |
bool | getEigenVectorsInRows (matrix< T > &result) const |
const matrix< T > & | getEigenVectors () const |
void | setDimension (int k) |
serialPCA & | copy (const serialPCA &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
virtual bool | updateParameters () |
virtual bool | read (ioHandler &handler, const bool complete=true) |
virtual bool | write (ioHandler &handler, const bool complete=true) const |
Protected Member Functions | |
int | checkDim () |
Functor for sequentially computing a principal component analysis.
It receives a set of input vectors in form of a matrix (each row of the matrix corresponds to an input vector), which will be transformed with PCA.
The first time you use the apply()-method, the transformation matrix will be computed. You can use this transformation matrix with other data sets using the transform() methods.
Please note that the eigenvector matrices will contain the eigenvector in the COLUMNS and not in the rows, as could be expected. This avoids the requirement of transposing matrices in the vector transformations (see also lti::eigenSystem<T>).
lti::serialPCA< T >::serialPCA | ( | ) |
default constructor
lti::serialPCA< T >::serialPCA | ( | const serialPCA< T > & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::serialPCA< T >::~serialPCA | ( | ) | [virtual] |
destructor
bool lti::serialPCA< T >::apply | ( | const vector< T > & | src, | |
vector< T > & | result | |||
) | [inline] |
Transforms a single vector according to a previously computed transformation matrix.
References lti::serialPCA< T >::transform().
bool lti::serialPCA< T >::apply | ( | matrix< T > & | srcdest | ) |
On-Place version of the transformation.
Computes the principal components of the previously considered data points and applies it to the given data matrix. The result is the transformed matrix. This method uses the eigenvector functor given in the parameters. By default, it uses ltilib's own jacobi functor. However, you can speed it up considerably by using the eigensystem functor in the lamath directory.
srcdest | matrix<T> with the source data, which will also contain the result. |
srcdest
. bool lti::serialPCA< T >::apply | ( | const matrix< T > & | src, | |
matrix< T > & | dest | |||
) |
Computes the principal components of the previously considered data points and applies it to the given data matrix.
The result is the transformed matrix. data and result must not be references to the same matrix. This method uses the eigenvector functor given in the parameters. By default, it uses ltilib's own jacobi functor. However, you can speed it up considerably by using the eigensystem functor in the lamath directory.
src | matrix<T> with the source data. | |
dest | matrix<T> with the result data. |
int lti::serialPCA< T >::checkDim | ( | ) | [protected] |
Determines the intrinsic dimensionality of the data set if the user specify autoDim, otherwise return parameters::resultDim.
The member usedDimensionality will be set with the returned value
virtual functor* lti::serialPCA< T >::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Implements lti::functor.
bool lti::serialPCA< T >::consider | ( | const vector< T > & | data | ) |
Consider a vector in the estimation of the covariance/correlation matrix.
You can later call the transform() method or the apply method to transform the data.
Each time you call this method, the current transformation matrix is invalidated and later recomputed when you call a transform method. Then, all data considered so far will be used in the covariance/correlation matrix estimation.
data | matrix<T> with the source data. |
bool lti::serialPCA< T >::consider | ( | const matrix< T > & | data | ) |
Consider the given data for the computation of a principal components transformation matrix.
You can later call the transform() method or the apply method to transform the data.
Each time you call this method, the current transformation matrix is invalidated and later recomputed when you call a transform method. Then, all data considered so far will be used in the covariance/correlation matrix estimation.
data | matrix<T> with the source data. |
serialPCA& lti::serialPCA< T >::copy | ( | const serialPCA< T > & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::functor.
const vector<T>& lti::serialPCA< T >::getEigenValues | ( | ) | const |
Returns the previously computed eigenvalues of the covariance matrix.
bool lti::serialPCA< T >::getEigenValues | ( | vector< T > & | result | ) | const |
const matrix<T>& lti::serialPCA< T >::getEigenVectors | ( | ) | const |
Returns the previously computed eigenvectors of the covariance matrix.
bool lti::serialPCA< T >::getEigenVectors | ( | matrix< T > & | result | ) | const |
bool lti::serialPCA< T >::getEigenVectorsInRows | ( | matrix< T > & | result | ) | const |
Returns the previously computed eigenvectors of the covariance matrix.
This method will call the normal getEigenVectors() methods and after that will transpose the obtained matrix, i.e. it is faster to get the eigenvectors in the columns.
result | the matrix which will receive the eigenvectors. Each row of the matrix contains one eigenvector. |
const parameters& lti::serialPCA< T >::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::functor.
const matrix<T>& lti::serialPCA< T >::getTransformMatrix | ( | ) | const |
bool lti::serialPCA< T >::getTransformMatrix | ( | matrix< T > & | result | ) | const |
virtual const char* lti::serialPCA< T >::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("serialPCA")
Reimplemented from lti::linearAlgebraFunctor.
virtual bool lti::serialPCA< T >::read | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | [virtual] |
Reads this functor from the given handler.
Reimplemented from lti::functor.
bool lti::serialPCA< T >::reset | ( | ) |
Reset the data.
Removes all data considered until now and set the functor as in the initial empty state.
void lti::serialPCA< T >::setDimension | ( | int | k | ) |
Set the dimension to which the vectors should be reduced.
bool lti::serialPCA< T >::transform | ( | const matrix< T > & | src, | |
matrix< T > & | result | |||
) |
bool lti::serialPCA< T >::transform | ( | const vector< T > & | src, | |
vector< T > & | result | |||
) |
Transforms a single vector according to a previously computed transformation matrix.
result
Referenced by lti::serialPCA< T >::apply().
virtual bool lti::serialPCA< T >::updateParameters | ( | ) | [virtual] |
Update functor's parameters.
Initialize some internal data according to the parameters.
Reimplemented from lti::functor.
virtual bool lti::serialPCA< T >::write | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | const [virtual] |
Writes this functor to the given handler.
Reimplemented from lti::functor.