ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_TMVA_MethodBase
48 #include "TMVA/MethodBase.h"
49 #endif
50 #ifndef ROOT_TMatrixDfwd
51 #include "TMatrixDfwd.h"
52 #endif
53 
54 class TH1D;
55 
56 namespace TMVA {
57 
58  class MethodFisher : public MethodBase {
59 
60  public:
61 
62  MethodFisher( const TString& jobName,
63  const TString& methodTitle,
64  DataSetInfo& dsi,
65  const TString& theOption = "Fisher",
66  TDirectory* theTargetDir = 0 );
67 
69  const TString& theWeightFile,
70  TDirectory* theTargetDir = NULL );
71 
72  virtual ~MethodFisher( void );
73 
74  virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
75 
76 
77  // training method
78  void Train( void );
79 
81 
82  // write weights to stream
83  void AddWeightsXMLTo ( void* parent ) const;
84 
85  // read weights from stream
86  void ReadWeightsFromStream( std::istream & i );
87  void ReadWeightsFromXML ( void* wghtnode );
88 
89  // calculate the MVA value
90  Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
91 
94 
95  // ranking of input variables
96  const Ranking* CreateRanking();
97 
98  // nice output
99  void PrintCoefficients( void );
100 
101 
102  protected:
103 
104  // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
105  void MakeClassSpecific( std::ostream&, const TString& ) const;
106 
107  // get help message text
108  void GetHelpMessage() const;
109 
110  private:
111 
112  // the option handling methods
113  void DeclareOptions();
114  void ProcessOptions();
115 
116  // Initialization and allocation of matrices
117  void InitMatrices( void );
118 
119  // get mean value of variables
120  void GetMean( void );
121 
122  // get matrix of covariance within class
123  void GetCov_WithinClass( void );
124 
125  // get matrix of covariance between class
126  void GetCov_BetweenClass( void );
127 
128  // and the full covariance matrix
129  void GetCov_Full( void );
130 
131  // get discriminating power
132  void GetDiscrimPower( void );
133 
134  // get Fisher coefficients
135  void GetFisherCoeff( void );
136 
137  // matrix of variables means: S, B, S+B vs. variables
139 
140  // method to be used
141  TString fTheMethod; // Fisher or Mahalanobis
142  EFisherMethod fFisherMethod; // Fisher or Mahalanobis
143 
144  // covariance matrices
145  TMatrixD *fBetw; // between-class matrix
146  TMatrixD *fWith; // within-class matrix
147  TMatrixD *fCov; // full covariance matrix
148 
149  // number of events (sumOfWeights)
150  Double_t fSumOfWeightsS; // sum-of-weights for signal training events
151  Double_t fSumOfWeightsB; // sum-of-weights for background training events
152 
153  std::vector<Double_t>* fDiscrimPow; // discriminating power
154  std::vector<Double_t>* fFisherCoeff; // Fisher coefficients
155  Double_t fF0; // offset
156 
157  // default initialisation called by all constructors
158  void Init( void );
159 
160  ClassDef(MethodFisher,0) // Analysis of Fisher discriminant (Fisher or Mahalanobis approach)
161  };
162 
163 } // namespace TMVA
164 
165 #endif // MethodFisher_H
void GetCov_BetweenClass(void)
the matrix of covariance 'between class' reflects the dispersion of the events of a class relative to...
const Ranking * CreateRanking()
computes ranking of input variables
void MakeClassSpecific(std::ostream &, const TString &) const
write Fisher-specific classifier response
void ReadWeightsFromStream(std::istream &i)
read Fisher coefficients from weight file
virtual ~MethodFisher(void)
destructor
void AddWeightsXMLTo(void *parent) const
create XML description of Fisher classifier
void GetCov_Full(void)
compute full covariance matrix from sum of within and between matrices
void GetDiscrimPower(void)
computation of discrimination power indicator for each variable small values of "fWith" indicates lit...
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
Fisher can only handle classification with 2 classes.
EFisherMethod GetFisherMethod(void)
Definition: MethodFisher.h:93
MethodFisher(const TString &jobName, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="Fisher", TDirectory *theTargetDir=0)
standard constructor for the "Fisher"
Double_t fSumOfWeightsS
Definition: MethodFisher.h:150
EAnalysisType
Definition: Types.h:124
Basic string class.
Definition: TString.h:137
TMatrixD * fMeanMatx
Definition: MethodFisher.h:138
bool Bool_t
Definition: RtypesCore.h:59
std::vector< Double_t > * fFisherCoeff
Definition: MethodFisher.h:154
#define ClassDef(name, id)
Definition: Rtypes.h:254
Double_t fSumOfWeightsB
Definition: MethodFisher.h:151
EFisherMethod fFisherMethod
Definition: MethodFisher.h:142
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
returns the Fisher value (no fixed range)
void Train(void)
computation of Fisher coefficients by series of matrix operations
void ReadWeightsFromXML(void *wghtnode)
read Fisher coefficients from xml weight file
void ProcessOptions()
process user options
unsigned int UInt_t
Definition: RtypesCore.h:42
void InitMatrices(void)
initializaton method; creates global matrices and vectors
void GetHelpMessage() const
get help message text
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:613
void DeclareOptions()
MethodFisher options: format and syntax of option string: "type" where type is "Fisher" or "Mahalanob...
double Double_t
Definition: RtypesCore.h:55
void GetMean(void)
compute mean values of variables in each sample, and the overall means
void GetCov_WithinClass(void)
the matrix of covariance 'within class' reflects the dispersion of the events relative to the center ...
Describe directory structure in memory.
Definition: TDirectory.h:44
int type
Definition: TGX11.cxx:120
#define NULL
Definition: Rtypes.h:82
void PrintCoefficients(void)
display Fisher coefficients and discriminating power for each variable check maximum length of variab...
virtual void ReadWeightsFromStream(std::istream &)=0
void GetFisherCoeff(void)
Fisher = Sum { [coeff]*[variables] }.
std::vector< Double_t > * fDiscrimPow
Definition: MethodFisher.h:153
void Init(void)
default initialization called by all constructors