ROOT  6.06/09
Reference Guide
VariablePCATransform.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : VariablePCATransform *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Principal value composition of input variables *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Peter Speckmayer <Peter.Speckmayer@cern.ch> - CERN, Switzerland *
16  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
17  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
18  * *
19  * Copyright (c) 2005: *
20  * CERN, Switzerland *
21  * U. of Victoria, Canada *
22  * MPI-K Heidelberg, Germany *
23  * *
24  * Redistribution and use in source and binary forms, with or without *
25  * modification, are permitted according to the terms listed in LICENSE *
26  * (http://tmva.sourceforge.net/LICENSE) *
27  **********************************************************************************/
28 
29 #ifndef ROOT_TMVA_VariablePCATransform
30 #define ROOT_TMVA_VariablePCATransform
31 
32 //////////////////////////////////////////////////////////////////////////
33 // //
34 // VariablePCATransform //
35 // //
36 // Linear interpolation class //
37 // //
38 //////////////////////////////////////////////////////////////////////////
39 
40 #ifndef ROOT_TPrincipal
41 #include "TPrincipal.h"
42 #endif
43 
44 #ifndef ROOT_TMVA_VariableTransformBase
46 #endif
47 
48 namespace TMVA {
49 
51 
52  public:
53 
55  virtual ~VariablePCATransform( void );
56 
57  void Initialize();
58  Bool_t PrepareTransformation (const std::vector<Event*>&);
59 
60  virtual const Event* Transform(const Event* const, Int_t cls ) const;
61  virtual const Event* InverseTransform(const Event* const, Int_t cls ) const;
62 
63  void WriteTransformationToStream ( std::ostream& ) const;
64  void ReadTransformationFromStream( std::istream&, const TString& );
65 
66  virtual void AttachXMLTo(void* parent);
67  virtual void ReadFromXML( void* trfnode );
68 
69  // writer of function code
70  virtual void MakeFunction( std::ostream& fout, const TString& fncName, Int_t part, UInt_t trCounter, Int_t cls );
71 
72  private:
73 
74  void CalculatePrincipalComponents( const std::vector< Event*>& );
75  void X2P( std::vector<Float_t>&, const std::vector<Float_t>&, Int_t cls ) const;
76  void P2X( std::vector<Float_t>&, const std::vector<Float_t>&, Int_t cls ) const;
77 
78  // store relevant parts of PCA locally
79  std::vector<TVectorD*> fMeanValues; // mean values
80  std::vector<TMatrixD*> fEigenVectors; // eigenvectors
81 
82  ClassDef(VariablePCATransform,0) // Variable transformation: Principal Value Composition
83  };
84 
85 } // namespace TMVA
86 
87 #endif
88 
Bool_t PrepareTransformation(const std::vector< Event * > &)
calculate the principal components using the ROOT class TPrincipal and the normalization ...
void ReadTransformationFromStream(std::istream &, const TString &)
Read mean values from input stream.
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void AttachXMLTo(void *parent)
create XML description of PCA transformation
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual const Event * InverseTransform(const Event *const, Int_t cls) const
apply the principal component analysis TODO: implementation of inverse transformation Log() << kFATAL...
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void ReadFromXML(void *trfnode)
Read the transformation matrices from the xml node.
void Initialize()
initialization of the transformation.
Abstract ClassifierFactory template that handles arbitrary types.
std::vector< TMatrixD * > fEigenVectors
virtual const Event * Transform(const Event *const, Int_t cls) const
apply the principal component analysis
VariablePCATransform(DataSetInfo &dsi)
virtual ~VariablePCATransform(void)
destructor
void P2X(std::vector< Float_t > &, const std::vector< Float_t > &, Int_t cls) const
Perform the back-transformation from the principal components pc, and return x It's the users respons...
std::vector< TVectorD * > fMeanValues
void WriteTransformationToStream(std::ostream &) const
write mean values to stream
void X2P(std::vector< Float_t > &, const std::vector< Float_t > &, Int_t cls) const
Calculate the principal components from the original data vector x, and return it in p (function extr...
virtual void MakeFunction(std::ostream &fout, const TString &fncName, Int_t part, UInt_t trCounter, Int_t cls)
creates C++ code fragment of the PCA transform for inclusion in standalone C++ class ...
void CalculatePrincipalComponents(const std::vector< Event * > &)
calculate the principal components for the signal and the background data it uses the MakePrincipal m...