ROOT  6.06/09
Reference Guide
MethodLikelihood.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss, Peter Speckmayer, Eckhard von Toerne, Jan Therhaag
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : MethodLikelihood *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Likelihood analysis ("non-parametric approach") *
12  * Also implemented is a "diagonalized likelihood approach", *
13  * which improves over the uncorrelated likelihood ansatz by transforming *
14  * linearly the input variables into a diagonal space, using the square-root *
15  * of the covariance matrix. This approach can be chosen by inserting *
16  * the letter "D" into the option string. *
17  * *
18  * Authors (alphabetical): *
19  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
20  * Peter Speckmayer <Peter.Speckmazer@cern.ch> - CERN, Switzerland *
21  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
22  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
23  * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
24  * Jan Therhaag <Jan.Therhaag@cern.ch> - U of Bonn, Germany *
25  * Eckhard v. Toerne <evt@uni-bonn.de> - U of Bonn, Germany *
26  * *
27  * Copyright (c) 2005-2011: *
28  * CERN, Switzerland *
29  * U. of Victoria, Canada *
30  * MPI-K Heidelberg, Germany *
31  * U. of Bonn, Germany *
32  * *
33  * Redistribution and use in source and binary forms, with or without *
34  * modification, are permitted according to the terms listed in LICENSE *
35  * (http://tmva.sourceforge.net/LICENSE) *
36  **********************************************************************************/
37 
38 #ifndef ROOT_TMVA_MethodLikelihood
39 #define ROOT_TMVA_MethodLikelihood
40 
41 //////////////////////////////////////////////////////////////////////////
42 // //
43 // MethodLikelihood //
44 // //
45 // Likelihood analysis ("non-parametric approach") //
46 // Also implemented is a "diagonalized likelihood approach", //
47 // which improves over the uncorrelated likelihood ansatz by //
48 // transforming linearly the input variables into a diagonal space, //
49 // using the square-root of the covariance matrix //
50 // //
51 //////////////////////////////////////////////////////////////////////////
52 
53 #ifndef ROOT_TMVA_MethodBase
54 #include "TMVA/MethodBase.h"
55 #endif
56 #ifndef ROOT_TMVA_PDF
57 #include "TMVA/PDF.h"
58 #endif
59 
60 class TH1D;
61 
62 namespace TMVA {
63 
64  class MethodLikelihood : public MethodBase {
65 
66  public:
67 
68  MethodLikelihood( const TString& jobName,
69  const TString& methodTitle,
70  DataSetInfo& theData,
71  const TString& theOption = "",
72  TDirectory* theTargetDir = 0 );
73 
74  MethodLikelihood( DataSetInfo& theData,
75  const TString& theWeightFile,
76  TDirectory* theTargetDir = NULL );
77 
78  virtual ~MethodLikelihood();
79 
81  UInt_t numberClasses, UInt_t numberTargets );
82 
83  // training method
84  void Train();
85 
86  // write weights to file
87  void WriteWeightsToStream( TFile& rf ) const;
88  void AddWeightsXMLTo( void* parent ) const;
89 
90  // read weights from file
91  void ReadWeightsFromStream( std::istream& istr );
92  void ReadWeightsFromStream( TFile& istr );
93  void ReadWeightsFromXML( void* wghtnode );
94  // calculate the MVA value
95  // the argument is used for internal ranking tests
96  Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
97 
98  // write method specific histos to target file
99  void WriteMonitoringHistosToFile() const;
100 
101  // ranking of input variables
102  const Ranking* CreateRanking();
103 
104  virtual void WriteOptionsToStream ( std::ostream& o, const TString& prefix ) const;
105 
106  protected:
107 
109 
110  // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
111  void MakeClassSpecific( std::ostream&, const TString& ) const;
112 
113  // header and auxiliary classes
114  void MakeClassSpecificHeader( std::ostream&, const TString& = "" ) const;
115 
116  // get help message text
117  void GetHelpMessage() const;
118 
119  private:
120 
121  // returns transformed or non-transformed output
123 
124  // the option handling methods
125  void Init();
126  void DeclareOptions();
127  void ProcessOptions();
128 
129  // options
130  Double_t fEpsilon; // minimum number of likelihood (to avoid zero)
131  Bool_t fTransformLikelihoodOutput; // likelihood output is sigmoid-transformed
132 
133  Int_t fDropVariable; // for ranking test
134 
135  std::vector<TH1*>* fHistSig; // signal PDFs (histograms)
136  std::vector<TH1*>* fHistBgd; // background PDFs (histograms)
137  std::vector<TH1*>* fHistSig_smooth; // signal PDFs (smoothed histograms)
138  std::vector<TH1*>* fHistBgd_smooth; // background PDFs (smoothed histograms)
139 
140  PDF* fDefaultPDFLik; // pdf that contains default definitions
141  std::vector<PDF*>* fPDFSig; // list of PDFs (signal)
142  std::vector<PDF*>* fPDFBgd; // list of PDFs (background)
143 
144  // default initialisation called by all constructors
145 
146  // obsolete variables kept for backward combatibility
147  Int_t fNsmooth; // number of smooth passes
148  Int_t* fNsmoothVarS; // number of smooth passes
149  Int_t* fNsmoothVarB; // number of smooth passes
150  Int_t fAverageEvtPerBin; // average events per bin; used to calculate fNbins
151  Int_t* fAverageEvtPerBinVarS; // average events per bin; used to calculate fNbins
152  Int_t* fAverageEvtPerBinVarB; // average events per bin; used to calculate fNbins
153  TString fBorderMethodString; // the method to take care about "border" effects (string)
154  Float_t fKDEfineFactor; // fine tuning factor for Adaptive KDE
155  TString fKDEiterString; // Number of iterations (string)
156  TString fKDEtypeString; // Kernel type to use for KDE (string)
157  TString* fInterpolateString; // which interpolation method used for reference histograms (individual for each variable)
158 
159  ClassDef(MethodLikelihood,0) // Likelihood analysis ("non-parametric approach")
160  };
161 
162 } // namespace TMVA
163 
164 #endif // MethodLikelihood_H
void DeclareCompatibilityOptions()
options that are used ONLY for the READER to ensure backward compatibility they are hence without any...
void WriteWeightsToStream(TFile &rf) const
write reference PDFs to ROOT file
virtual void WriteOptionsToStream(std::ostream &o, const TString &prefix) const
write options to stream
float Float_t
Definition: RtypesCore.h:53
void Train()
create reference distributions (PDFs) from signal and background events: fill histograms and smooth t...
virtual ~MethodLikelihood()
destructor
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
EAnalysisType
Definition: Types.h:124
std::vector< TH1 * > * fHistSig
Basic string class.
Definition: TString.h:137
void WriteMonitoringHistosToFile() const
write histograms and PDFs to file for monitoring purposes
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:254
void ReadWeightsFromXML(void *wghtnode)
read weights from XML
Definition: PDF.h:71
std::vector< PDF * > * fPDFSig
std::vector< TH1 * > * fHistBgd_smooth
Double_t TransformLikelihoodOutput(Double_t ps, Double_t pb) const
returns transformed or non-transformed output
std::vector< TH1 * > * fHistSig_smooth
void GetHelpMessage() const
get help message text
MethodLikelihood(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="", TDirectory *theTargetDir=0)
unsigned int UInt_t
Definition: RtypesCore.h:42
const Ranking * CreateRanking()
computes ranking of input variables
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:613
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
FDA can handle classification with 2 classes.
void MakeClassSpecific(std::ostream &, const TString &) const
write specific classifier response
double Double_t
Definition: RtypesCore.h:55
void DeclareOptions()
define the options (their key words) that can be set in the option string TransformOutput tran...
Describe directory structure in memory.
Definition: TDirectory.h:41
std::vector< PDF * > * fPDFBgd
int type
Definition: TGX11.cxx:120
void AddWeightsXMLTo(void *parent) const
write weights to XML
void Init()
default initialisation called by all constructors
void ReadWeightsFromStream(std::istream &istr)
read weight info from file nothing to do for this method
Abstract ClassifierFactory template that handles arbitrary types.
void MakeClassSpecificHeader(std::ostream &, const TString &="") const
write specific header of the classifier (mostly include files)
#define NULL
Definition: Rtypes.h:82
std::vector< TH1 * > * fHistBgd
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
returns the likelihood estimator for signal fill a new Likelihood branch into the testTree ...