PandaRoot
PndMvaVarPCATransform.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /* **********************************************
14  * MVA variable transformation interface. *
15  * Principal Components Analysis (PCA). *
16  * Author: M.Babai@rug.nl *
17  * LICENSE: *
18  * Version: *
19  * License: *
20  * **********************************************
21  */
22 /*
23  * This code is directly based on the Cern Root implementation of PCA.
24  */
25 //#pragma once
26 #ifndef PND_MVA_VAR_PCA_TRANSFORM_H
27 #define PND_MVA_VAR_PCA_TRANSFORM_H
28 
29 // C & C++ includes
30 #include <cassert>
31 #include <cstdlib>
32 #include <iostream>
33 #include <vector>
34 #include <utility>
35 
36 // ROOT includes.
37 #include "TPrincipal.h"
38 
40  public:
42  explicit PndMvaVarPCATransform();
43 
45  virtual ~PndMvaVarPCATransform();
46 
51  bool InitPCATranformation(std::vector<std::pair<std::string, std::vector<float> *>> const &dat);
52 
58  std::vector<float> *Transform(std::vector<float> const &evd) const;
59 
61  inline TVectorD const &GetMeanValues() const;
62 
64  inline TMatrixD const &GetEigenVectors() const;
65 
67  void SetMeanVector(TVectorD const &vect);
68 
70  void SetEigenVectors(TMatrixD const &mat);
71 
72  private:
75  PndMvaVarPCATransform &operator=(PndMvaVarPCATransform const &ot);
76 
77  /*
78  * Given a list of n-dimensional data points, Computes PCA for the
79  * current dataset.
80  */
81  void ComputePrincipalComponents(std::vector<std::pair<std::string, std::vector<float> *>> const &dat);
82 
83  // Mean values
84  TVectorD *m_MeanValues;
85 
86  // Eigenvectors
87  TMatrixD *m_EigenVectors;
88 };
89 //____________________ ENd of interface definition
90 
94 inline TVectorD const &PndMvaVarPCATransform::GetMeanValues() const
95 {
96  return (*m_MeanValues);
97 }
98 
103 {
104  return (*m_EigenVectors);
105 }
106 #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:64