bpp-core
2.2.0
|
This class allows to perform a principal component analysis. More...
#include <Bpp/Numeric/Stat/Mva/PrincipalComponentAnalysis.h>
Public Member Functions | |
PrincipalComponentAnalysis (const Matrix< double > &data, unsigned int nbAxes, const std::vector< double > &rowW, const std::vector< double > &colW, bool centered=true, bool scaled=true, double tol=0.0000001, bool verbose=true) throw (Exception) | |
Build a new PrincipalComponentAnalysis object. More... | |
PrincipalComponentAnalysis (const Matrix< double > &data, unsigned int nbAxes, bool centered=true, bool scaled=true, double tol=0.0000001, bool verbose=true) throw (Exception) | |
Build a new PrincipalComponentAnalysis object and specify default row and column weights. More... | |
virtual | ~PrincipalComponentAnalysis () |
PrincipalComponentAnalysis * | clone () const |
Create a copy of this object and send a pointer to it. More... | |
const std::vector< double > & | getColumnMeans () const throw (Exception) |
const std::vector< double > & | getColumnSd () const throw (Exception) |
void | setData (const Matrix< double > &matrix, const std::vector< double > &rowWeights, const std::vector< double > &colWeights, unsigned int nbAxes, double tol=0.0000001, bool verbose=true) throw (Exception) |
Set the data and perform computations. More... | |
std::vector< double > | computeVariancePercentagePerAxis () throw (Exception) |
size_t | getNbOfKeptAxes () const throw (Exception) |
const std::vector< double > | getRowWeights () const throw (Exception) |
const std::vector< double > | getColumnWeights () const throw (Exception) |
const std::vector< double > & | getEigenValues () const throw (Exception) |
const RowMatrix< double > & | getRowCoordinates () const throw (Exception) |
const RowMatrix< double > & | getColCoordinates () const throw (Exception) |
const RowMatrix< double > & | getPrincipalAxes () const throw (Exception) |
const RowMatrix< double > & | getPrincipalComponents () const throw (Exception) |
Static Public Member Functions | |
static void | center (Matrix< double > &matrix, const std::vector< double > &rowW) throw (Exception) |
This function allows to center an input matrix from its column means. More... | |
static void | scale (Matrix< double > &matrix, const std::vector< double > &rowW) throw (Exception) |
This function allows to center an input matrix from its column means. More... | |
Private Attributes | |
std::vector< double > | columnMeans_ |
std::vector< double > | columnSd_ |
This class allows to perform a principal component analysis.
Two constructors are available. The first one allows the user to specify the row and column weights. The second one specify default weights: uniform weights unit weights are created for rows and columns respectively.
The code of this class is deeply inspired from the R code of the dudi.pca function available in the ade4 package.
Definition at line 57 of file PrincipalComponentAnalysis.h.
PrincipalComponentAnalysis::PrincipalComponentAnalysis | ( | const Matrix< double > & | data, |
unsigned int | nbAxes, | ||
const std::vector< double > & | rowW, | ||
const std::vector< double > & | colW, | ||
bool | centered = true , |
||
bool | scaled = true , |
||
double | tol = 0.0000001 , |
||
bool | verbose = true |
||
) | |||
throw | ( | Exception | |
) |
Build a new PrincipalComponentAnalysis object.
data | The input data (a RowMatrix) to analyse. |
nbAxes | The number of kept axes during the analysis. |
rowW | A vector of values specifying the weights of rows. |
colW | A vector of values specifying the weights of columns. |
centered | If true the input matrix is centered according to the column means. |
scaled | If true the input matrix is normalized according to the standard deviations of columns. |
tol | Tolerance threshold for null eigenvalues (a value less than tol times the first one is considered as null) |
verbose | Should warnings be dispayed. |
Exception | if an error occured. |
Definition at line 50 of file PrincipalComponentAnalysis.cpp.
Referenced by clone().
PrincipalComponentAnalysis::PrincipalComponentAnalysis | ( | const Matrix< double > & | data, |
unsigned int | nbAxes, | ||
bool | centered = true , |
||
bool | scaled = true , |
||
double | tol = 0.0000001 , |
||
bool | verbose = true |
||
) | |||
throw | ( | Exception | |
) |
Build a new PrincipalComponentAnalysis object and specify default row and column weights.
data | The input data (a RowMatrix) to analyse. |
nbAxes | The number of kept axes during the analysis. |
centered | If true the input matrix is centered according to the column means. |
scaled | If true the input matrix is normalized according to the standard deviations of columns. |
tol | Tolerance threshold for null eigenvalues (a value less than tol times the first one is considered as null) |
verbose | Should warnings be dispayed. |
Exception | if an error occured. |
Definition at line 82 of file PrincipalComponentAnalysis.cpp.
References bpp::VectorTools::fill().
|
inlinevirtual |
Definition at line 109 of file PrincipalComponentAnalysis.h.
|
static |
This function allows to center an input matrix from its column means.
matrix | The input data (a Matrix) to center. |
rowW | A vector with row weights. |
Definition at line 120 of file PrincipalComponentAnalysis.cpp.
References bpp::VectorTools::sum().
|
inlinevirtual |
Create a copy of this object and send a pointer to it.
Reimplemented from bpp::DualityDiagram.
Definition at line 111 of file PrincipalComponentAnalysis.h.
References PrincipalComponentAnalysis().
|
inherited |
|
inlineinherited |
Definition at line 151 of file DualityDiagram.h.
References bpp::DualityDiagram::colCoord_.
|
inline |
Definition at line 131 of file PrincipalComponentAnalysis.h.
References columnMeans_.
|
inline |
Definition at line 132 of file PrincipalComponentAnalysis.h.
References columnSd_.
|
inlineinherited |
Definition at line 148 of file DualityDiagram.h.
References bpp::DualityDiagram::colWeights_.
|
inlineinherited |
Definition at line 149 of file DualityDiagram.h.
References bpp::DualityDiagram::eigenValues_.
|
inlineinherited |
Definition at line 146 of file DualityDiagram.h.
References bpp::DualityDiagram::nbAxes_.
|
inlineinherited |
Definition at line 152 of file DualityDiagram.h.
References bpp::DualityDiagram::ppalAxes_.
|
inlineinherited |
Definition at line 153 of file DualityDiagram.h.
References bpp::DualityDiagram::ppalComponents_.
|
inlineinherited |
Definition at line 150 of file DualityDiagram.h.
References bpp::DualityDiagram::rowCoord_.
|
inlineinherited |
Definition at line 147 of file DualityDiagram.h.
References bpp::DualityDiagram::rowWeights_.
|
static |
This function allows to center an input matrix from its column means.
matrix | The input data (a Matrix) to center. |
rowW | A vector with row weights. |
Definition at line 151 of file PrincipalComponentAnalysis.cpp.
References bpp::VectorTools::sum().
|
inherited |
Set the data and perform computations.
matrix | The input data to analyse. |
rowWeights | A vector of values specifying the weights of rows. |
colWeights | A vector of values specifying the weights of columns. |
nbAxes | The number of kept axes during the analysis. |
tol | Tolerance threshold for null eigenvalues (a value less than tol times the first one is considered as null) |
verbose | Should warnings be dispayed. |
Exception | if an error occured. |
Definition at line 100 of file DualityDiagram.cpp.
|
private |
Definition at line 61 of file PrincipalComponentAnalysis.h.
Referenced by getColumnMeans().
|
private |
Definition at line 62 of file PrincipalComponentAnalysis.h.
Referenced by getColumnSd().