FairRoot/PandaRoot
PndMvaVarPCATransform.h
Go to the documentation of this file.
1 /* **********************************************
2  * MVA variable transformation interface. *
3  * Principal Components Analysis (PCA). *
4  * Author: M.Babai@rug.nl *
5  * LICENSE: *
6  * Version: *
7  * License: *
8  * **********************************************
9  */
10 /*
11  * This code is directly based on the Cern Root implementation of PCA.
12 */
13 //#pragma once
14 #ifndef PND_MVA_VAR_PCA_TRANSFORM_H
15 #define PND_MVA_VAR_PCA_TRANSFORM_H
16 
17 // C & C++ includes
18 #include <cassert>
19 #include <cstdlib>
20 #include <iostream>
21 #include <vector>
22 #include <utility>
23 
24 // ROOT includes.
25 #include "TPrincipal.h"
26 
28 {
29  public:
31  explicit PndMvaVarPCATransform();
32 
34  virtual ~PndMvaVarPCATransform();
35 
40  bool InitPCATranformation(std::vector<std::pair<std::string, std::vector<float>*> > const& dat);
41 
47  std::vector<float>* Transform(std::vector<float> const& evd) const;
48 
50  inline TVectorD const& GetMeanValues() const;
51 
53  inline TMatrixD const& GetEigenVectors() const;
54 
56  void SetMeanVector(TVectorD const& vect);
57 
59  void SetEigenVectors(TMatrixD const& mat);
60 
61  private:
65 
66  /*
67  * Given a list of n-dimensional data points, Computes PCA for the
68  * current dataset.
69  */
70  void ComputePrincipalComponents(std::vector< std::pair<std::string, std::vector<float>*> > const& dat);
71 
72  // Mean values
73  TVectorD* m_MeanValues;
74 
75  // Eigenvectors
77 };
78 //____________________ ENd of interface definition
79 
83 inline TVectorD const& PndMvaVarPCATransform::GetMeanValues() const
84 {
85  return (*m_MeanValues);
86 }
87 
92 {
93  return (*m_EigenVectors);
94 }
95 #endif
PndMvaVarPCATransform()
Constructor.
void ComputePrincipalComponents(std::vector< std::pair< std::string, std::vector< float > * > > const &dat)
std::vector< float > * Transform(std::vector< float > const &evd) const
void SetEigenVectors(TMatrixD const &mat)
Set Eigenvectors matrix.
bool InitPCATranformation(std::vector< std::pair< std::string, std::vector< float > * > > const &dat)
TMatrixD const & GetEigenVectors() const
Get Eigenvectors matrix.
PndMvaVarPCATransform & operator=(PndMvaVarPCATransform const &ot)
virtual ~PndMvaVarPCATransform()
Destructor.
TVectorD const & GetMeanValues() const
Get mean values vector.
void SetMeanVector(TVectorD const &vect)
Set mean values vector.
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52