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  public:
30  explicit PndMvaVarPCATransform();
31 
33  virtual ~PndMvaVarPCATransform();
34 
39  bool InitPCATranformation(std::vector<std::pair<std::string, std::vector<float> *>> const &dat);
40 
46  std::vector<float> *Transform(std::vector<float> const &evd) const;
47 
49  inline TVectorD const &GetMeanValues() const;
50 
52  inline TMatrixD const &GetEigenVectors() const;
53 
55  void SetMeanVector(TVectorD const &vect);
56 
58  void SetEigenVectors(TMatrixD const &mat);
59 
60  private:
63  PndMvaVarPCATransform &operator=(PndMvaVarPCATransform const &ot);
64 
65  /*
66  * Given a list of n-dimensional data points, Computes PCA for the
67  * current dataset.
68  */
69  void ComputePrincipalComponents(std::vector<std::pair<std::string, std::vector<float> *>> const &dat);
70 
71  // Mean values
72  TVectorD *m_MeanValues;
73 
74  // Eigenvectors
75  TMatrixD *m_EigenVectors;
76 };
77 //____________________ ENd of interface definition
78 
82 inline TVectorD const &PndMvaVarPCATransform::GetMeanValues() const
83 {
84  return (*m_MeanValues);
85 }
86 
91 {
92  return (*m_EigenVectors);
93 }
94 #endif
PndMvaVarPCATransform()
Constructor.
void SetEigenVectors(TMatrixD const &mat)
Set Eigenvectors matrix.
std::vector< float > * Transform(std::vector< float > const &evd) const
bool InitPCATranformation(std::vector< std::pair< std::string, std::vector< float > *>> const &dat)
TVectorD const & GetMeanValues() const
Get mean values vector.
virtual ~PndMvaVarPCATransform()
Destructor.
TMatrixD const & GetEigenVectors() const
Get Eigenvectors matrix.
void SetMeanVector(TVectorD const &vect)
Set mean values vector.
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52