Logo ROOT   6.10/09
Reference Guide
OptimizeConfigParameters.cxx
Go to the documentation of this file.
1 /**********************************************************************************
2  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
3  * Package: TMVA *
4  * Class : OptimizeConfigParameters *
5  * Web : http://tmva.sourceforge.net *
6  * *
7  * Description: The OptimizeConfigParameters takes care of "scanning/fitting" *
8  * different tuning parameters in order to find the best set of *
9  * tuning paraemters which will be used in the end *
10  * *
11  * Authors (alphabetical): *
12  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
13  * *
14  * Copyright (c) 2005: *
15  * CERN, Switzerland *
16  * MPI-K Heidelberg, Germany *
17  * *
18  * Redistribution and use in source and binary forms, with or without *
19  * modification, are permitted according to the terms listed in LICENSE *
20  * (http://ttmva.sourceforge.net/LICENSE) *
21  **********************************************************************************/
22 
23 /*! \class TMVA::OptimizeConfigParameters
24 \ingroup TMVA
25 
26 */
27 
29 
30 #include "TMVA/DataSet.h"
31 #include "TMVA/DataSetInfo.h"
32 #include "TMVA/Event.h"
33 #include "TMVA/IFitterTarget.h"
34 #include "TMVA/FitterBase.h"
35 #include "TMVA/GeneticFitter.h"
36 #include "TMVA/IMethod.h"
37 #include "TMVA/Interval.h"
38 #include "TMVA/MethodBase.h"
39 #include "TMVA/MethodFDA.h"
40 #include "TMVA/MsgLogger.h"
41 #include "TMVA/MinuitFitter.h"
42 #include "TMVA/PDF.h"
43 #include "TMVA/Tools.h"
44 #include "TMVA/Types.h"
45 
46 #include "TDirectory.h"
47 #include "TGraph.h"
48 #include "TH1.h"
49 #include "TH2.h"
50 #include "TMath.h"
51 
52 #include <cstdlib>
53 #include <limits>
54 
55 
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 /// Constructor which sets either "Classification or Regression"
60 
61 TMVA::OptimizeConfigParameters::OptimizeConfigParameters(MethodBase * const method, std::map<TString,TMVA::Interval*> tuneParameters, TString fomType, TString optimizationFitType)
62 : fMethod(method),
63  fTuneParameters(tuneParameters),
64  fFOMType(fomType),
65  fOptimizationFitType(optimizationFitType),
66  fMvaSig(NULL),
67  fMvaBkg(NULL),
68  fMvaSigFineBin(NULL),
69  fMvaBkgFineBin(NULL),
70  fNotDoneYet(kFALSE)
71 {
72  std::string name = "OptimizeConfigParameters_";
73  name += std::string(GetMethod()->GetName());
74  fLogger = new MsgLogger(name);
75  if (fMethod->DoRegression()){
76  Log() << kFATAL << " ERROR: Sorry, Regression is not yet implement for automatic parameter optimization"
77  << " --> exit" << Endl;
78  }
79 
80  Log() << kINFO << "Automatic optimisation of tuning parameters in "
81  << GetMethod()->GetName() << " uses:" << Endl;
82 
83  std::map<TString,TMVA::Interval*>::iterator it;
84  for (it=fTuneParameters.begin(); it!=fTuneParameters.end();it++) {
85  Log() << kINFO << it->first
86  << " in range from: " << it->second->GetMin()
87  << " to: " << it->second->GetMax()
88  << " in : " << it->second->GetNbins() << " steps"
89  << Endl;
90  }
91  Log() << kINFO << " using the options: " << fFOMType << " and " << fOptimizationFitType << Endl;
92 }
93 
94 ////////////////////////////////////////////////////////////////////////////////
95 /// the destructor (delete the OptimizeConfigParameters, store the graph and .. delete it)
96 
98 {
99  if(!GetMethod()->IsSilentFile()) GetMethod()->BaseDir()->cd();
100  Int_t n=Int_t(fFOMvsIter.size());
101  Float_t *x = new Float_t[n];
102  Float_t *y = new Float_t[n];
103  Float_t ymin=+999999999;
104  Float_t ymax=-999999999;
105 
106  for (Int_t i=0;i<n;i++){
107  x[i] = Float_t(i);
108  y[i] = fFOMvsIter[i];
109  if (ymin>y[i]) ymin=y[i];
110  if (ymax<y[i]) ymax=y[i];
111  }
112 
113  TH2D *h=new TH2D(TString(GetMethod()->GetName())+"_FOMvsIterFrame","",2,0,n,2,ymin*0.95,ymax*1.05);
114  h->SetXTitle("#iteration "+fOptimizationFitType);
115  h->SetYTitle(fFOMType);
116  TGraph *gFOMvsIter = new TGraph(n,x,y);
117  gFOMvsIter->SetName((TString(GetMethod()->GetName())+"_FOMvsIter").Data());
118  if(!GetMethod()->IsSilentFile()) gFOMvsIter->Write();
119  if(!GetMethod()->IsSilentFile()) h->Write();
120 
121  delete [] x;
122  delete [] y;
123  // delete fFOMvsIter;
124 }
125 
126 ////////////////////////////////////////////////////////////////////////////////
127 
128 std::map<TString,Double_t> TMVA::OptimizeConfigParameters::optimize()
129 {
130  if (fOptimizationFitType == "Scan" ) this->optimizeScan();
131  else if (fOptimizationFitType == "FitGA" || fOptimizationFitType == "Minuit" ) this->optimizeFit();
132  else {
133  Log() << kFATAL << "You have chosen as optimization type " << fOptimizationFitType
134  << " that is not (yet) coded --> exit()" << Endl;
135  }
136 
137  Log() << kINFO << "For " << GetMethod()->GetName() << " the optimized Parameters are: " << Endl;
138  std::map<TString,Double_t>::iterator it;
139  for(it=fTunedParameters.begin(); it!= fTunedParameters.end(); it++){
140  Log() << kINFO << it->first << " = " << it->second << Endl;
141  }
142  return fTunedParameters;
143 
144 }
145 
146 ////////////////////////////////////////////////////////////////////////////////
147 /// helper function to scan through the all the combinations in the
148 /// parameter space
149 
150 std::vector< int > TMVA::OptimizeConfigParameters::GetScanIndices( int val, std::vector<int> base){
151  std::vector < int > indices;
152  for (UInt_t i=0; i< base.size(); i++){
153  indices.push_back(val % base[i] );
154  val = int( floor( float(val) / float(base[i]) ) );
155  }
156  return indices;
157 }
158 
159 ////////////////////////////////////////////////////////////////////////////////
160 /// do the actual optimization using a simple scan method,
161 /// i.e. calculate the FOM for
162 /// different tuning paraemters and remember which one is
163 /// gave the best FOM
164 
166 {
167 
168  Double_t bestFOM=-1000000, currentFOM;
169 
170  std::map<TString,Double_t> currentParameters;
171  std::map<TString,TMVA::Interval*>::iterator it;
172 
173  // for the scan, start at the lower end of the interval and then "move upwards"
174  // initialize all parameters in currentParameter
175  currentParameters.clear();
176  fTunedParameters.clear();
177 
178  for (it=fTuneParameters.begin(); it!=fTuneParameters.end(); it++){
179  currentParameters.insert(std::pair<TString,Double_t>(it->first,it->second->GetMin()));
180  fTunedParameters.insert(std::pair<TString,Double_t>(it->first,it->second->GetMin()));
181  }
182  // now loop over all the parameters and get for each combination the figure of merit
183 
184  // in order to loop over all the parameters, I first create an "array" (tune parameters)
185  // of arrays (the different values of the tune parameter)
186 
187  std::vector< std::vector <Double_t> > v;
188  for (it=fTuneParameters.begin(); it!=fTuneParameters.end(); it++){
189  std::vector< Double_t > tmp;
190  for (Int_t k=0; k<it->second->GetNbins(); k++){
191  tmp.push_back(it->second->GetElement(k));
192  }
193  v.push_back(tmp);
194  }
195  Int_t Ntot = 1;
196  std::vector< int > Nindividual;
197  for (UInt_t i=0; i<v.size(); i++) {
198  Ntot *= v[i].size();
199  Nindividual.push_back(v[i].size());
200  }
201  //loop on the total number of different combinations
202 
203  for (int i=0; i<Ntot; i++){
204  UInt_t index=0;
205  std::vector<int> indices = GetScanIndices(i, Nindividual );
206  for (it=fTuneParameters.begin(), index=0; index< indices.size(); index++, it++){
207  currentParameters[it->first] = v[index][indices[index]];
208  }
209  Log() << kINFO << "--------------------------" << Endl;
210  Log() << kINFO <<"Settings being evaluated:" << Endl;
211  for (std::map<TString,Double_t>::iterator it_print=currentParameters.begin();
212  it_print!=currentParameters.end(); it_print++){
213  Log() << kINFO << " " << it_print->first << " = " << it_print->second << Endl;
214  }
215 
216  GetMethod()->Reset();
217  GetMethod()->SetTuneParameters(currentParameters);
218  // now do the training for the current parameters:
219  if(!GetMethod()->IsSilentFile()) GetMethod()->BaseDir()->cd();
221  GetMethod()->Data()->GetEventCollection());
223  GetMethod()->Train();
225  currentFOM = GetFOM();
226  Log() << kINFO << "FOM was found : " << currentFOM << "; current best is " << bestFOM << Endl;
227 
228  if (currentFOM > bestFOM) {
229  bestFOM = currentFOM;
230  for (std::map<TString,Double_t>::iterator iter=currentParameters.begin();
231  iter != currentParameters.end(); iter++){
232  fTunedParameters[iter->first]=iter->second;
233  }
234  }
235  }
236 
237  GetMethod()->Reset();
239 }
240 
241 ////////////////////////////////////////////////////////////////////////////////
242 
244 {
245  // ranges (intervals) in which the fit varies the parameters
246  std::vector<TMVA::Interval*> ranges; // intervals of the fit ranges
247  std::map<TString, TMVA::Interval*>::iterator it;
248  std::vector<Double_t> pars; // current (starting) fit parameters
249 
250  for (it=fTuneParameters.begin(); it != fTuneParameters.end(); it++){
251  ranges.push_back(new TMVA::Interval(*(it->second)));
252  pars.push_back( (it->second)->GetMean() ); // like this the order is "right". Always keep the
253  // order in the vector "pars" the same as the iterator
254  // iterates through the tuneParameters !!!!
255  }
256 
257  // added to allow for transformation on input variables i.e. norm
258  GetMethod()->GetTransformationHandler().CalcTransformations(GetMethod()->Data()->GetEventCollection());
259 
260  // create the fitter
261 
262  FitterBase* fitter = NULL;
263 
264  if ( fOptimizationFitType == "Minuit" ) {
265  TString opt="";
266  fitter = new MinuitFitter( *this,
267  "FitterMinuit_BDTOptimize",
268  ranges, opt );
269  }else if ( fOptimizationFitType == "FitGA" ) {
270  TString opt="PopSize=20:Steps=30:Cycles=3:ConvCrit=0.01:SaveBestCycle=5";
271  fitter = new GeneticFitter( *this,
272  "FitterGA_BDTOptimize",
273  ranges, opt );
274  } else {
275  Log() << kWARNING << " you did not specify a valid OptimizationFitType "
276  << " will use the default (FitGA) " << Endl;
277  TString opt="PopSize=20:Steps=30:Cycles=3:ConvCrit=0.01:SaveBestCycle=5";
278  fitter = new GeneticFitter( *this,
279  "FitterGA_BDTOptimize",
280  ranges, opt );
281  }
282 
283  fitter->CheckForUnusedOptions();
284 
285  // perform the fit
286  fitter->Run(pars);
287 
288  // clean up
289  for (UInt_t ipar=0; ipar<ranges.size(); ipar++) delete ranges[ipar];
290 
291  GetMethod()->Reset();
292 
293  fTunedParameters.clear();
294  Int_t jcount=0;
295  for (it=fTuneParameters.begin(); it!=fTuneParameters.end(); it++){
296  fTunedParameters.insert(std::pair<TString,Double_t>(it->first,pars[jcount++]));
297  }
298 
300 
301 }
302 
303 ////////////////////////////////////////////////////////////////////////////////
304 /// return the estimator (from current FOM) for the fitting interface
305 
307 {
308  std::map< std::vector<Double_t> , Double_t>::const_iterator iter;
309  iter = fAlreadyTrainedParCombination.find(pars);
310 
311  if (iter != fAlreadyTrainedParCombination.end()) {
312  // std::cout << "I had trained Depth=" <<Int_t(pars[0])
313  // <<" MinEv=" <<Int_t(pars[1])
314  // <<" already --> FOM="<< iter->second <<std::endl;
315  return iter->second;
316  }else{
317  std::map<TString,Double_t> currentParameters;
318  Int_t icount =0; // map "pars" to the map of Tuneparameter, make sure
319  // you never screw up this order!!
320  std::map<TString, TMVA::Interval*>::iterator it;
321  for (it=fTuneParameters.begin(); it!=fTuneParameters.end(); it++){
322  currentParameters[it->first] = pars[icount++];
323  }
324  GetMethod()->Reset();
325  GetMethod()->SetTuneParameters(currentParameters);
326  if(!GetMethod()->IsSilentFile()) GetMethod()->BaseDir()->cd();
327 
328  if (fNotDoneYet){
330  CalcTransformations(GetMethod()->Data()->GetEventCollection());
332  }
334  GetMethod()->Train();
336 
337 
338  Double_t currentFOM = GetFOM();
339 
340  fAlreadyTrainedParCombination.insert(std::make_pair(pars,-currentFOM));
341  return -currentFOM;
342  }
343 }
344 
345 ////////////////////////////////////////////////////////////////////////////////
346 /// Return the Figure of Merit (FOM) used in the parameter
347 /// optimization process
348 
350 {
351  Double_t fom=0;
352  if (fMethod->DoRegression()){
353  std::cout << " ERROR: Sorry, Regression is not yet implement for automatic parameter optimisation"
354  << " --> exit" << std::endl;
355  std::exit(1);
356  }else{
357  if (fFOMType == "Separation") fom = GetSeparation();
358  else if (fFOMType == "ROCIntegral") fom = GetROCIntegral();
359  else if (fFOMType == "SigEffAtBkgEff01") fom = GetSigEffAtBkgEff(0.1);
360  else if (fFOMType == "SigEffAtBkgEff001") fom = GetSigEffAtBkgEff(0.01);
361  else if (fFOMType == "SigEffAtBkgEff002") fom = GetSigEffAtBkgEff(0.02);
362  else if (fFOMType == "BkgRejAtSigEff05") fom = GetBkgRejAtSigEff(0.5);
363  else if (fFOMType == "BkgEffAtSigEff05") fom = GetBkgEffAtSigEff(0.5);
364  else {
365  Log()<<kFATAL << " ERROR, you've specified as Figure of Merit in the "
366  << " parameter optimisation " << fFOMType << " which has not"
367  << " been implemented yet!! ---> exit " << Endl;
368  }
369  }
370  fFOMvsIter.push_back(fom);
371  // std::cout << "fom="<<fom<<std::endl; // should write that into a debug log (as option)
372  return fom;
373 }
374 
375 ////////////////////////////////////////////////////////////////////////////////
376 /// fill the private histograms with the mva distributions for sig/bkg
377 
379 {
380  if (fMvaSig) fMvaSig->Delete();
381  if (fMvaBkg) fMvaBkg->Delete();
384 
385  // maybe later on this should be done a bit more clever (time consuming) by
386  // first determining proper ranges, removing outliers, as we do in the
387  // MVA output calculation in MethodBase::TestClassifier...
388  // --> then it might be possible also to use the splined PDF's which currently
389  // doesn't seem to work
390 
391  fMvaSig = new TH1D("fMvaSig","",100,-1.5,1.5); //used for spline fit
392  fMvaBkg = new TH1D("fMvaBkg","",100,-1.5,1.5); //used for spline fit
393  fMvaSigFineBin = new TH1D("fMvaSigFineBin","",100000,-1.5,1.5);
394  fMvaBkgFineBin = new TH1D("fMvaBkgFineBin","",100000,-1.5,1.5);
395 
396  const std::vector< Event*> events=fMethod->Data()->GetEventCollection(Types::kTesting);
397 
398  UInt_t signalClassNr = fMethod->DataInfo().GetClassInfo("Signal")->GetNumber();
399 
400  // fMethod->GetTransformationHandler().CalcTransformations(fMethod->Data()->GetEventCollection(Types::kTesting));
401 
402  for (UInt_t iev=0; iev < events.size() ; iev++){
403  // std::cout << " GetMVADists event " << iev << std::endl;
404  // std::cout << " Class = " << events[iev]->GetClass() << std::endl;
405  // std::cout << " MVA Value = " << fMethod->GetMvaValue(events[iev]) << std::endl;
406  if (events[iev]->GetClass() == signalClassNr) {
407  fMvaSig->Fill(fMethod->GetMvaValue(events[iev]),events[iev]->GetWeight());
408  fMvaSigFineBin->Fill(fMethod->GetMvaValue(events[iev]),events[iev]->GetWeight());
409  } else {
410  fMvaBkg->Fill(fMethod->GetMvaValue(events[iev]),events[iev]->GetWeight());
411  fMvaBkgFineBin->Fill(fMethod->GetMvaValue(events[iev]),events[iev]->GetWeight());
412  }
413  }
414 }
415 ////////////////////////////////////////////////////////////////////////////////
416 /// return the separation between the signal and background
417 /// MVA ouput distribution
418 
420 {
421  GetMVADists();
422  if (1){
423  PDF *splS = new PDF( " PDF Sig", fMvaSig, PDF::kSpline2 );
424  PDF *splB = new PDF( " PDF Bkg", fMvaBkg, PDF::kSpline2 );
425  return gTools().GetSeparation(*splS,*splB);
426  }else{
427  std::cout << "Separation calculation via histograms (not PDFs) seems to give still strange results!! Don't do that, check!!"<<std::endl;
428  return gTools().GetSeparation(fMvaSigFineBin,fMvaBkgFineBin); // somehow still gives strange results!!!! Check!!!
429  }
430 }
431 
432 ////////////////////////////////////////////////////////////////////////////////
433 /// calculate the area (integral) under the ROC curve as a
434 /// overall quality measure of the classification
435 ///
436 /// making pdfs out of the MVA-output distributions doesn't work
437 /// reliably for cases where the MVA-output isn't a smooth distribution.
438 /// this happens "frequently" in BDTs for example when the number of
439 /// trees is small resulting in only some discrete possible MVA output values.
440 /// (I still leave the code here, but use this with care!!! The default
441 /// however is to use the distributions!!!
442 
444 {
445  GetMVADists();
446 
447  Double_t integral = 0;
448  if (0){
449  PDF *pdfS = new PDF( " PDF Sig", fMvaSig, PDF::kSpline2 );
450  PDF *pdfB = new PDF( " PDF Bkg", fMvaBkg, PDF::kSpline2 );
451 
452  Double_t xmin = TMath::Min(pdfS->GetXmin(), pdfB->GetXmin());
453  Double_t xmax = TMath::Max(pdfS->GetXmax(), pdfB->GetXmax());
454 
455  UInt_t nsteps = 1000;
456  Double_t step = (xmax-xmin)/Double_t(nsteps);
457  Double_t cut = xmin;
458  for (UInt_t i=0; i<nsteps; i++){
459  integral += (1-pdfB->GetIntegral(cut,xmax)) * pdfS->GetVal(cut);
460  cut+=step;
461  }
462  integral*=step;
463  }else{
464  // sanity checks
467  std::cout << " Error in OptimizeConfigParameters GetROCIntegral, unequal histograms for sig and bkg.." << std::endl;
468  std::exit(1);
469  }else{
470 
471  Double_t *cumulator = fMvaBkgFineBin->GetIntegral();
473  // get the true signal integral (ComputeIntegral just return 1 as they
474  // automatically normalize. IN ADDITION, they do not account for variable
475  // bin sizes (which you might perhaps use later on for the fMvaSig/Bkg histograms)
476  Double_t sigIntegral = 0;
477  for (Int_t ibin=1; ibin<=nbins; ibin++){
478  sigIntegral += fMvaSigFineBin->GetBinContent(ibin) * fMvaSigFineBin->GetBinWidth(ibin);
479  }
480  //gTools().NormHist( fMvaSigFineBin ); // also doesn't use variable bin width. And calls TH1::Scale, which oddly enough does not change the SumOfWeights !!!
481 
482  for (Int_t ibin=1; ibin <= nbins; ibin++){ // don't include under- and overflow bin
483  integral += (cumulator[ibin]) * fMvaSigFineBin->GetBinContent(ibin)/sigIntegral * fMvaSigFineBin->GetBinWidth(ibin) ;
484  }
485  }
486  }
487 
488  return integral;
489 }
490 
491 ////////////////////////////////////////////////////////////////////////////////
492 /// calculate the signal efficiency for a given background efficiency
493 
495 {
496  GetMVADists();
497  Double_t sigEff=0;
498 
499  // sanity checks
502  std::cout << " Error in OptimizeConfigParameters GetSigEffAt, unequal histograms for sig and bkg.." << std::endl;
503  std::exit(1);
504  }else{
505  Double_t *bkgCumulator = fMvaBkgFineBin->GetIntegral();
506  Double_t *sigCumulator = fMvaSigFineBin->GetIntegral();
507 
509  Int_t ibin=0;
510 
511  // std::cout << " bkgIntegral="<<bkgIntegral
512  // << " sigIntegral="<<sigIntegral
513  // << " bkgCumulator[nbins]="<<bkgCumulator[nbins]
514  // << " sigCumulator[nbins]="<<sigCumulator[nbins]
515  // << std::endl;
516 
517  while (bkgCumulator[nbins-ibin] > (1-bkgEff)) {
518  sigEff = sigCumulator[nbins]-sigCumulator[nbins-ibin];
519  ibin++;
520  }
521  }
522  return sigEff;
523 }
524 
525 
526 ////////////////////////////////////////////////////////////////////////////////
527 /// calculate the background efficiency for a given signal efficiency
528 ///
529 /// adapted by marc-olivier.bettler@cern.ch
530 
532 {
533  GetMVADists();
534  Double_t bkgEff=0;
535 
536  // sanity checks
539  std::cout << " Error in OptimizeConfigParameters GetBkgEffAt, unequal histograms for sig and bkg.." << std::endl;
540  std::exit(1);
541  }else{
542 
543  Double_t *bkgCumulator = fMvaBkgFineBin->GetIntegral();
544  Double_t *sigCumulator = fMvaSigFineBin->GetIntegral();
545 
547  Int_t ibin=0;
548 
549  // std::cout << " bkgIntegral="<<bkgIntegral
550  // << " sigIntegral="<<sigIntegral
551  // << " bkgCumulator[nbins]="<<bkgCumulator[nbins]
552  // << " sigCumulator[nbins]="<<sigCumulator[nbins]
553  // << std::endl;
554 
555  while ( sigCumulator[nbins]-sigCumulator[nbins-ibin] < sigEff) {
556  bkgEff = bkgCumulator[nbins]-bkgCumulator[nbins-ibin];
557  ibin++;
558  }
559  }
560  return bkgEff;
561 }
562 
563 ////////////////////////////////////////////////////////////////////////////////
564 /// calculate the background rejection for a given signal efficiency
565 ///
566 /// adapted by marc-olivier.bettler@cern.ch
567 
569 {
570  GetMVADists();
571  Double_t bkgRej=0;
572 
573  // sanity checks
576  std::cout << " Error in OptimizeConfigParameters GetBkgEffAt, unequal histograms for sig and bkg.." << std::endl;
577  std::exit(1);
578  }else{
579 
580  Double_t *bkgCumulator = fMvaBkgFineBin->GetIntegral();
581  Double_t *sigCumulator = fMvaSigFineBin->GetIntegral();
582 
584  Int_t ibin=0;
585 
586  // std::cout << " bkgIntegral="<<bkgIntegral
587  // << " sigIntegral="<<sigIntegral
588  // << " bkgCumulator[nbins]="<<bkgCumulator[nbins]
589  // << " sigCumulator[nbins]="<<sigCumulator[nbins]
590  // << std::endl;
591 
592  while ( sigCumulator[nbins]-sigCumulator[nbins-ibin] < sigEff) {
593  bkgRej = bkgCumulator[nbins-ibin];
594  ibin++;
595  }
596  }
597  return bkgRej;
598 }
std::map< TString, Double_t > fTunedParameters
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition: TObject.cxx:778
std::string GetName(const std::string &scope_name)
Definition: Cppyy.cxx:145
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3126
virtual void SetTuneParameters(std::map< TString, Double_t > tuneParameters)
set the tuning parameters according to the argument This is just a dummy .
Definition: MethodBase.cxx:649
std::map< TString, TMVA::Interval * > fTuneParameters
float xmin
Definition: THbookFile.cxx:93
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:158
Base class for TMVA fitters.
Definition: FitterBase.h:51
Double_t Log(Double_t x)
Definition: TMath.h:649
virtual Double_t GetMvaValue(Double_t *errLower=0, Double_t *errUpper=0)=0
float Float_t
Definition: RtypesCore.h:53
float ymin
Definition: THbookFile.cxx:93
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:131
TH1 * h
Definition: legend2.C:5
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH1.cxx:4639
Virtual base Class for all MVA method.
Definition: MethodBase.h:106
Basic string class.
Definition: TString.h:129
Double_t GetSeparation()
return the separation between the signal and background MVA ouput distribution
TransformationHandler & GetTransformationHandler(Bool_t takeReroutedIfAvailable=true)
Definition: MethodBase.h:378
void optimizeScan()
do the actual optimization using a simple scan method, i.e.
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:168
int Int_t
Definition: RtypesCore.h:41
virtual void SetYTitle(const char *title)
Definition: TH1.h:390
int nbins[3]
const std::vector< Event * > & GetEventCollection(Types::ETreeType type=Types::kMaxTreeType) const
Definition: DataSet.h:225
STL namespace.
#define NULL
Definition: RtypesCore.h:88
Double_t GetFOM()
Return the Figure of Merit (FOM) used in the parameter optimization process.
static void SetIsTraining(Bool_t)
when this static function is called, it sets the flag whether events with negative event weight shoul...
Definition: Event.cxx:392
TClass * GetClass(T *)
Definition: TClass.h:545
Double_t GetXmin() const
Definition: TAxis.h:133
void GetMVADists()
fill the private histograms with the mva distributions for sig/bkg
/Fitter using MINUIT
Definition: MinuitFitter.h:47
Double_t x[n]
Definition: legend1.C:17
Double_t Run()
estimator function interface for fitting
Definition: FitterBase.cxx:74
DataSet * Data() const
Definition: MethodBase.h:393
std::vector< std::vector< double > > Data
DataSetInfo & DataInfo() const
Definition: MethodBase.h:394
Bool_t DoRegression() const
Definition: MethodBase.h:422
PDF wrapper for histograms; uses user-defined spline interpolation.
Definition: PDF.h:63
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:727
const std::vector< Event * > * CalcTransformations(const std::vector< Event *> &, Bool_t createNewVector=kFALSE)
computation of transformation
virtual void Delete(Option_t *option="")
Delete this object.
Definition: TObject.cxx:176
virtual Double_t * GetIntegral()
Return a pointer to the array of bins integral.
Definition: TH1.cxx:2403
float ymax
Definition: THbookFile.cxx:93
virtual void Train()=0
Double_t GetROCIntegral()
calculate the area (integral) under the ROC curve as a overall quality measure of the classification ...
SVector< double, 2 > v
Definition: Dict.h:5
const char * GetName() const
Definition: MethodBase.h:318
ClassInfo * GetClassInfo(Int_t clNum) const
std::map< TString, Double_t > optimize()
The TMVA::Interval Class.
Definition: Interval.h:61
virtual ~OptimizeConfigParameters()
the destructor (delete the OptimizeConfigParameters, store the graph and .. delete it) ...
unsigned int UInt_t
Definition: RtypesCore.h:42
Double_t GetSigEffAtBkgEff(Double_t bkgEff=0.1)
calculate the signal efficiency for a given background efficiency
double floor(double)
Double_t GetXmin() const
Definition: PDF.h:104
float xmax
Definition: THbookFile.cxx:93
Tools & gTools()
const Bool_t kFALSE
Definition: RtypesCore.h:92
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width for 1D histogram.
Definition: TH1.cxx:8275
#define ClassImp(name)
Definition: Rtypes.h:336
double Double_t
Definition: RtypesCore.h:55
Double_t GetXmax() const
Definition: PDF.h:105
Double_t y[n]
Definition: legend1.C:17
virtual void Reset()
Definition: MethodBase.h:184
Double_t GetBkgEffAtSigEff(Double_t sigEff=0.5)
calculate the background efficiency for a given signal efficiency
THist< 2, double, THistStatContent, THistStatUncertainty > TH2D
Definition: THist.hxx:316
UInt_t GetNumber() const
Definition: ClassInfo.h:65
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:59
Abstract ClassifierFactory template that handles arbitrary types.
virtual void SetXTitle(const char *title)
Definition: TH1.h:389
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
Definition: TDirectory.cxx:435
std::vector< int > GetScanIndices(int val, std::vector< int > base)
helper function to scan through the all the combinations in the parameter space
Double_t GetBkgRejAtSigEff(Double_t sigEff=0.5)
calculate the background rejection for a given signal efficiency
TDirectory * BaseDir() const
returns the ROOT directory where info/histograms etc of the corresponding MVA method instance are sto...
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:200
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:41
Double_t EstimatorFunction(std::vector< Double_t > &)
return the estimator (from current FOM) for the fitting interface
std::map< std::vector< Double_t >, Double_t > fAlreadyTrainedParCombination
THist< 1, double, THistStatContent, THistStatUncertainty > TH1D
Definition: THist.hxx:310
Double_t GetIntegral(Double_t xmin, Double_t xmax)
computes PDF integral within given ranges
Definition: PDF.cxx:657
virtual Int_t GetNbinsX() const
Definition: TH1.h:277
const Bool_t kTRUE
Definition: RtypesCore.h:91
Fitter using a Genetic Algorithm.
Definition: GeneticFitter.h:43
void CheckForUnusedOptions() const
checks for unused options in option string
const Int_t n
Definition: legend1.C:16
TAxis * GetXaxis()
Definition: TH1.h:300
Double_t GetVal(Double_t x) const
returns value PDF(x)
Definition: PDF.cxx:704
Double_t GetSeparation(TH1 *S, TH1 *B) const
compute "separation" defined as
Definition: Tools.cxx:133
tomato 2-D histogram with a double per channel (see TH1 documentation)}
Definition: TH2.h:290