libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
crn::PCA Class Reference

Class to perform Principal Componant Analysis. More...

#include <CRNPCA.h>

+ Inheritance diagram for crn::PCA:
+ Collaboration diagram for crn::PCA:

Public Member Functions

 PCA (const MatrixDouble &data, bool data_reduction_flag=true)
 Constructor. More...
 
 PCA (const std::vector< std::vector< double > > &data, bool data_reduction_flag=true)
 Constructor. More...
 
 PCA (const std::vector< std::vector< double > > &data, const std::vector< size_t > &cards, bool data_reduction_flag=true)
 Constructor from weighted vectors. More...
 
 PCA (const std::map< std::vector< double >, size_t > &data, bool data_reduction_flag=true)
 Constructor from map. More...
 
template<typename ITER >
 PCA (ITER begin, ITER end, bool data_reduction_flag=true)
 Constructor from iterators. More...
 
 PCA (const PCA &)=default
 Constructor. More...
 
 PCA (PCA &&)=default
 
virtual ~PCA () override=default
 Destructor. More...
 
PCAoperator= (const PCA &)=default
 
PCAoperator= (PCA &&)=default
 
size_t GetDimension () const noexcept
 Returns the dimension of feature space. More...
 
const std::vector< double > & GetMeans () const noexcept
 Returns the mean values computed for sample data. More...
 
double GetMean (size_t d) const
 Returns the mean value of d-th feature computed for sample data. More...
 
const std::vector< double > & GetDeviations () const noexcept
 Returns the deviation computed for sample data. More...
 
double GetDeviation (size_t d) const
 Returns the deviation of d-th feature computed for sample data. More...
 
const std::multimap< double,
MatrixDouble > & 
GetEigensystem () const noexcept
 Returns the eigensystem computed on covariance matrix of last sample data. More...
 
MatrixDouble Transform (const MatrixDouble &patterns, size_t nb_features=1u) const
 Apply transform to given patterns. More...
 
std::vector< std::vector
< double > > 
Transform (const std::vector< std::vector< double > > &data, const size_t nb_features=0u) const
 Apply transform to given patterns. More...
 
std::vector< std::vector
< double > > 
ReverseTransform (const std::vector< std::vector< double > > &data) const
 Apply reverse transform to get given patterns' pre-images. More...
 
void Deserialize (xml::Element &el)
 
xml::Element Serialize (xml::Element &parent) const
 
 PCA (xml::Element &el)
 
- Public Member Functions inherited from crn::Object
virtual ~Object ()=default
 

Detailed Description

Class to perform Principal Componant Analysis.

Principal Componant Analysis

Author
Jean DUONG
Date
September 2009
Version
0.1

Definition at line 39 of file CRNPCA.h.

Constructor & Destructor Documentation

PCA::PCA ( const MatrixDouble data,
bool  data_reduction_flag = true 
)

Constructor.

Constructor

Parameters
[in]datamatrix of double numbers in which patterns are stored as rows
[in]data_reduction_flagflag to indicate if the data have to be reduced

Definition at line 41 of file CRNPCA.cpp.

PCA::PCA ( const std::vector< std::vector< double > > &  data,
bool  data_reduction_flag = true 
)

Constructor.

Constructor

Parameters
[in]datavector of vectors of double numbers in which patterns are stored
[in]data_reduction_flagflag to indicate if the data have to be reduced

Definition at line 140 of file CRNPCA.cpp.

PCA::PCA ( const std::vector< std::vector< double > > &  data,
const std::vector< size_t > &  cards,
bool  data_reduction_flag = true 
)

Constructor from weighted vectors.

Constructor

Parameters
[in]datacollection of vectors of double numbers
[in]cardspattern cardinals
[in]data_reduction_flagflag to indicate if the data have to be reduced

Definition at line 247 of file CRNPCA.cpp.

PCA::PCA ( const std::map< std::vector< double >, size_t > &  data,
bool  data_reduction_flag = true 
)

Constructor from map.

Constructor

Parameters
[in]datamap of vectors of double numbers with cardinals
[in]data_reduction_flagflag to indicate if the data have to be reduced

Definition at line 359 of file CRNPCA.cpp.

template<typename ITER >
crn::PCA::PCA ( ITER  begin,
ITER  end,
bool  data_reduction_flag = true 
)

Constructor from iterators.

Constructor

