Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
MethodPDERS.h
Go to the documentation of this file.
1// @(#)root/tmva $Id$
2// Author: Andreas Hoecker, Yair Mahalalel, Joerg Stelzer, Helge Voss, Kai Voss
3
4/**********************************************************************************
5 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6 * Package: TMVA *
7 * Class : MethodPDERS *
8 * Web : http://tmva.sourceforge.net *
9 * *
10 * Description: *
11 * Multidimensional Likelihood using the "Probability density estimator *
12 * range search" (PDERS) method suggested in *
13 * T. Carli and B. Koblitz, NIM A 501, 576 (2003) *
14 * *
15 * The multidimensional PDFs for signal and background are modeled *
16 * by counting the events in the "vicinity" of a test point. The volume *
17 * that describes "vicinity" is user-defined through the option string. *
18 * A search method based on binary-trees is used to improve the selection *
19 * efficiency of the volume search. *
20 * *
21 * Authors (alphabetical): *
22 * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
23 * Yair Mahalalel <Yair.Mahalalel@cern.ch> - CERN, Switzerland *
24 * Peter Speckmayer <peter.speckmayer@cern.ch> - CERN, Switzerland *
25 * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
26 * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
27 * *
28 * Copyright (c) 2005: *
29 * CERN, Switzerland *
30 * U. of Victoria, Canada *
31 * MPI-K Heidelberg, 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_MethodPDERS
39#define ROOT_TMVA_MethodPDERS
40
41//////////////////////////////////////////////////////////////////////////
42// //
43// MethodPDERS //
44// //
45// Multidimensional Likelihood using the "Probability density //
46// estimator range search" (PDERS) method //
47// //
48//////////////////////////////////////////////////////////////////////////
49
50#include "TMVA/MethodBase.h"
52#include "TVector.h"
53#include "ThreadLocalStorage.h"
54#include <vector>
55
56namespace TMVA {
57
58 class Volume;
59 class Event;
60
61 class MethodPDERS : public MethodBase {
62
63 public:
64
65 MethodPDERS( const TString& jobName,
66 const TString& methodTitle,
67 DataSetInfo& theData,
68 const TString& theOption);
69
70 MethodPDERS( DataSetInfo& theData,
71 const TString& theWeightFile);
72
73 virtual ~MethodPDERS( void );
74
75 virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
76
77
78 // training method
79 void Train( void );
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
90 // calculate the MVA value
91 Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
92
93 // calculate the MVA value
94 const std::vector<Float_t>& GetRegressionValues();
95 public:
96
97 // for root finder
100
101 // static pointer to this object
102 static MethodPDERS* ThisPDERS( void );
103
104 protected:
105
106 // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
107 void MakeClassSpecific( std::ostream&, const TString& ) const;
108
109 // get help message text
110 void GetHelpMessage() const;
111
112 Volume* fHelpVolume; // auxiliary variable
113 Int_t fFcnCall; // number of external function calls (RootFinder)
114
115 // accessors
116 BinarySearchTree* GetBinaryTree( void ) const { return fBinaryTree; }
117
118 Double_t CKernelEstimate( const Event&, std::vector<const BinarySearchTreeNode*>&, Volume& );
119 void RKernelEstimate( const Event&, std::vector<const BinarySearchTreeNode*>&, Volume&, std::vector<Float_t> *pdfSum );
120
121 Double_t ApplyKernelFunction( Double_t normalized_distance );
123 Double_t GetNormalizedDistance( const TMVA::Event &base_event,
124 const BinarySearchTreeNode &sample_event,
125 Double_t *dim_normalization);
128
129 // ranking of input variables
130 const Ranking* CreateRanking() { return 0; }
131
132 private:
133
134 // the option handling methods
135 void DeclareOptions();
136 void ProcessOptions();
137
138 // calculate the averages of the input variables needed for adaptive training
139 void CalcAverages();
140
141 // create binary search trees for signal and background
143
144 // get sample of training events
145 void GetSample( const Event &e, std::vector<const BinarySearchTreeNode*>& events, Volume *volume);
146
147 // option
148 TString fVolumeRange; // option volume range
149 TString fKernelString; // option kernel estimator
150
157 kkNN
159
161 kBox = 0,
165 kSinc3, // the sinc enumerators must be consecutive and in order!
174 kTrim
176
178
179 std::vector<Float_t>* fDelta; // size of volume
180 std::vector<Float_t>* fShift; // volume center
181 std::vector<Float_t> fAverageRMS; // average RMS of signal and background
182
183 Float_t fScaleS; // weight for signal events
184 Float_t fScaleB; // weight for background events
185 Float_t fDeltaFrac; // fraction of RMS
186 Double_t fGaussSigma; // size of Gauss in adaptive volume
187 Double_t fGaussSigmaNorm;// size of Gauss in adaptive volume (normalised to dimensions)
188
189 Double_t fNRegOut; // number of output dimensions for regression
190
191 // input for adaptive volume adjustment
192 Float_t fNEventsMin; // minimum number of events in adaptive volume
193 Float_t fNEventsMax; // maximum number of events in adaptive volume
194 Float_t fMaxVIterations;// maximum number of iterations to adapt volume size
195 Float_t fInitialScale; // initial scale for adaptive volume
196
197 Bool_t fInitializedVolumeEle; // is volume element initialized ?
198
199 Int_t fkNNMin; // min number of events in kNN tree
200 Int_t fkNNMax; // max number of events in kNN tree
201
202 Double_t fMax_distance; // maximum distance
203 Bool_t fPrinted; // print
204 Bool_t fNormTree; // binary-search tree is normalised
205
206 void SetVolumeElement ( void );
207
208 Double_t CRScalc ( const Event& );
209 void RRScalc ( const Event&, std::vector<Float_t>* count );
210
211 Float_t GetError ( Float_t countS, Float_t countB,
212 Float_t sumW2S, Float_t sumW2B ) const;
213
214 // This is a workaround for OSx where static thread_local data members are
215 // not supported. The C++ solution would indeed be the following:
216 static MethodPDERS*& GetMethodPDERSThreadLocal() {TTHREAD_TLS(MethodPDERS*) fgThisPDERS(nullptr); return fgThisPDERS;};
217 void UpdateThis();
218
219 void Init( void );
220
221 ClassDef(MethodPDERS,0); // Multi-dimensional probability density estimator range search (PDERS) method
222 };
223
224} // namespace TMVA
225
226#endif // MethodPDERS_H
#define e(i)
Definition RSha256.hxx:103
double Double_t
Definition RtypesCore.h:59
float Float_t
Definition RtypesCore.h:57
#define ClassDef(name, id)
Definition Rtypes.h:325
int type
Definition TGX11.cxx:121
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition TFile.h:54
Node for the BinarySearch or Decision Trees.
A simple Binary search tree including a volume search method.
Class that contains all the data information.
Definition DataSetInfo.h:62
Virtual base Class for all MVA method.
Definition MethodBase.h:111
This is a generalization of the above Likelihood methods to dimensions, where is the number of inpu...
Definition MethodPDERS.h:61
void WriteWeightsToStream(TFile &rf) const
write training sample (TTree) to file
static MethodPDERS *& GetMethodPDERSThreadLocal()
void CreateBinarySearchTree(Types::ETreeType type)
create binary search trees for signal and background
BinarySearchTree * fBinaryTree
std::vector< Float_t > * fDelta
virtual ~MethodPDERS(void)
destructor
Bool_t fInitializedVolumeEle
void GetSample(const Event &e, std::vector< const BinarySearchTreeNode * > &events, Volume *volume)
Double_t fMax_distance
Float_t GetError(Float_t countS, Float_t countB, Float_t sumW2S, Float_t sumW2B) const
statistical error estimate for RS estimator
BinarySearchTree * GetBinaryTree(void) const
static MethodPDERS * ThisPDERS(void)
static pointer to this object
Double_t KernelNormalization(Double_t pdf)
Calculating the normalization factor only once (might need a reset at some point.
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
init the size of a volume element using a defined fraction of the volume containing the entire events
std::vector< Float_t > fAverageRMS
void ReadWeightsFromXML(void *wghtnode)
void ProcessOptions()
process the options specified by the user
void RRScalc(const Event &, std::vector< Float_t > *count)
void GetHelpMessage() const
get help message text
void UpdateThis()
update static this pointer
void Train(void)
this is a dummy training: the preparation work to do is the construction of the binary tree as a poin...
void MakeClassSpecific(std::ostream &, const TString &) const
write specific classifier response
Double_t CRScalc(const Event &)
void DeclareOptions()
define the options (their key words) that can be set in the option string.
const Ranking * CreateRanking()
Double_t fGaussSigmaNorm
std::vector< Float_t > * fShift
void CalcAverages()
compute also average RMS values required for adaptive Gaussian
enum TMVA::MethodPDERS::EVolumeRangeMode fVRangeMode
void RKernelEstimate(const Event &, std::vector< const BinarySearchTreeNode * > &, Volume &, std::vector< Float_t > *pdfSum)
normalization factors so we can work with radius 1 hyperspheres
void ReadWeightsFromStream(std::istream &istr)
read weight info from file
enum TMVA::MethodPDERS::EKernelEstimator fKernelEstimator
const std::vector< Float_t > & GetRegressionValues()
Double_t NormSinc(Double_t x)
NormSinc.
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
PDERS can handle classification with 2 classes and regression with one or more regression-targets.
void AddWeightsXMLTo(void *parent) const
write weights to xml file
void SetVolumeElement(void)
defines volume dimensions
void Init(void)
default initialisation routine called by all constructors
Double_t LanczosFilter(Int_t level, Double_t x)
Lanczos Filter.
Double_t CKernelEstimate(const Event &, std::vector< const BinarySearchTreeNode * > &, Volume &)
normalization factors so we can work with radius 1 hyperspheres
Float_t fMaxVIterations
Double_t ApplyKernelFunction(Double_t normalized_distance)
from the normalized euclidean distance calculate the distance for a certain kernel
Double_t GetNormalizedDistance(const TMVA::Event &base_event, const BinarySearchTreeNode &sample_event, Double_t *dim_normalization)
We use Euclidian metric here. Might not be best or most efficient.
static Double_t IGetVolumeContentForRoot(Double_t)
Interface to RootFinder.
Double_t GetVolumeContentForRoot(Double_t)
count number of events in rescaled volume
Ranking for variables in method (implementation)
Definition Ranking.h:48
Volume for BinarySearchTree.
Definition Volume.h:47
Basic string class.
Definition TString.h:136
Double_t x[n]
Definition legend1.C:17
create variable transformations