Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
MethodBoost.h
Go to the documentation of this file.
1// @(#)root/tmva $Id$
2// Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss,Or Cohen, Jan Therhaag, Eckhard von Toerne
3
4/**********************************************************************************
5 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6 * Package: TMVA *
7 * Class : MethodCompositeBase *
8 * *
9 * *
10 * Description: *
11 * Virtual base class for all MVA method *
12 * *
13 * Authors (alphabetical): *
14 * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15 * Peter Speckmayer <Peter.Speckmazer@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 * Jan Therhaag <Jan.Therhaag@cern.ch> - U of Bonn, Germany *
19 * Eckhard v. Toerne <evt@uni-bonn.de> - U of Bonn, Germany *
20 * *
21 * Copyright (c) 2005-2011: *
22 * CERN, Switzerland *
23 * U. of Victoria, Canada *
24 * MPI-K Heidelberg, Germany *
25 * U. of Bonn, Germany *
26 * *
27 * Redistribution and use in source and binary forms, with or without *
28 * modification, are permitted according to the terms listed in LICENSE *
29 * (see tmva/doc/LICENSE) *
30 **********************************************************************************/
31
32#ifndef ROOT_TMVA_MethodBoost
33#define ROOT_TMVA_MethodBoost
34
35//////////////////////////////////////////////////////////////////////////
36// //
37// MethodBoost //
38// //
39// Class for boosting a TMVA method //
40// //
41//////////////////////////////////////////////////////////////////////////
42
43#include <iosfwd>
44#include <vector>
45
46#include "TMVA/MethodBase.h"
47
49
50namespace TMVA {
51
52 class Factory; // DSMTEST
53 class Reader; // DSMTEST
54 class DataSetManager; // DSMTEST
56 friend class Factory; // DSMTEST
57 friend class Reader; // DSMTEST
58
59 public :
60
61 // constructors
63 const TString& methodTitle,
65 const TString& theOption = "" );
66
68 const TString& theWeightFile );
69
70 virtual ~MethodBoost( void );
71
73
74 // training and boosting all the classifiers
75 void Train( void ) override;
76
77 // ranking of input variables
78 const Ranking* CreateRanking() override;
79
80 // saves the name and options string of the boosted classifier
82 void SetBoostedMethodName ( TString methodName ) { fBoostedMethodName = methodName; }
83
85
86 void CleanBoostOptions();
87
88 Double_t GetMvaValue( Double_t* err = nullptr, Double_t* errUpper = nullptr ) override;
89
90 private :
91 // clean up
92 void ClearAll();
93
94 // print fit results
95 void PrintResults( const TString&, std::vector<Double_t>&, const Double_t ) const;
96
97 // initializing mostly monitoring tools of the boost process
98 void Init() override;
99 void InitHistos();
100 void CheckSetup() override;
101
103
104 // the option handling methods
105 void DeclareOptions() override;
106 void DeclareCompatibilityOptions() override;
107 void ProcessOptions() override;
108
109
112 // training a single classifier
113 void SingleTrain();
114
115 // calculating a boosting weight from the classifier, storing it in the next one
119
120
121 // calculate weight of single method
123
124 // return ROC integral on training/testing sample
126
127 // writing the monitoring histograms and tree to a file
128 void WriteMonitoringHistosToFile( void ) const override;
129
130 // write evaluation histograms into target file
132
133 // performs the MethodBase testing + testing of each boosted classifier
134 virtual void TestClassification() override;
135
136 // finding the MVA to cut between sig and bgd according to fMVACutPerc,fMVACutType
138
139 // setting all the boost weights to 1
140 void ResetBoostWeights();
141
142 // creating the vectors of histogram for monitoring MVA response of each classifier
144
145 // calculate MVA values of current trained method on training
146 // sample
147 void CalcMVAValues();
148
149 UInt_t fBoostNum; ///< Number of times the classifier is boosted
150 TString fBoostType; ///< string specifying the boost type
151
152 TString fTransformString; ///< min and max values for the classifier response
153 Bool_t fDetailedMonitoring; ///< produce detailed monitoring histograms (boost-wise)
154
155 Double_t fAdaBoostBeta; ///< ADA boost parameter, default is 1
156 UInt_t fRandomSeed; ///< seed for random number generator used for bagging
157 Double_t fBaggedSampleFraction; ///< rel.Size of bagged sample
158
159 TString fBoostedMethodName; ///< details of the boosted classifier
162
163 Bool_t fMonitorBoostedMethod; ///< monitor the MVA response of every classifier
164
165 // MVA output from each classifier over the training hist, using orignal events weights
166 std::vector< TH1* > fTrainSigMVAHist;
167 std::vector< TH1* > fTrainBgdMVAHist;
168 // MVA output from each classifier over the training hist, using boosted events weights
169 std::vector< TH1* > fBTrainSigMVAHist;
170 std::vector< TH1* > fBTrainBgdMVAHist;
171 // MVA output from each classifier over the testing hist
172 std::vector< TH1* > fTestSigMVAHist;
173 std::vector
175
176 //monitoring tree/ntuple and it's variables
177 TTree* fMonitorTree; ///< tree to monitor values during the boosting
178 Double_t fBoostWeight; ///< the weight used to boost the next classifier
179 Double_t fMethodError; ///< estimation of the level error of the classifier
180 // analysing the train dataset
181 Double_t fROC_training; ///< roc integral of last trained method (on training sample)
182
183 // overlap integral of mva distributions for signal and
184 // background (training sample)
186
187 std::vector<Float_t> *fMVAvalues; ///< mva values for the last trained method
188
190 TString fHistoricOption; ///< historic variable, only needed for "CompatibilityOptions"
191 Bool_t fHistoricBoolOption; ///< historic variable, only needed for "CompatibilityOptions"
192
193 protected:
194
195 // get help message text
196 void GetHelpMessage() const override;
197
199 };
200}
201
202#endif
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
#define ClassDefOverride(name, id)
Definition Rtypes.h:347
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
Class that contains all the data information.
Definition DataSetInfo.h:62
Class that contains all the data information.
This is the main MVA steering class.
Definition Factory.h:80
Virtual base Class for all MVA method.
Definition MethodBase.h:79
friend class MethodBoost
Definition MethodBase.h:84
Class for boosting a TMVA method.
Definition MethodBoost.h:55
void MonitorBoost(Types::EBoostStage stage, UInt_t methodIdx=0)
fill various monitoring histograms from information of the individual classifiers that have been boos...
virtual void WriteEvaluationHistosToFile(Types::ETreeType treetype) override
writes all MVA evaluation histograms to file
void ResetBoostWeights()
resetting back the boosted weights of the events to 1
MethodBase * CurrentMethod()
Double_t fAdaBoostBeta
ADA boost parameter, default is 1.
TString fBoostedMethodOptions
options
Double_t fBaggedSampleFraction
rel.Size of bagged sample
void DeclareCompatibilityOptions() override
options that are used ONLY for the READER to ensure backward compatibility they are hence without any...
Double_t fBoostWeight
the weight used to boost the next classifier
std::vector< TH1 * > fTestSigMVAHist
void ProcessOptions() override
process user options
void SingleTrain()
initialization
virtual void TestClassification() override
initialization
UInt_t fBoostNum
Number of times the classifier is boosted.
void SetBoostedMethodName(TString methodName)
Definition MethodBoost.h:82
Bool_t fDetailedMonitoring
produce detailed monitoring histograms (boost-wise)
UInt_t fRandomSeed
seed for random number generator used for bagging
void PrintResults(const TString &, std::vector< Double_t > &, const Double_t) const
DataSetManager * fDataSetManager
DSMTEST.
std::vector< TH1 * > fTestBgdMVAHist
Bool_t fHistoricBoolOption
historic variable, only needed for "CompatibilityOptions"
TTree * fMonitorTree
tree to monitor values during the boosting
void DeclareOptions() override
Double_t AdaBoost(MethodBase *method, Bool_t useYesNoLeaf)
the standard (discrete or real) AdaBoost algorithm
TString fBoostedMethodTitle
title
Bool_t BookMethod(Types::EMVA theMethod, TString methodTitle, TString theOption)
just registering the string from which the boosted classifier will be created
UInt_t CurrentMethodIdx()
std::vector< TH1 * > fTrainSigMVAHist
TString fHistoricOption
historic variable, only needed for "CompatibilityOptions"
void InitHistos()
initialisation routine
void GetHelpMessage() const override
Get help message text.
TString fBoostType
string specifying the boost type
void Init() override
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t) override
Boost can handle classification with 2 classes and regression with one regression-target.
Double_t GetMvaValue(Double_t *err=nullptr, Double_t *errUpper=nullptr) override
return boosted MVA response
Double_t GetBoostROCIntegral(Bool_t, Types::ETreeType, Bool_t CalcOverlapIntergral=kFALSE)
Calculate the ROC integral of a single classifier or even the whole boosted classifier.
const Ranking * CreateRanking() override
Double_t fROC_training
roc integral of last trained method (on training sample)
TString fBoostedMethodName
details of the boosted classifier
std::vector< TH1 * > fBTrainBgdMVAHist
std::vector< TH1 * > fTrainBgdMVAHist
Double_t SingleBoost(MethodBase *method)
void Train(void) override
Double_t CalcMethodWeight()
std::vector< TH1 * > fBTrainSigMVAHist
Double_t Bagging()
Bagging or Bootstrap boosting, gives new random poisson weight for every event.
void WriteMonitoringHistosToFile(void) const override
write special monitoring histograms to file dummy implementation here --------------—
Double_t fMethodError
estimation of the level error of the classifier
TString fTransformString
min and max values for the classifier response
std::vector< Float_t > * fMVAvalues
mva values for the last trained method
Bool_t fMonitorBoostedMethod
monitor the MVA response of every classifier
virtual ~MethodBoost(void)
destructor
void FindMVACut(MethodBase *method)
find the CUT on the individual MVA that defines an event as correct or misclassified (to be used in t...
Double_t fOverlap_integral
void CheckSetup() override
check may be overridden by derived class (sometimes, eg, fitters are used which can only be implement...
Virtual base class for combining several TMVA method.
Ranking for variables in method (implementation)
Definition Ranking.h:48
The Reader class serves to use the MVAs in a specific analysis context.
Definition Reader.h:64
Basic string class.
Definition TString.h:137
A TTree represents a columnar dataset.
Definition TTree.h:89
create variable transformations