Performs principal component analysis over patterns given as a value-cardinal pairs

Parameters
[in]beginiterator pointing at the begining of the data collection
[in]endending iterator
[in]data_reduction_flagflag to indicate if data should be reduced for PCA estimate

Definition at line 114 of file CRNPCA.h.

crn::PCA::PCA ( const PCA )
default

Constructor.

crn::PCA::PCA ( PCA &&  )
default
virtual crn::PCA::~PCA ( )
overridevirtualdefault

Destructor.

crn::PCA::PCA ( xml::Element el)
inline

Definition at line 97 of file CRNPCA.h.

Member Function Documentation

void PCA::Deserialize ( xml::Element el)

Unsafe load from XML node

Author
Jean DUONG
Exceptions
ExceptionInvalidArgumentnot a UnivariateGaussianMixture
ExceptionNotFoundcannot find attribute
ExceptionDomainwrong attribute
Parameters
[in]elthe element to load

Definition at line 713 of file CRNPCA.cpp.

double PCA::GetDeviation ( size_t  d) const

Returns the deviation of d-th feature computed for sample data.

Returns the deviation of d-th feature

Exceptions
ExceptionDimensionincompatible patter dimensions
Parameters
[in]dindex of desired value
Returns
double value

Definition at line 539 of file CRNPCA.cpp.

const std::vector<double>& crn::PCA::GetDeviations ( ) const
inlinenoexcept

Returns the deviation computed for sample data.

Definition at line 69 of file CRNPCA.h.

size_t crn::PCA::GetDimension ( ) const
inlinenoexcept

Returns the dimension of feature space.

Definition at line 62 of file CRNPCA.h.

const std::multimap<double, MatrixDouble>& crn::PCA::GetEigensystem ( ) const
inlinenoexcept

Returns the eigensystem computed on covariance matrix of last sample data.

Definition at line 74 of file CRNPCA.h.

double PCA::GetMean ( size_t  d) const

Returns the mean value of d-th feature computed for sample data.

Returns the mean value of d-th feature

Exceptions
ExceptionDimensionincompatible patter dimensions
Parameters
[in]dindex of desired value
Returns
double value

Definition at line 524 of file CRNPCA.cpp.

const std::vector<double>& crn::PCA::GetMeans ( ) const
inlinenoexcept

Returns the mean values computed for sample data.

Definition at line 64 of file CRNPCA.h.

PCA& crn::PCA::operator= ( const PCA )
default
PCA& crn::PCA::operator= ( PCA &&  )
default
std::vector< std::vector< double > > PCA::ReverseTransform ( const std::vector< std::vector< double > > &  data) const

Apply reverse transform to get given patterns' pre-images.

Apply reverse transform to get given patterns' pre-images. No dimension change allowed for this version.

Parameters
[in]datavector of multivariate patterns
Returns
a vector containing projected multivariate patterns

Definition at line 663 of file CRNPCA.cpp.

xml::Element PCA::Serialize ( xml::Element parent) const

Unsafe save

Author
Jean DUONG
Parameters
[in]parentthe parent element to which we will add the new element
Returns
The newly created element

Definition at line 773 of file CRNPCA.cpp.

MatrixDouble PCA::Transform ( const MatrixDouble patterns,
size_t  nb_features = 1u 
) const

Apply transform to given patterns.

Perform projection of given patterns using current PCA attributes. Patterns are translated to make centroid become the center of space, then projected on pricipal componants from most to least significant ones.

Exceptions
ExceptionDimensionincompatible patter dimensions
ExceptionDomainincompatible output dimension
Parameters
[in]patternsmatrix of double numbers in which patterns are stored
[in]nb_featuresthe number of principal componants used for projection
Returns
a matrix containing projected patterns

Definition at line 560 of file CRNPCA.cpp.

std::vector< std::vector< double > > PCA::Transform ( const std::vector< std::vector< double > > &  data,
const size_t  nb_features = 0u 
) const

Apply transform to given patterns.

Perform projection of given patterns using current PCA attributes. Patterns are translated to make centroid become the center of space, then projected on principal componants from most to least significant ones.

Parameters
[in]datavector of multivariate patterns
[in]nb_featuresthe number of principal componants used for projection
Returns
a vector containing projected multivariate patterns

Definition at line 614 of file CRNPCA.cpp.


The documentation for this class was generated from the following files: