Logo ROOT  
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 #include "TMVA/MethodBase.h"
54 #include "TMVA/PDF.h"
55 #include <vector>
56 
57 class TH1D;
58 
59 namespace TMVA {
60 
61  class MethodLikelihood : public MethodBase {
62 
63  public:
64 
65  MethodLikelihood( const TString& jobName,
66  const TString& methodTitle,
67  DataSetInfo& theData,
68  const TString& theOption = "");
69 
70  MethodLikelihood( DataSetInfo& theData,
71  const TString& theWeightFile);
72 
73  virtual ~MethodLikelihood();
74 
76  UInt_t numberClasses, UInt_t numberTargets );
77 
78  // training method
79  void Train();
80 
81  // write weights to file
82  void WriteWeightsToStream( TFile& rf ) const;
83  void AddWeightsXMLTo( void* parent ) const;
84 
85  // read weights from file
86  void ReadWeightsFromStream( std::istream& istr );
87  void ReadWeightsFromStream( TFile& istr );
88  void ReadWeightsFromXML( void* wghtnode );
89  // calculate the MVA value
90  // the argument is used for internal ranking tests
91  Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
92 
93  // write method specific histos to target file
94  void WriteMonitoringHistosToFile() const;
95 
96  // ranking of input variables
97  const Ranking* CreateRanking();
98 
99  virtual void WriteOptionsToStream ( std::ostream& o, const TString& prefix ) const;
100 
101  protected:
102 
104 
105  // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
106  void MakeClassSpecific( std::ostream&, const TString& ) const;
107 
108  // header and auxiliary classes
109  void MakeClassSpecificHeader( std::ostream&, const TString& = "" ) const;
110 
111  // get help message text
112  void GetHelpMessage() const;
113 
114  private:
115 
116  // returns transformed or non-transformed output
118 
119  // the option handling methods
120  void Init();
121  void DeclareOptions();
122  void ProcessOptions();
123 
124  // options
125  Double_t fEpsilon; // minimum number of likelihood (to avoid zero)
126  Bool_t fTransformLikelihoodOutput; // likelihood output is sigmoid-transformed
127 
128  Int_t fDropVariable; // for ranking test
129 
130  std::vector<TH1*>* fHistSig; // signal PDFs (histograms)
131  std::vector<TH1*>* fHistBgd; // background PDFs (histograms)
132  std::vector<TH1*>* fHistSig_smooth; // signal PDFs (smoothed histograms)
133  std::vector<TH1*>* fHistBgd_smooth; // background PDFs (smoothed histograms)
134 
135  PDF* fDefaultPDFLik; // pdf that contains default definitions
136  std::vector<PDF*>* fPDFSig; // list of PDFs (signal)
137  std::vector<PDF*>* fPDFBgd; // list of PDFs (background)
138 
139  // default initialisation called by all constructors
140 
141  // obsolete variables kept for backward combatibility
142  Int_t fNsmooth; // number of smooth passes
143  Int_t* fNsmoothVarS; // number of smooth passes
144  Int_t* fNsmoothVarB; // number of smooth passes
145  Int_t fAverageEvtPerBin; // average events per bin; used to calculate fNbins
146  Int_t* fAverageEvtPerBinVarS; // average events per bin; used to calculate fNbins
147  Int_t* fAverageEvtPerBinVarB; // average events per bin; used to calculate fNbins
148  TString fBorderMethodString; // the method to take care about "border" effects (string)
149  Float_t fKDEfineFactor; // fine tuning factor for Adaptive KDE
150  TString fKDEiterString; // Number of iterations (string)
151  TString fKDEtypeString; // Kernel type to use for KDE (string)
152  TString* fInterpolateString; // which interpolation method used for reference histograms (individual for each variable)
153 
154  ClassDef(MethodLikelihood,0); // Likelihood analysis ("non-parametric approach")
155  };
156 
157 } // namespace TMVA
158 
159 #endif // MethodLikelihood_H
TMVA::MethodLikelihood::ReadWeightsFromXML
void ReadWeightsFromXML(void *wghtnode)
read weights from XML
Definition: MethodLikelihood.cxx:667
TMVA::MethodLikelihood::fHistSig_smooth
std::vector< TH1 * > * fHistSig_smooth
Definition: MethodLikelihood.h:132
TMVA::MethodLikelihood::CreateRanking
const Ranking * CreateRanking()
computes ranking of input variables
Definition: MethodLikelihood.cxx:605
TMVA::MethodLikelihood::fTransformLikelihoodOutput
Bool_t fTransformLikelihoodOutput
Definition: MethodLikelihood.h:126
TMVA::MethodLikelihood::~MethodLikelihood
virtual ~MethodLikelihood()
destructor
Definition: MethodLikelihood.cxx:198
TMVA::Ranking
Ranking for variables in method (implementation)
Definition: Ranking.h:48
TMVA::MethodLikelihood::GetHelpMessage
void GetHelpMessage() const
get help message text
Definition: MethodLikelihood.cxx:995
TMVA::MethodLikelihood::GetMvaValue
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
Definition: MethodLikelihood.cxx:451
TMVA::MethodLikelihood::fNsmoothVarS
Int_t * fNsmoothVarS
Definition: MethodLikelihood.h:143
TMVA::MethodLikelihood::fDropVariable
Int_t fDropVariable
Definition: MethodLikelihood.h:128
TMVA::MethodLikelihood::MethodLikelihood
MethodLikelihood(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="")
standard constructor
Definition: MethodLikelihood.cxx:142
TMVA::MethodLikelihood::fAverageEvtPerBinVarS
Int_t * fAverageEvtPerBinVarS
Definition: MethodLikelihood.h:146
TMVA::MethodLikelihood::fNsmooth
Int_t fNsmooth
Definition: MethodLikelihood.h:142
TH1D
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:618
TMVA::MethodLikelihood::ReadWeightsFromStream
void ReadWeightsFromStream(std::istream &istr)
read weight info from file nothing to do for this method
Definition: MethodLikelihood.cxx:697
Float_t
float Float_t
Definition: RtypesCore.h:57
TMVA::MethodLikelihood::fAverageEvtPerBinVarB
Int_t * fAverageEvtPerBinVarB
Definition: MethodLikelihood.h:147
TMVA::MethodLikelihood::fKDEfineFactor
Float_t fKDEfineFactor
Definition: MethodLikelihood.h:149
TGeant4Unit::ps
static constexpr double ps
Definition: TGeant4SystemOfUnits.h:165
TMVA::MethodLikelihood::WriteWeightsToStream
void WriteWeightsToStream(TFile &rf) const
write reference PDFs to ROOT file
Definition: MethodLikelihood.cxx:655
TMVA::MethodLikelihood::Train
void Train()
create reference distributions (PDFs) from signal and background events: fill histograms and smooth t...
Definition: MethodLikelihood.cxx:335
MethodBase.h
TMVA::MethodLikelihood::Init
void Init()
default initialisation called by all constructors
Definition: MethodLikelihood.cxx:226
TMVA::MethodLikelihood::DeclareOptions
void DeclareOptions()
define the options (their key words) that can be set in the option string
Definition: MethodLikelihood.cxx:243
TString
Basic string class.
Definition: TString.h:136
bool
PDF.h
TMVA::DataSetInfo
Class that contains all the data information.
Definition: DataSetInfo.h:62
TMVA::MethodLikelihood::fInterpolateString
TString * fInterpolateString
Definition: MethodLikelihood.h:152
TMVA::MethodLikelihood::AddWeightsXMLTo
void AddWeightsXMLTo(void *parent) const
write weights to XML
Definition: MethodLikelihood.cxx:581
TMVA::MethodLikelihood::fHistSig
std::vector< TH1 * > * fHistSig
Definition: MethodLikelihood.h:130
TMVA::Types::EAnalysisType
EAnalysisType
Definition: Types.h:128
TMVA::MethodLikelihood::fDefaultPDFLik
PDF * fDefaultPDFLik
Definition: MethodLikelihood.h:135
TMVA::MethodLikelihood::fAverageEvtPerBin
Int_t fAverageEvtPerBin
Definition: MethodLikelihood.h:145
TMVA::MethodLikelihood::fPDFBgd
std::vector< PDF * > * fPDFBgd
Definition: MethodLikelihood.h:137
TMVA::MethodLikelihood::HasAnalysisType
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
FDA can handle classification with 2 classes.
Definition: MethodLikelihood.cxx:216
TMVA::MethodBase
Virtual base Class for all MVA method.
Definition: MethodBase.h:111
TMVA::MethodLikelihood::WriteMonitoringHistosToFile
void WriteMonitoringHistosToFile() const
write histograms and PDFs to file for monitoring purposes
Definition: MethodLikelihood.cxx:734
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
TMVA::MethodLikelihood::DeclareCompatibilityOptions
void DeclareCompatibilityOptions()
options that are used ONLY for the READER to ensure backward compatibility they are hence without any...
Definition: MethodLikelihood.cxx:274
unsigned int
TMVA::PDF
PDF wrapper for histograms; uses user-defined spline interpolation.
Definition: PDF.h:63
TMVA::MethodLikelihood::MakeClassSpecific
void MakeClassSpecific(std::ostream &, const TString &) const
write specific classifier response
Definition: MethodLikelihood.cxx:791
TMVA::MethodLikelihood::fEpsilon
Double_t fEpsilon
Definition: MethodLikelihood.h:125
TMVA::MethodLikelihood::TransformLikelihoodOutput
Double_t TransformLikelihoodOutput(Double_t ps, Double_t pb) const
returns transformed or non-transformed output
Definition: MethodLikelihood.cxx:533
TMVA::MethodLikelihood::fHistBgd_smooth
std::vector< TH1 * > * fHistBgd_smooth
Definition: MethodLikelihood.h:133
Double_t
double Double_t
Definition: RtypesCore.h:59
TMVA::MethodLikelihood
Likelihood analysis ("non-parametric approach")
Definition: MethodLikelihood.h:61
TMVA::MethodLikelihood::MakeClassSpecificHeader
void MakeClassSpecificHeader(std::ostream &, const TString &="") const
write specific header of the classifier (mostly include files)
Definition: MethodLikelihood.cxx:782
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TMVA::MethodLikelihood::ProcessOptions
void ProcessOptions()
process user options reference cut value to distinguish signal-like from background-like events
Definition: MethodLikelihood.cxx:316
TMVA::MethodLikelihood::fPDFSig
std::vector< PDF * > * fPDFSig
Definition: MethodLikelihood.h:136
type
int type
Definition: TGX11.cxx:121
TMVA::MethodLikelihood::fNsmoothVarB
Int_t * fNsmoothVarB
Definition: MethodLikelihood.h:144
TMVA::MethodLikelihood::WriteOptionsToStream
virtual void WriteOptionsToStream(std::ostream &o, const TString &prefix) const
write options to stream
Definition: MethodLikelihood.cxx:557
TMVA::MethodLikelihood::fKDEiterString
TString fKDEiterString
Definition: MethodLikelihood.h:150
TMVA::MethodLikelihood::fBorderMethodString
TString fBorderMethodString
Definition: MethodLikelihood.h:148
TMVA
create variable transformations
Definition: GeneticMinimizer.h:22
int
TMVA::MethodLikelihood::fKDEtypeString
TString fKDEtypeString
Definition: MethodLikelihood.h:151
TMVA::MethodLikelihood::fHistBgd
std::vector< TH1 * > * fHistBgd
Definition: MethodLikelihood.h:131