Logo ROOT  
Reference Guide
MethodFisher.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Xavier Prudent, Joerg Stelzer, Helge Voss, Kai Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : MethodFisher *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Analysis of Fisher discriminant (Fisher or Mahalanobis approach) *
12  * *
13  * Original author of this Fisher-Discriminant implementation: *
14  * Andre Gaidot, CEA-France; *
15  * (Translation from FORTRAN) *
16  * *
17  * Authors (alphabetical): *
18  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
19  * Xavier Prudent <prudent@lapp.in2p3.fr> - LAPP, France *
20  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
21  * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
22  * *
23  * Copyright (c) 2005: *
24  * CERN, Switzerland *
25  * U. of Victoria, Canada *
26  * MPI-K Heidelberg, Germany *
27  * LAPP, Annecy, France *
28  * *
29  * Redistribution and use in source and binary forms, with or without *
30  * modification, are permitted according to the terms listed in LICENSE *
31  * (http://tmva.sourceforge.net/LICENSE) *
32  **********************************************************************************/
33 
34 #ifndef ROOT_TMVA_MethodFisher
35 #define ROOT_TMVA_MethodFisher
36 
37 //////////////////////////////////////////////////////////////////////////
38 // //
39 // MethodFisher //
40 // //
41 // Analysis of Fisher discriminant (Fisher or Mahalanobis approach) //
42 // //
43 //////////////////////////////////////////////////////////////////////////
44 
45 #include <vector>
46 
47 #include "TMVA/MethodBase.h"
48 #include "TMatrixDfwd.h"
49 
50 class TH1D;
51 
52 namespace TMVA {
53 
54  class MethodFisher : public MethodBase {
55 
56  public:
57 
58  MethodFisher( const TString& jobName,
59  const TString& methodTitle,
60  DataSetInfo& dsi,
61  const TString& theOption = "Fisher");
62 
64  const TString& theWeightFile);
65 
66  virtual ~MethodFisher( void );
67 
68  virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
69 
70 
71  // training method
72  void Train( void );
73 
75 
76  // write weights to stream
77  void AddWeightsXMLTo ( void* parent ) const;
78 
79  // read weights from stream
80  void ReadWeightsFromStream( std::istream & i );
81  void ReadWeightsFromXML ( void* wghtnode );
82 
83  // calculate the MVA value
84  Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
85 
88 
89  // ranking of input variables
90  const Ranking* CreateRanking();
91 
92  // nice output
93  void PrintCoefficients( void );
94 
95 
96  protected:
97 
98  // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
99  void MakeClassSpecific( std::ostream&, const TString& ) const;
100 
101  // get help message text
102  void GetHelpMessage() const;
103 
104  private:
105 
106  // the option handling methods
107  void DeclareOptions();
108  void ProcessOptions();
109 
110  // Initialization and allocation of matrices
111  void InitMatrices( void );
112 
113  // get mean value of variables
114  void GetMean( void );
115 
116  // get matrix of covariance within class
117  void GetCov_WithinClass( void );
118 
119  // get matrix of covariance between class
120  void GetCov_BetweenClass( void );
121 
122  // and the full covariance matrix
123  void GetCov_Full( void );
124 
125  // get discriminating power
126  void GetDiscrimPower( void );
127 
128  // get Fisher coefficients
129  void GetFisherCoeff( void );
130 
131  // matrix of variables means: S, B, S+B vs. variables
133 
134  // method to be used
135  TString fTheMethod; // Fisher or Mahalanobis
136  EFisherMethod fFisherMethod; // Fisher or Mahalanobis
137 
138  // covariance matrices
139  TMatrixD *fBetw; // between-class matrix
140  TMatrixD *fWith; // within-class matrix
141  TMatrixD *fCov; // full covariance matrix
142 
143  // number of events (sumOfWeights)
144  Double_t fSumOfWeightsS; // sum-of-weights for signal training events
145  Double_t fSumOfWeightsB; // sum-of-weights for background training events
146 
147  std::vector<Double_t>* fDiscrimPow; // discriminating power
148  std::vector<Double_t>* fFisherCoeff; // Fisher coefficients
149  Double_t fF0; // offset
150 
151  // default initialisation called by all constructors
152  void Init( void );
153 
154  ClassDef(MethodFisher,0); // Analysis of Fisher discriminant (Fisher or Mahalanobis approach)
155  };
156 
157 } // namespace TMVA
158 
159 #endif // MethodFisher_H
TMatrixDfwd.h
TMVA::MethodFisher::AddWeightsXMLTo
void AddWeightsXMLTo(void *parent) const
create XML description of Fisher classifier
Definition: MethodFisher.cxx:618
TMVA::MethodFisher::GetFisherCoeff
void GetFisherCoeff(void)
Fisher = Sum { [coeff]*[variables] }.
Definition: MethodFisher.cxx:457
TMVA::MethodFisher::ReadWeightsFromStream
virtual void ReadWeightsFromStream(std::istream &)=0
TMVA::MethodFisher::PrintCoefficients
void PrintCoefficients(void)
display Fisher coefficients and discriminating power for each variable check maximum length of variab...
Definition: MethodFisher.cxx:557
TMVA::MethodFisher::kFisher
@ kFisher
Definition: MethodFisher.h:86
TMVA::MethodBase::ReadWeightsFromStream
virtual void ReadWeightsFromStream(std::istream &)=0
TMVA::MethodFisher::ProcessOptions
void ProcessOptions()
process user options
Definition: MethodFisher.cxx:204
TMVA::MethodFisher::fSumOfWeightsB
Double_t fSumOfWeightsB
Definition: MethodFisher.h:145
TMVA::MethodFisher::MethodFisher
MethodFisher(const TString &jobName, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="Fisher")
standard constructor for the "Fisher"
Definition: MethodFisher.cxx:135
TMVA::Ranking
Ranking for variables in method (implementation)
Definition: Ranking.h:48
TH1D
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:618
TMVA::MethodFisher::fDiscrimPow
std::vector< Double_t > * fDiscrimPow
Definition: MethodFisher.h:147
TMVA::MethodFisher::GetCov_BetweenClass
void GetCov_BetweenClass(void)
the matrix of covariance 'between class' reflects the dispersion of the events of a class relative to...
Definition: MethodFisher.cxx:417
TMVA::MethodFisher::Train
void Train(void)
computation of Fisher coefficients by series of matrix operations
Definition: MethodFisher.cxx:237
TMVA::MethodFisher::GetMean
void GetMean(void)
compute mean values of variables in each sample, and the overall means
Definition: MethodFisher.cxx:302
MethodBase.h
TString
Basic string class.
Definition: TString.h:136
TMatrixT< Double_t >
TMVA::MethodFisher::fCov
TMatrixD * fCov
Definition: MethodFisher.h:141
TMVA::MethodFisher::fSumOfWeightsS
Double_t fSumOfWeightsS
Definition: MethodFisher.h:144
TMVA::MethodFisher::HasAnalysisType
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
Fisher can only handle classification with 2 classes.
Definition: MethodFisher.cxx:228
TMVA::MethodFisher::EFisherMethod
EFisherMethod
Definition: MethodFisher.h:86
bool
TMVA::MethodFisher::GetFisherMethod
EFisherMethod GetFisherMethod(void)
Definition: MethodFisher.h:87
TMVA::MethodFisher::fFisherMethod
EFisherMethod fFisherMethod
Definition: MethodFisher.h:136
TMVA::MethodFisher::DeclareOptions
void DeclareOptions()
MethodFisher options: format and syntax of option string: "type" where type is "Fisher" or "Mahalanob...
Definition: MethodFisher.cxx:194
TMVA::DataSetInfo
Class that contains all the data information.
Definition: DataSetInfo.h:62
TMVA::Types::EAnalysisType
EAnalysisType
Definition: Types.h:128
TMVA::MethodFisher::InitMatrices
void InitMatrices(void)
initialization method; creates global matrices and vectors
Definition: MethodFisher.cxx:285
TMVA::MethodFisher::fTheMethod
TString fTheMethod
Definition: MethodFisher.h:135
TMVA::MethodFisher::MakeClassSpecific
void MakeClassSpecific(std::ostream &, const TString &) const
write Fisher-specific classifier response
Definition: MethodFisher.cxx:655
TMVA::MethodFisher::Init
void Init(void)
default initialization called by all constructors
Definition: MethodFisher.cxx:177
TMVA::MethodFisher::fF0
Double_t fF0
Definition: MethodFisher.h:149
TMVA::MethodFisher::fFisherCoeff
std::vector< Double_t > * fFisherCoeff
Definition: MethodFisher.h:148
TMVA::MethodFisher::GetDiscrimPower
void GetDiscrimPower(void)
computation of discrimination power indicator for each variable small values of "fWith" indicates lit...
Definition: MethodFisher.cxx:528
TMVA::MethodFisher::GetMvaValue
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
returns the Fisher value (no fixed range)
Definition: MethodFisher.cxx:268
TMVA::MethodBase
Virtual base Class for all MVA method.
Definition: MethodBase.h:111
TMVA::MethodFisher::~MethodFisher
virtual ~MethodFisher(void)
destructor
Definition: MethodFisher.cxx:216
unsigned int
TMVA::MethodFisher::fMeanMatx
TMatrixD * fMeanMatx
Definition: MethodFisher.h:132
TMVA::MethodFisher
Fisher and Mahalanobis Discriminants (Linear Discriminant Analysis)
Definition: MethodFisher.h:54
Double_t
double Double_t
Definition: RtypesCore.h:59
TMVA::MethodFisher::GetCov_Full
void GetCov_Full(void)
compute full covariance matrix from sum of within and between matrices
Definition: MethodFisher.cxx:440
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TMVA::MethodFisher::GetCov_WithinClass
void GetCov_WithinClass(void)
the matrix of covariance 'within class' reflects the dispersion of the events relative to the center ...
Definition: MethodFisher.cxx:351
TMVA::MethodFisher::fBetw
TMatrixD * fBetw
Definition: MethodFisher.h:139
TMVA::MethodFisher::CreateRanking
const Ranking * CreateRanking()
computes ranking of input variables
Definition: MethodFisher.cxx:541
TMVA::MethodFisher::ReadWeightsFromXML
void ReadWeightsFromXML(void *wghtnode)
read Fisher coefficients from xml weight file
Definition: MethodFisher.cxx:635
type
int type
Definition: TGX11.cxx:121
TMVA::MethodFisher::fWith
TMatrixD * fWith
Definition: MethodFisher.h:140
TMVA::MethodFisher::GetHelpMessage
void GetHelpMessage() const
get help message text
Definition: MethodFisher.cxx:702
TMVA::MethodFisher::kMahalanobis
@ kMahalanobis
Definition: MethodFisher.h:86
TMVA
create variable transformations
Definition: GeneticMinimizer.h:22