Logo ROOT   6.12/07
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 #include "TMVA/Config.h"
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="FitStrategy=0:UseImprove=False:UseMinos=False:Tolerance=100";
266  if (!TMVA::gConfig().IsSilent() ) opt += TString(":PrintLevel=0");
267 
268  fitter = new MinuitFitter( *this,
269  "FitterMinuit_BDTOptimize",
270  ranges, opt );
271  }else if ( fOptimizationFitType == "FitGA" ) {
272  TString opt="PopSize=20:Steps=30:Cycles=3:ConvCrit=0.01:SaveBestCycle=5";
273  fitter = new GeneticFitter( *this,
274  "FitterGA_BDTOptimize",
275  ranges, opt );
276  } else {
277  Log() << kWARNING << " you did not specify a valid OptimizationFitType "
278  << " will use the default (FitGA) " << Endl;
279  TString opt="PopSize=20:Steps=30:Cycles=3:ConvCrit=0.01:SaveBestCycle=5";
280  fitter = new GeneticFitter( *this,
281  "FitterGA_BDTOptimize",
282  ranges, opt );
283  }
284 
285  fitter->CheckForUnusedOptions();
286 
287  // perform the fit
288  fitter->Run(pars);
289 
290  // clean up
291  for (UInt_t ipar=0; ipar<ranges.size(); ipar++) delete ranges[ipar];
292 
293  GetMethod()->Reset();
294 
295  fTunedParameters.clear();
296  Int_t jcount=0;
297  for (it=fTuneParameters.begin(); it!=fTuneParameters.end(); it++){
298  fTunedParameters.insert(std::pair<TString,Double_t>(it->first,pars[jcount++]));
299  }
300 
302 
303 }
304 
305 ////////////////////////////////////////////////////////////////////////////////
306 /// return the estimator (from current FOM) for the fitting interface
307 
309 {
310  std::map< std::vector<Double_t> , Double_t>::const_iterator iter;
311  iter = fAlreadyTrainedParCombination.find(pars);
312 
313  if (iter != fAlreadyTrainedParCombination.end()) {
314  // std::cout << "I had trained Depth=" <<Int_t(pars[0])
315  // <<" MinEv=" <<Int_t(pars[1])
316  // <<" already --> FOM="<< iter->second <<std::endl;
317  return iter->second;
318  }else{
319  std::map<TString,Double_t> currentParameters;
320  Int_t icount =0; // map "pars" to the map of Tuneparameter, make sure
321  // you never screw up this order!!
322  std::map<TString, TMVA::Interval*>::iterator it;
323  for (it=fTuneParameters.begin(); it!=fTuneParameters.end(); it++){
324  currentParameters[it->first] = pars[icount++];
325  }
326  GetMethod()->Reset();
327  GetMethod()->SetTuneParameters(currentParameters);
328  if(!GetMethod()->IsSilentFile()) GetMethod()->BaseDir()->cd();
329 
330  if (fNotDoneYet){
332  CalcTransformations(GetMethod()->Data()->GetEventCollection());
334  }
336  GetMethod()->Train();
338 
339 
340  Double_t currentFOM = GetFOM();
341 
342  fAlreadyTrainedParCombination.insert(std::make_pair(pars,-currentFOM));
343  return -currentFOM;
344  }
345 }
346 
347 ////////////////////////////////////////////////////////////////////////////////
348 /// Return the Figure of Merit (FOM) used in the parameter
349 /// optimization process
350 
352 {
353  Double_t fom=0;
354  if (fMethod->DoRegression()){
355  std::cout << " ERROR: Sorry, Regression is not yet implement for automatic parameter optimisation"
356  << " --> exit" << std::endl;
357  std::exit(1);
358  }else{
359  if (fFOMType == "Separation") fom = GetSeparation();
360  else if (fFOMType == "ROCIntegral") fom = GetROCIntegral();
361  else if (fFOMType == "SigEffAtBkgEff01") fom = GetSigEffAtBkgEff(0.1);
362  else if (fFOMType == "SigEffAtBkgEff001") fom = GetSigEffAtBkgEff(0.01);
363  else if (fFOMType == "SigEffAtBkgEff002") fom = GetSigEffAtBkgEff(0.02);
364  else if (fFOMType == "BkgRejAtSigEff05") fom = GetBkgRejAtSigEff(0.5);
365  else if (fFOMType == "BkgEffAtSigEff05") fom = GetBkgEffAtSigEff(0.5);
366  else {
367  Log()<<kFATAL << " ERROR, you've specified as Figure of Merit in the "
368  << " parameter optimisation " << fFOMType << " which has not"
369  << " been implemented yet!! ---> exit " << Endl;
370  }
371  }
372  fFOMvsIter.push_back(fom);
373  // std::cout << "fom="<<fom<<std::endl; // should write that into a debug log (as option)
374  return fom;
375 }
376 
377 ////////////////////////////////////////////////////////////////////////////////
378 /// fill the private histograms with the mva distributions for sig/bkg
379 
381 {
382  if (fMvaSig) fMvaSig->Delete();
383  if (fMvaBkg) fMvaBkg->Delete();
386 
387  // maybe later on this should be done a bit more clever (time consuming) by
388  // first determining proper ranges, removing outliers, as we do in the
389  // MVA output calculation in MethodBase::TestClassifier...
390  // --> then it might be possible also to use the splined PDF's which currently
391  // doesn't seem to work
392 
393  fMvaSig = new TH1D("fMvaSig","",100,-1.5,1.5); //used for spline fit
394  fMvaBkg = new TH1D("fMvaBkg","",100,-1.5,1.5); //used for spline fit
395  fMvaSigFineBin = new TH1D("fMvaSigFineBin","",100000,-1.5,1.5);
396  fMvaBkgFineBin = new TH1D("fMvaBkgFineBin","",100000,-1.5,1.5);
397 
398  const std::vector< Event*> events=fMethod->Data()->GetEventCollection(Types::kTesting);
399 
400  UInt_t signalClassNr = fMethod->DataInfo().GetClassInfo("Signal")->GetNumber();
401 
402  // fMethod->GetTransformationHandler().CalcTransformations(fMethod->Data()->GetEventCollection(Types::kTesting));
403 
404  for (UInt_t iev=0; iev < events.size() ; iev++){
405  // std::cout << " GetMVADists event " << iev << std::endl;
406  // std::cout << " Class = " << events[iev]->GetClass() << std::endl;
407  // std::cout << " MVA Value = " << fMethod->GetMvaValue(events[iev]) << std::endl;
408  if (events[iev]->GetClass() == signalClassNr) {
409  fMvaSig->Fill(fMethod->GetMvaValue(events[iev]),events[iev]->GetWeight());
410  fMvaSigFineBin->Fill(fMethod->GetMvaValue(events[iev]),events[iev]->GetWeight());
411  } else {
412  fMvaBkg->Fill(fMethod->GetMvaValue(events[iev]),events[iev]->GetWeight());
413  fMvaBkgFineBin->Fill(fMethod->GetMvaValue(events[iev]),events[iev]->GetWeight());
414  }
415  }
416 }
417 ////////////////////////////////////////////////////////////////////////////////
418 /// return the separation between the signal and background
419 /// MVA ouput distribution
420 
422 {
423  GetMVADists();
424  if (1){
425  PDF *splS = new PDF( " PDF Sig", fMvaSig, PDF::kSpline2 );
426  PDF *splB = new PDF( " PDF Bkg", fMvaBkg, PDF::kSpline2 );
427  return gTools().GetSeparation(*splS,*splB);
428  }else{
429  std::cout << "Separation calculation via histograms (not PDFs) seems to give still strange results!! Don't do that, check!!"<<std::endl;
430  return gTools().GetSeparation(fMvaSigFineBin,fMvaBkgFineBin); // somehow still gives strange results!!!! Check!!!
431  }
432 }
433 
434 ////////////////////////////////////////////////////////////////////////////////
435 /// calculate the area (integral) under the ROC curve as a
436 /// overall quality measure of the classification
437 ///
438 /// making pdfs out of the MVA-output distributions doesn't work
439 /// reliably for cases where the MVA-output isn't a smooth distribution.
440 /// this happens "frequently" in BDTs for example when the number of
441 /// trees is small resulting in only some discrete possible MVA output values.
442 /// (I still leave the code here, but use this with care!!! The default
443 /// however is to use the distributions!!!
444 
446 {
447  GetMVADists();
448 
449  Double_t integral = 0;
450  if (0){
451  PDF *pdfS = new PDF( " PDF Sig", fMvaSig, PDF::kSpline2 );
452  PDF *pdfB = new PDF( " PDF Bkg", fMvaBkg, PDF::kSpline2 );
453 
454  Double_t xmin = TMath::Min(pdfS->GetXmin(), pdfB->GetXmin());
455  Double_t xmax = TMath::Max(pdfS->GetXmax(), pdfB->GetXmax());
456 
457  UInt_t nsteps = 1000;
458  Double_t step = (xmax-xmin)/Double_t(nsteps);
459  Double_t cut = xmin;
460  for (UInt_t i=0; i<nsteps; i++){
461  integral += (1-pdfB->GetIntegral(cut,xmax)) * pdfS->GetVal(cut);
462  cut+=step;
463  }
464  integral*=step;
465  }else{
466  // sanity checks
469  std::cout << " Error in OptimizeConfigParameters GetROCIntegral, unequal histograms for sig and bkg.." << std::endl;
470  std::exit(1);
471  }else{
472 
473  Double_t *cumulator = fMvaBkgFineBin->GetIntegral();
474  Int_t nbins = fMvaSigFineBin->GetNbinsX();
475  // get the true signal integral (ComputeIntegral just return 1 as they
476  // automatically normalize. IN ADDITION, they do not account for variable
477  // bin sizes (which you might perhaps use later on for the fMvaSig/Bkg histograms)
478  Double_t sigIntegral = 0;
479  for (Int_t ibin=1; ibin<=nbins; ibin++){
480  sigIntegral += fMvaSigFineBin->GetBinContent(ibin) * fMvaSigFineBin->GetBinWidth(ibin);
481  }
482  //gTools().NormHist( fMvaSigFineBin ); // also doesn't use variable bin width. And calls TH1::Scale, which oddly enough does not change the SumOfWeights !!!
483 
484  for (Int_t ibin=1; ibin <= nbins; ibin++){ // don't include under- and overflow bin
485  integral += (cumulator[ibin]) * fMvaSigFineBin->GetBinContent(ibin)/sigIntegral * fMvaSigFineBin->GetBinWidth(ibin) ;
486  }
487  }
488  }
489 
490  return integral;
491 }
492 
493 ////////////////////////////////////////////////////////////////////////////////
494 /// calculate the signal efficiency for a given background efficiency
495 
497 {
498  GetMVADists();
499  Double_t sigEff=0;
500 
501  // sanity checks
504  std::cout << " Error in OptimizeConfigParameters GetSigEffAt, unequal histograms for sig and bkg.." << std::endl;
505  std::exit(1);
506  }else{
507  Double_t *bkgCumulator = fMvaBkgFineBin->GetIntegral();
508  Double_t *sigCumulator = fMvaSigFineBin->GetIntegral();
509 
510  Int_t nbins=fMvaBkgFineBin->GetNbinsX();
511  Int_t ibin=0;
512 
513  // std::cout << " bkgIntegral="<<bkgIntegral
514  // << " sigIntegral="<<sigIntegral
515  // << " bkgCumulator[nbins]="<<bkgCumulator[nbins]
516  // << " sigCumulator[nbins]="<<sigCumulator[nbins]
517  // << std::endl;
518 
519  while (bkgCumulator[nbins-ibin] > (1-bkgEff)) {
520  sigEff = sigCumulator[nbins]-sigCumulator[nbins-ibin];
521  ibin++;
522  }
523  }
524  return sigEff;
525 }
526 
527 
528 ////////////////////////////////////////////////////////////////////////////////
529 /// calculate the background efficiency for a given signal efficiency
530 ///
531 /// adapted by marc-olivier.bettler@cern.ch
532 
534 {
535  GetMVADists();
536  Double_t bkgEff=0;
537 
538  // sanity checks
541  std::cout << " Error in OptimizeConfigParameters GetBkgEffAt, unequal histograms for sig and bkg.." << std::endl;
542  std::exit(1);
543  }else{
544 
545  Double_t *bkgCumulator = fMvaBkgFineBin->GetIntegral();
546  Double_t *sigCumulator = fMvaSigFineBin->GetIntegral();
547 
548  Int_t nbins=fMvaBkgFineBin->GetNbinsX();
549  Int_t ibin=0;
550 
551  // std::cout << " bkgIntegral="<<bkgIntegral
552  // << " sigIntegral="<<sigIntegral
553  // << " bkgCumulator[nbins]="<<bkgCumulator[nbins]
554  // << " sigCumulator[nbins]="<<sigCumulator[nbins]
555  // << std::endl;
556 
557  while ( sigCumulator[nbins]-sigCumulator[nbins-ibin] < sigEff) {
558  bkgEff = bkgCumulator[nbins]-bkgCumulator[nbins-ibin];
559  ibin++;
560  }
561  }
562  return bkgEff;
563 }
564 
565 ////////////////////////////////////////////////////////////////////////////////
566 /// calculate the background rejection for a given signal efficiency
567 ///
568 /// adapted by marc-olivier.bettler@cern.ch
569 
571 {
572  GetMVADists();
573  Double_t bkgRej=0;
574 
575  // sanity checks
578  std::cout << " Error in OptimizeConfigParameters GetBkgEffAt, unequal histograms for sig and bkg.." << std::endl;
579  std::exit(1);
580  }else{
581 
582  Double_t *bkgCumulator = fMvaBkgFineBin->GetIntegral();
583  Double_t *sigCumulator = fMvaSigFineBin->GetIntegral();
584 
585  Int_t nbins=fMvaBkgFineBin->GetNbinsX();
586  Int_t ibin=0;
587 
588  // std::cout << " bkgIntegral="<<bkgIntegral
589  // << " sigIntegral="<<sigIntegral
590  // << " bkgCumulator[nbins]="<<bkgCumulator[nbins]
591  // << " sigCumulator[nbins]="<<sigCumulator[nbins]
592  // << std::endl;
593 
594  while ( sigCumulator[nbins]-sigCumulator[nbins-ibin] < sigEff) {
595  bkgRej = bkgCumulator[nbins-ibin];
596  ibin++;
597  }
598  }
599  return bkgRej;
600 }
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:785
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:3244
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
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:140
Config & gConfig()
TH1 * h
Definition: legend2.C:5
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH1.cxx:4763
Virtual base Class for all MVA method.
Definition: MethodBase.h:109
Basic string class.
Definition: TString.h:125
Double_t GetSeparation()
return the separation between the signal and background MVA ouput distribution
TransformationHandler & GetTransformationHandler(Bool_t takeReroutedIfAvailable=true)
Definition: MethodBase.h:383
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:406
const std::vector< Event * > & GetEventCollection(Types::ETreeType type=Types::kMaxTreeType) const
Definition: DataSet.h:225
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:577
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:398
DataSetInfo & DataInfo() const
Definition: MethodBase.h:399
Bool_t DoRegression() const
Definition: MethodBase.h:427
PDF wrapper for histograms; uses user-defined spline interpolation.
Definition: PDF.h:63
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:169
virtual Double_t * GetIntegral()
Return a pointer to the array of bins integral.
Definition: TH1.cxx:2520
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:323
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:88
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width for 1D histogram.
Definition: TH1.cxx:8419
#define ClassImp(name)
Definition: Rtypes.h:359
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:189
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:290
UInt_t GetNumber() const
Definition: ClassInfo.h:65
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:59
virtual void SetXTitle(const char *title)
Definition: TH1.h:405
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
Definition: TDirectory.cxx:497
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:284
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:291
const Bool_t kTRUE
Definition: RtypesCore.h:87
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
OptimizeConfigParameters(MethodBase *const method, std::map< TString, TMVA::Interval *> tuneParameters, TString fomType="Separation", TString optimizationType="GA")
Constructor which sets either "Classification or Regression".
char name[80]
Definition: TGX11.cxx:109
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:315
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
2-D histogram with a double per channel (see TH1 documentation)}
Definition: TH2.h:290