108 fVRangeMode(kAdaptive),
109 fKernelEstimator(
kBox),
122 fInitializedVolumeEle(0),
137 const TString& theWeightFile) :
294 Log() << kFATAL <<
"Mechanism to ignore events with negative weights in training not yet available for method: " 296 <<
" --> please remove \"IgnoreNegWeightsInTraining\" option from booking string." 333 Log() << kVERBOSE <<
"interpreted option string: vRangeMethod: '" 340 Log() << kVERBOSE <<
"nEventsMin/Max, maxVIterations, initialScale: " 354 if (
IsNormalised())
Log() << kFATAL <<
"\"Normalise\" option cannot be used with PDERS; " 355 <<
"please remove the option from the configuration string, or " 356 <<
"use \"!Normalise\"" 485 Log() << kFATAL <<
"GetNvar() == 0" <<
Endl;
506 Log() << kFATAL <<
"<SetVolumeElement> RMS not computed: " <<
fAverageRMS.size() <<
Endl;
508 Log() << kVERBOSE <<
"delta of var[" << (*fInputVars)[ivar]
510 <<
"\t | comp with |max - min|: " << (
GetXmax( ivar ) -
GetXmin( ivar ))
520 Log() << kFATAL <<
"<SetVolumeElement> unknown range-set mode: " 523 (*fShift)[ivar] = 0.5;
551 std::vector<const BinarySearchTreeNode*>& events,
562 #ifdef TMVA_MethodPDERS__countByHand__Debug__ 567 Int_t iS = 0, iB = 0;
572 for (
Int_t ivar=0; ivar<nvar; ivar++) {
574 inV = (x > (*volume->Lower)[ivar] && x <= (*volume->Upper)[ivar]);
581 Log() << kVERBOSE <<
"debug: my test: " << in <<
Endl;
582 Log() << kVERBOSE <<
"debug: binTree: " << count << Endl <<
Endl;
590 std::vector<Double_t> *lb =
new std::vector<Double_t>(
GetNvar() );
592 std::vector<Double_t> *ub =
new std::vector<Double_t>( *lb );
594 (*lb)[ivar] -= (*fDelta)[ivar]*(1.0 - (*fShift)[ivar]);
595 (*ub)[ivar] += (*fDelta)[ivar]*(*fShift)[ivar];
608 if (MethodPDERS_UseFindRoot) {
615 RootFinder rootFinder(
this, 0.01, 50, 200, 10 );
639 if (i_ > 50)
Log() << kWARNING <<
"warning in event: " << e
640 <<
": adaptive volume pre-adjustment reached " 641 <<
">50 iterations in while loop (" << i_ <<
")" <<
Endl;
649 Float_t nEventsBest = nEventsN;
652 if (nEventsN < fNEventsMin || nEventsN >
fNEventsMax) {
660 if (nEventsN > 1 && nEventsN - nEventsO != 0)
661 if (scaleN - scaleO != 0)
662 scale += (scaleN - scaleO)/(nEventsN - nEventsO)*(nEventsE - nEventsN);
673 (nEventsN >=
fNEventsMin || nEventsBest < nEventsN)) {
674 nEventsBest = nEventsN;
685 nEventsN = nEventsBest;
687 if (nEventsN < fNEventsMin-1 || nEventsN >
fNEventsMax+1)
688 Log() << kWARNING <<
"warning in event " << e
689 <<
": adaptive volume adjustment reached " 690 <<
"max. #iterations (" << fMaxVIterations <<
")" 728 Log() << kWARNING <<
"warning in event" << e
729 <<
": kNN volume adjustment reached " 739 dim_normalization [ivar] = 1.0 / ((*v.
fUpper)[ivar] - (*v.
fLower)[ivar]);
742 std::vector<const BinarySearchTreeNode*> tempVector;
745 std::vector<Double_t> *distances =
new std::vector<Double_t>( kNNcount );
752 std::vector<Double_t>::iterator wsk = distances->begin();
754 std::nth_element( distances->begin(), wsk, distances->end() );
761 if (dist <= (*distances)[fkNNMin-1])
762 tempVector.push_back( events[j] );
767 delete[] dim_normalization;
782 std::vector<const BinarySearchTreeNode*> events;
787 std::vector<Double_t> *lb =
new std::vector<Double_t>(
GetNvar() );
790 std::vector<Double_t> *ub =
new std::vector<Double_t>( *lb );
792 (*lb)[ivar] -= (*fDelta)[ivar]*(1.0 - (*fShift)[ivar]);
793 (*ub)[ivar] += (*fDelta)[ivar]*(*fShift)[ivar];
811 std::vector<const BinarySearchTreeNode*> events;
816 std::vector<Double_t> *lb =
new std::vector<Double_t>(
GetNvar() );
819 std::vector<Double_t> *ub =
new std::vector<Double_t>( *lb );
821 (*lb)[ivar] -= (*fDelta)[ivar]*(1.0 - (*fShift)[ivar]);
822 (*ub)[ivar] += (*fDelta)[ivar]*(*fShift)[ivar];
837 std::vector<const BinarySearchTreeNode*>& events,
Volume&
v )
841 dim_normalization [ivar] = 2 / ((*v.
fUpper)[ivar] - (*v.
fLower)[ivar]);
847 for (std::vector<const BinarySearchTreeNode*>::iterator iev = events.begin(); iev != events.end(); iev++) {
864 delete[] dim_normalization;
866 if (pdfSumS < 1
e-20 && pdfSumB < 1
e-20)
return 0.5;
867 if (pdfSumB < 1
e-20)
return 1.0;
868 if (pdfSumS < 1
e-20)
return 0.0;
871 return 1.0/(r + 1.0);
878 std::vector<const BinarySearchTreeNode*>& events,
Volume&
v,
879 std::vector<Float_t>* pdfSum )
883 dim_normalization [ivar] = 2 / ((*v.
fUpper)[ivar] - (*v.
fLower)[ivar]);
891 pdfSum->push_back( 0 );
894 for (std::vector<const BinarySearchTreeNode*>::iterator iev = events.begin(); iev != events.end(); iev++) {
904 pdfSum->at(ivar) +=
ApplyKernelFunction (normalized_distance) * (*iev)->GetWeight() * (*iev)->GetTargets()[ivar];
909 delete[] dim_normalization;
915 pdfSum->at(ivar) /= pdfDiv;
932 return (1 - normalized_distance);
943 return NormSinc (side_crossings * normalized_distance);
982 if (ret != 0.0)
return ret*pdf;
1043 if (x < 10e-10 && x > -10
e-10) {
1064 if (x < 10e-10 && x > -10
e-10) {
1086 Float_t d = countS + c*countB; d *= d;
1088 if (d < 1
e-10)
return 1;
1091 Float_t err = f*countB*countB*sumW2S + f*countS*countS*sumW2B;
1093 if (err < 1
e-10)
return 1;
1107 Log() << kFATAL <<
"Signal and background binary search tree not available" <<
Endl;
1119 Log() << kFATAL <<
"Could not create BinarySearchTree from XML" <<
Endl;
1121 Log() << kFATAL <<
"Could not create BinarySearchTree from XML" <<
Endl;
1150 fBinaryTree->CalcStatistics();
1152 fBinaryTree->CountNodes();
1201 fout <<
" // not implemented for class: \"" << className <<
"\"" << std::endl;
1202 fout <<
"};" << std::endl;
1216 Log() <<
"PDERS is a generalization of the projective likelihood classifier " <<
Endl;
1217 Log() <<
"to N dimensions, where N is the number of input variables used." <<
Endl;
1218 Log() <<
"In its adaptive form it is mostly equivalent to k-Nearest-Neighbor" <<
Endl;
1219 Log() <<
"(k-NN) methods. If the multidimensional PDF for signal and background" <<
Endl;
1220 Log() <<
"were known, this classifier would exploit the full information" <<
Endl;
1221 Log() <<
"contained in the input variables, and would hence be optimal. In " <<
Endl;
1222 Log() <<
"practice however, huge training samples are necessary to sufficiently " <<
Endl;
1223 Log() <<
"populate the multidimensional phase space. " <<
Endl;
1225 Log() <<
"The simplest implementation of PDERS counts the number of signal" <<
Endl;
1226 Log() <<
"and background events in the vicinity of a test event, and returns" <<
Endl;
1227 Log() <<
"a weight according to the majority species of the neighboring events." <<
Endl;
1228 Log() <<
"A more involved version of PDERS (selected by the option \"KernelEstimator\")" <<
Endl;
1229 Log() <<
"uses Kernel estimation methods to approximate the shape of the PDF." <<
Endl;
1233 Log() <<
"PDERS can be very powerful in case of strongly non-linear problems, " <<
Endl;
1234 Log() <<
"e.g., distinct islands of signal and background regions. Because of " <<
Endl;
1235 Log() <<
"the exponential growth of the phase space, it is important to restrict" <<
Endl;
1236 Log() <<
"the number of input variables (dimension) to the strictly necessary." <<
Endl;
1238 Log() <<
"Note that PDERS is a slowly responding classifier. Moreover, the necessity" <<
Endl;
1239 Log() <<
"to store the entire binary tree in memory, to avoid accessing virtual " <<
Endl;
1240 Log() <<
"memory, limits the number of training events that can effectively be " <<
Endl;
1241 Log() <<
"used to model the multidimensional PDF." <<
Endl;
1245 Log() <<
"If the PDERS response is found too slow when using the adaptive volume " <<
Endl;
1246 Log() <<
"size (option \"VolumeRangeMode=Adaptive\"), it might be found beneficial" <<
Endl;
1247 Log() <<
"to reduce the number of events required in the volume, and/or to enlarge" <<
Endl;
1248 Log() <<
"the allowed range (\"NeventsMin/Max\"). PDERS is relatively insensitive" <<
Endl;
1249 Log() <<
"to the width (\"GaussSigma\") of the Gaussian kernel (if used)." <<
Endl;
Int_t SearchVolumeWithMaxLimit(TMVA::Volume *, std::vector< const TMVA::BinarySearchTreeNode *> *events=0, Int_t=-1)
recursively walk through the daughter nodes and add up all weights of events that lie within the give...
std::vector< Double_t > * fLower
virtual void * AddXMLTo(void *parent) const
add attributes to XML
void WriteWeightsToStream(TFile &rf) const
write training sample (TTree) to file
void Delete(void)
delete array of volume bondaries
void UpdateThis()
update static this pointer
double dist(Rotation3D const &r1, Rotation3D const &r2)
virtual ~MethodPDERS(void)
destructor
MsgLogger & Endl(MsgLogger &ml)
Singleton class for Global types used by TMVA.
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.
std::vector< Float_t > * fShift
void GetHelpMessage() const
get help message text
BinarySearchTree * fBinaryTree
Double_t NormSinc(Double_t x)
NormSinc.
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
void CreateBinarySearchTree(Types::ETreeType type)
create binary search trees for signal and background
Double_t Fill(const std::vector< TMVA::Event *> &events, const std::vector< Int_t > &theVars, Int_t theType=-1)
create the search tree from the event collection using ONLY the variables specified in "theVars" ...
Virtual base Class for all MVA method.
std::vector< Double_t > * fUpper
void AddWeightsXMLTo(void *parent) const
write weights to xml file
TransformationHandler & GetTransformationHandler(Bool_t takeReroutedIfAvailable=true)
void ScaleInterval(Double_t f)
"scale" the volume by symmetrically blowing up the interval in each dimension
void RKernelEstimate(const Event &, std::vector< const BinarySearchTreeNode *> &, Volume &, std::vector< Float_t > *pdfSum)
normalization factors so we can work with radius 1 hyperspheres
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...
Double_t Gamma(Double_t z)
Computation of gamma(z) for all z.
Node for the BinarySearch or Decision Trees.
Double_t GetSumOfWeights(void) const
return the sum of event (node) weights
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Volume for BinarySearchTree.
void GetSample(const Event &e, std::vector< const BinarySearchTreeNode *> &events, Volume *volume)
void NormalizeTree()
Normalisation of tree.
void Init(void)
default initialisation routine called by all constructors
static Double_t IGetVolumeContentForRoot(Double_t)
Interface to RootFinder.
void ReadWeightsFromStream(std::istream &istr)
read weight info from file
const Event * GetEvent() const
Double_t GetXmin(Int_t ivar) const
Float_t GetError(Float_t countS, Float_t countB, Float_t sumW2S, Float_t sumW2B) const
statistical error estimate for RS estimator
Bool_t DoRegression() const
Class that contains all the data information.
Long64_t GetNTrainingEvents() const
void CalcStatistics(TMVA::Node *n=0)
calculate basic statistics (mean, rms for each variable)
const Event * GetTrainingEvent(Long64_t ievt) const
UInt_t GetNTargets() const
accessor to the number of targets
Double_t Root(Double_t refValue)
Root finding using Brents algorithm; taken from CERNLIB function RZERO.
void CalcAverages()
compute also average RMS values required for adaptive Gaussian
Double_t CRScalc(const Event &)
Double_t GetXmax(Int_t ivar) const
static BinarySearchTree * CreateFromXML(void *node, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
re-create a new tree (decision tree or search tree) from XML
void DeclareOptions()
define the options (their key words) that can be set in the option string.
Float_t GetTarget(UInt_t itgt) const
void SetVolumeElement(void)
defines volume dimensions
Bool_t fInitializedVolumeEle
BinarySearchTree * GetBinaryTree(void) const
void SetTarget(UInt_t itgt, Float_t value)
set the target value (dimension itgt) to value
void SetNormalize(Bool_t norm)
Double_t Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE)
Calculate a gaussian function with mean and sigma.
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
void ReadWeightsFromXML(void *wghtnode)
static MethodPDERS * ThisPDERS(void)
static pointer to this object
Bool_t IgnoreEventsWithNegWeightsInTraining() const
This is a generalization of the above Likelihood methods to dimensions, where is the number of inpu...
void Train(void)
this is a dummy training: the preparation work to do is the construction of the binary tree as a poin...
const std::vector< TMVA::Event * > & GetEventCollection(Types::ETreeType type)
returns the event collection (i.e.
std::vector< Float_t > * fDelta
Float_t RMS(Types::ESBType sb, UInt_t var)
enum TMVA::MethodPDERS::EKernelEstimator fKernelEstimator
Bool_t IsNormalised() const
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
void AddPreDefVal(const T &)
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.
Double_t CKernelEstimate(const Event &, std::vector< const BinarySearchTreeNode *> &, Volume &)
normalization factors so we can work with radius 1 hyperspheres
std::vector< Float_t > fAverageRMS
UInt_t CountNodes(Node *n=NULL)
return the number of nodes in the tree. (make a new count –> takes time)
const std::vector< Float_t > & GetEventV() const
const std::vector< Float_t > & GetRegressionValues()
#define REGISTER_METHOD(CLASS)
for example
Root finding using Brents algorithm (translated from CERNLIB function RZERO)
Abstract ClassifierFactory template that handles arbitrary types.
TString GetMethodTypeName() const
enum TMVA::MethodPDERS::EVolumeRangeMode fVRangeMode
void ProcessOptions()
process the options specified by the user
std::vector< Float_t > * fRegressionReturnVal
Double_t GetVolumeContentForRoot(Double_t)
count number of events in rescaled volume
MethodPDERS(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption)
standard constructor for the PDERS method
Double_t Sqrt(Double_t x)
Double_t SearchVolume(Volume *, std::vector< const TMVA::BinarySearchTreeNode *> *events=0)
search the whole tree and add up all weights of events that lie within the given volume ...
static MethodPDERS *& GetMethodPDERSThreadLocal()
Double_t ApplyKernelFunction(Double_t normalized_distance)
from the normalized euclidean distance calculate the distance for a certain kernel ...
A simple Binary search tree including a volume search method.
Double_t LanczosFilter(Int_t level, Double_t x)
Lanczos Filter.
void RRScalc(const Event &, std::vector< Float_t > *count)
Double_t KernelNormalization(Double_t pdf)
Calculating the normalization factor only once (might need a reset at some point. ...
void MakeClassSpecific(std::ostream &, const TString &) const
write specific classifier response
void NoErrorCalc(Double_t *const err, Double_t *const errUpper)
void SetSignalReferenceCut(Double_t cut)