Logo ROOT   6.08/07
Reference Guide
TransformationHandler.cxx
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss, Eckhard von Toerne, Jan Therhaag
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : TransformationHandler *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Implementation (see header for description) *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Peter Speckmayer <speckmay@mail.cern.ch> - CERN, Switzerland *
16  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
17  * Jan Therhaag <Jan.Therhaag@cern.ch> - U of Bonn, Germany *
18  * Eckhard v. Toerne <evt@uni-bonn.de> - U of Bonn, Germany *
19  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
20  * *
21  * Copyright (c) 2005-2011: *
22  * CERN, Switzerland *
23  * MPI-K Heidelberg, Germany *
24  * U. of Bonn, Germany *
25  * *
26  * Redistribution and use in source and binary forms, with or without *
27  * modification, are permitted according to the terms listed in LICENSE *
28  * (http://tmva.sourceforge.net/LICENSE) *
29  **********************************************************************************/
30 
32 
33 #include "TMVA/Config.h"
34 #include "TMVA/DataSet.h"
35 #include "TMVA/DataSetInfo.h"
36 #include "TMVA/Event.h"
37 #include "TMVA/MsgLogger.h"
38 #include "TMVA/Ranking.h"
39 #include "TMVA/Tools.h"
40 #include "TMVA/Types.h"
43 #include "TMVA/VariableInfo.h"
49 
50 #include "TAxis.h"
51 #include "TDirectory.h"
52 #include "TH1.h"
53 #include "TH2.h"
54 #include "TList.h"
55 #include "TMath.h"
56 #include "TProfile.h"
57 
58 #include <vector>
59 #include <iomanip>
60 
61 ////////////////////////////////////////////////////////////////////////////////
62 /// constructor
63 
65  : fDataSetInfo(dsi),
66  fRootBaseDir(0),
67  fCallerName (callerName),
68  fLogger ( new MsgLogger(TString("TFHandler_" + callerName).Data(), kINFO) )
69 {
70  // produce one entry for each class and one entry for all classes. If there is only one class,
71  // produce only one entry
72  fNumC = (dsi.GetNClasses()<= 1) ? 1 : dsi.GetNClasses()+1;
73 
74  fVariableStats.resize( fNumC );
75  for (Int_t i=0; i<fNumC; i++ ) fVariableStats.at(i).resize(dsi.GetNVariables() + dsi.GetNTargets());
76 }
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 /// destructor
80 
82 {
83  std::vector<Ranking*>::const_iterator it = fRanking.begin();
84  for (; it != fRanking.end(); it++) delete *it;
85 
87  delete fLogger;
88 }
89 
90 ////////////////////////////////////////////////////////////////////////////////
91 
93 {
94  fCallerName = name;
95  fLogger->SetSource( TString("TFHandler_" + fCallerName).Data() );
96 }
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 
101 {
102  TString tfname = trf->Log().GetName();
103  trf->Log().SetSource(TString(fCallerName+"_"+tfname+"_TF").Data());
104  fTransformations.Add(trf);
105  fTransformationsReferenceClasses.push_back( cls );
106  return trf;
107 }
108 
109 ////////////////////////////////////////////////////////////////////////////////
110 
112 {
113  if (rms <= 0) {
114  Log() << kWARNING << "Variable \"" << Variable(ivar).GetExpression()
115  << "\" has zero or negative RMS^2 "
116  << "==> set to zero. Please check the variable content" << Endl;
117  rms = 0;
118  }
119 
120  VariableStat stat; stat.fMean = mean; stat.fRMS = rms; stat.fMin = min; stat.fMax = max;
121  fVariableStats.at(k).at(ivar) = stat;
122 }
123 
124 ////////////////////////////////////////////////////////////////////////////////
125 /// overrides the setting for all classes! (this is put in basically for the likelihood-method)
126 /// be careful with the usage this method
127 
129 {
130  for (UInt_t i = 0; i < fTransformationsReferenceClasses.size(); i++) {
131  fTransformationsReferenceClasses.at( i ) = cls;
132  }
133 }
134 
135 ////////////////////////////////////////////////////////////////////////////////
136 /// the transformation
137 
139 {
141  std::vector<Int_t>::const_iterator rClsIt = fTransformationsReferenceClasses.begin();
142  const Event* trEv = ev;
143  while (VariableTransformBase *trf = (VariableTransformBase*) trIt()) {
144  if (rClsIt == fTransformationsReferenceClasses.end()) Log() << kFATAL<< "invalid read in TransformationHandler::Transform " <<Endl;
145  trEv = trf->Transform(trEv, (*rClsIt) );
146  rClsIt++;
147  }
148  return trEv;
149 }
150 
151 ////////////////////////////////////////////////////////////////////////////////
152 
153 const TMVA::Event* TMVA::TransformationHandler::InverseTransform( const Event* ev, Bool_t suppressIfNoTargets ) const
154 {
156  //Log() << kWARNING << __FILE__ <<":InverseTransform fTransformationsReferenceClasses is empty" << Endl;
157  return ev;
158  }
159  // the inverse transformation
161  std::vector< Int_t >::const_iterator rClsIt = fTransformationsReferenceClasses.end();
162  rClsIt--;
163  const Event* trEv = ev;
164  UInt_t nvars = 0, ntgts = 0, nspcts = 0;
165  while (VariableTransformBase *trf = (VariableTransformBase*) trIt() ) { // shouldn't be the transformation called in the inverse order for the inversetransformation?????
166  if (trf->IsCreated()) {
167  trf->CountVariableTypes( nvars, ntgts, nspcts );
168  if( !(suppressIfNoTargets && ntgts==0) )
169  trEv = trf->InverseTransform(ev, (*rClsIt) );
170  }
171  else break;
172  --rClsIt;
173  }
174  return trEv;
175 
176 
177  // TListIter trIt(&fTransformations);
178  // std::vector< Int_t >::const_iterator rClsIt = fTransformationsReferenceClasses.begin();
179  // const Event* trEv = ev;
180  // UInt_t nvars = 0, ntgts = 0, nspcts = 0;
181  // while (VariableTransformBase *trf = (VariableTransformBase*) trIt() ) { // shouldn't be the transformation called in the inverse order for the inversetransformation?????
182  // if (trf->IsCreated()) {
183  // trf->CountVariableTypes( nvars, ntgts, nspcts );
184  // if( !(suppressIfNoTargets && ntgts==0) )
185  // trEv = trf->InverseTransform(ev, (*rClsIt) );
186  // }
187  // else break;
188  // rClsIt++;
189  // }
190  // return trEv;
191 
192 }
193 
194 ////////////////////////////////////////////////////////////////////////////////
195 /// computation of transformation
196 
197 const std::vector<TMVA::Event*>* TMVA::TransformationHandler::CalcTransformations( const std::vector<Event*>& events,
198  Bool_t createNewVector )
199 {
200  if (fTransformations.GetEntries() <= 0)
201  return &events;
202 
203  // the transformedEvents are initialised with the initial events and then
204  // subsequently replaced with transformed ones. The n-th transformation will
205  // and on the events as they look like after the (n-1)-the transformation
206  // as intended for the chained transfromations
207  std::vector<Event*> *transformedEvents = new std::vector<TMVA::Event*>(events.size());
208  for ( UInt_t ievt = 0; ievt<events.size(); ievt++)
209  transformedEvents->at(ievt) = new Event(*events.at(ievt));
210 
212  std::vector< Int_t >::iterator rClsIt = fTransformationsReferenceClasses.begin();
213  while (VariableTransformBase *trf = (VariableTransformBase*) trIt()) {
214  if (trf->PrepareTransformation(*transformedEvents)) {
215  for (UInt_t ievt = 0; ievt<transformedEvents->size(); ievt++) { // loop through all events
216  *(*transformedEvents)[ievt] = *trf->Transform((*transformedEvents)[ievt],(*rClsIt));
217  }
218  rClsIt++;
219  }
220  }
221 
222  CalcStats(*transformedEvents);
223 
224  // plot the variables once in this transformation
225  PlotVariables(*transformedEvents);
226 
227  //sometimes, the actual transformed event vector is not used for anything but the previous
228  //CalcStat and PlotVariables calles, in that case, we delete it again (and return NULL)
229  if (!createNewVector) { // if we don't want that newly created event vector to persist, then delete it
230  for ( UInt_t ievt = 0; ievt<transformedEvents->size(); ievt++)
231  delete (*transformedEvents)[ievt];
232  delete transformedEvents;
233  transformedEvents=NULL;
234  }
235 
236  return transformedEvents; // give back the newly created event collection (containing the transformed events)
237 }
238 
239 ////////////////////////////////////////////////////////////////////////////////
240 
241 void TMVA::TransformationHandler::CalcStats (const std::vector<Event*>& events )
242 {
243  // method to calculate minimum, maximum, mean, and RMS for all
244  // variables used in the MVA
245 
246  UInt_t nevts = events.size();
247 
248  if (nevts==0)
249  Log() << kFATAL << "No events available to find min, max, mean and rms" << Endl;
250 
251  // if transformation has not been succeeded, the tree may be empty
252  const UInt_t nvar = events[0]->GetNVariables();
253  const UInt_t ntgt = events[0]->GetNTargets();
254 
255  Double_t *sumOfWeights = new Double_t[fNumC];
256  Double_t* *x2 = new Double_t*[fNumC];
257  Double_t* *x0 = new Double_t*[fNumC];
258  Double_t* *varMin = new Double_t*[fNumC];
259  Double_t* *varMax = new Double_t*[fNumC];
260 
261  for (Int_t cls=0; cls<fNumC; cls++) {
262  sumOfWeights[cls]=0;
263  x2[cls] = new Double_t[nvar+ntgt];
264  x0[cls] = new Double_t[nvar+ntgt];
265  varMin[cls] = new Double_t[nvar+ntgt];
266  varMax[cls] = new Double_t[nvar+ntgt];
267  for (UInt_t ivar=0; ivar<nvar+ntgt; ivar++) {
268  x0[cls][ivar] = x2[cls][ivar] = 0;
269  varMin[cls][ivar] = DBL_MAX;
270  varMax[cls][ivar] = -DBL_MAX;
271  }
272  }
273 
274  for (UInt_t ievt=0; ievt<nevts; ievt++) {
275  const Event* ev = events[ievt];
276  Int_t cls = ev->GetClass();
277 
278  Double_t weight = ev->GetWeight();
279  sumOfWeights[cls] += weight;
280  if (fNumC > 1 ) sumOfWeights[fNumC-1] += weight; // if more than one class, store values for all classes
281  for (UInt_t var_tgt = 0; var_tgt < 2; var_tgt++ ){ // first for variables, then for targets
282  UInt_t nloop = ( var_tgt==0?nvar:ntgt );
283  for (UInt_t ivar=0; ivar<nloop; ivar++) {
284  Double_t x = ( var_tgt==0?ev->GetValue(ivar):ev->GetTarget(ivar) );
285 
286  if (x < varMin[cls][(var_tgt*nvar)+ivar]) varMin[cls][(var_tgt*nvar)+ivar]= x;
287  if (x > varMax[cls][(var_tgt*nvar)+ivar]) varMax[cls][(var_tgt*nvar)+ivar]= x;
288 
289  x0[cls][(var_tgt*nvar)+ivar] += x*weight;
290  x2[cls][(var_tgt*nvar)+ivar] += x*x*weight;
291 
292  if (fNumC > 1) {
293  if (x < varMin[fNumC-1][(var_tgt*nvar)+ivar]) varMin[fNumC-1][(var_tgt*nvar)+ivar]= x;
294  if (x > varMax[fNumC-1][(var_tgt*nvar)+ivar]) varMax[fNumC-1][(var_tgt*nvar)+ivar]= x;
295 
296  x0[fNumC-1][(var_tgt*nvar)+ivar] += x*weight;
297  x2[fNumC-1][(var_tgt*nvar)+ivar] += x*x*weight;
298  }
299  }
300  }
301  }
302 
303 
304  // set Mean and RMS
305  for (UInt_t var_tgt = 0; var_tgt < 2; var_tgt++ ){ // first for variables, then for targets
306  UInt_t nloop = ( var_tgt==0?nvar:ntgt );
307  for (UInt_t ivar=0; ivar<nloop; ivar++) {
308  for (Int_t cls = 0; cls < fNumC; cls++) {
309  Double_t mean = x0[cls][(var_tgt*nvar)+ivar]/sumOfWeights[cls];
310  Double_t rms = TMath::Sqrt( x2[cls][(var_tgt*nvar)+ivar]/sumOfWeights[cls] - mean*mean);
311  AddStats(cls, (var_tgt*nvar)+ivar, mean, rms, varMin[cls][(var_tgt*nvar)+ivar], varMax[cls][(var_tgt*nvar)+ivar]);
312  }
313  }
314  }
315 
316  // ------ pretty output of basic statistics -------------------------------
317  // find maximum length in V (and column title)
318  UInt_t maxL = 8, maxV = 0;
319  std::vector<UInt_t> vLengths;
320  for (UInt_t ivar=0; ivar<nvar+ntgt; ivar++) {
321  if( ivar < nvar )
322  maxL = TMath::Max( (UInt_t)Variable(ivar).GetLabel().Length(), maxL );
323  else
324  maxL = TMath::Max( (UInt_t)Target(ivar-nvar).GetLabel().Length(), maxL );
325  }
326  maxV = maxL + 2;
327  // full column length
328  UInt_t clen = maxL + 4*maxV + 11;
329  Log() << kHEADER ;
330  //for (UInt_t i=0; i<clen; i++) //Log() << "-";
331 
332  //Log() << Endl;
333  // full column length
334  Log() << std::setw(maxL) << "Variable";
335  Log() << " " << std::setw(maxV) << "Mean";
336  Log() << " " << std::setw(maxV) << "RMS";
337  Log() << " " << std::setw(maxV) << "[ Min ";
338  Log() << " " << std::setw(maxV) << " Max ]"<< Endl;;
339  for (UInt_t i=0; i<clen; i++) Log() << "-";
340  Log() << Endl;
341 
342  // the numbers
343  TString format = "%#11.5g";
344  for (UInt_t ivar=0; ivar<nvar+ntgt; ivar++) {
345  if( ivar < nvar )
346  Log() << std::setw(maxL) << Variable(ivar).GetLabel() << ":";
347  else
348  Log() << std::setw(maxL) << Target(ivar-nvar).GetLabel() << ":";
349  Log() << std::setw(maxV) << Form( format.Data(), GetMean(ivar) );
350  Log() << std::setw(maxV) << Form( format.Data(), GetRMS(ivar) );
351  Log() << " [" << std::setw(maxV) << Form( format.Data(), GetMin(ivar) );
352  Log() << std::setw(maxV) << Form( format.Data(), GetMax(ivar) ) << " ]";
353  Log() << Endl;
354  }
355  for (UInt_t i=0; i<clen; i++) Log() << "-";
356  Log() << Endl;
357  // ------------------------------------------------------------------------
358 
359  delete[] sumOfWeights;
360  for (Int_t cls=0; cls<fNumC; cls++) {
361  delete [] x2[cls];
362  delete [] x0[cls];
363  delete [] varMin[cls];
364  delete [] varMax[cls];
365  }
366  delete [] x2;
367  delete [] x0;
368  delete [] varMin;
369  delete [] varMax;
370 }
371 
372 ////////////////////////////////////////////////////////////////////////////////
373 /// create transformation function
374 
375 void TMVA::TransformationHandler::MakeFunction( std::ostream& fout, const TString& fncName, Int_t part ) const
376 {
378  std::vector< Int_t >::const_iterator rClsIt = fTransformationsReferenceClasses.begin();
379  UInt_t trCounter=1;
380  while (VariableTransformBase *trf = (VariableTransformBase*) trIt() ) {
381  trf->MakeFunction(fout, fncName, part, trCounter++, (*rClsIt) );
382  rClsIt++;
383  }
384  if (part==1) {
385  for (Int_t i=0; i<fTransformations.GetSize(); i++) {
386  fout << " void InitTransform_"<<i+1<<"();" << std::endl;
387  fout << " void Transform_"<<i+1<<"( std::vector<double> & iv, int sigOrBgd ) const;" << std::endl;
388  }
389  }
390  if (part==2) {
391  fout << std::endl;
392  fout << "//_______________________________________________________________________" << std::endl;
393  fout << "inline void " << fncName << "::InitTransform()" << std::endl;
394  fout << "{" << std::endl;
395  for (Int_t i=0; i<fTransformations.GetSize(); i++)
396  fout << " InitTransform_"<<i+1<<"();" << std::endl;
397  fout << "}" << std::endl;
398  fout << std::endl;
399  fout << "//_______________________________________________________________________" << std::endl;
400  fout << "inline void " << fncName << "::Transform( std::vector<double>& iv, int sigOrBgd ) const" << std::endl;
401  fout << "{" << std::endl;
402  for (Int_t i=0; i<fTransformations.GetSize(); i++)
403  fout << " Transform_"<<i+1<<"( iv, sigOrBgd );" << std::endl;
404 
405  fout << "}" << std::endl;
406  }
407 }
408 
409 ////////////////////////////////////////////////////////////////////////////////
410 /// return transformation name
411 
413 {
414  TString name("Id");
417  if ((trf = (VariableTransformBase*) trIt())) {
418  name = TString(trf->GetShortName());
419  while ((trf = (VariableTransformBase*) trIt())) name += "_" + TString(trf->GetShortName());
420  }
421  return name;
422 }
423 
424 ////////////////////////////////////////////////////////////////////////////////
425 /// incorporates transformation type into title axis (usually for histograms)
426 
428 {
429  TString xtit = info.GetTitle();
430  // indicate transformation, but not in case of single identity transform
431  if (fTransformations.GetSize() >= 1) {
432  if (fTransformations.GetSize() > 1 ||
433  ((VariableTransformBase*)GetTransformationList().Last())->GetVariableTransform() != Types::kIdentity) {
434  xtit += " (" + GetName() + ")";
435  }
436  }
437  return xtit;
438 }
439 
440 
441 ////////////////////////////////////////////////////////////////////////////////
442 /// create histograms from the input variables
443 /// - histograms for all input variables
444 /// - scatter plots for all pairs of input variables
445 
446 void TMVA::TransformationHandler::PlotVariables (const std::vector<Event*>& events, TDirectory* theDirectory )
447 {
448  if (fRootBaseDir==0 && theDirectory == 0) return;
449 
450  Log() << kDEBUG << "Plot event variables for ";
451  if (theDirectory !=0) Log()<< TString(theDirectory->GetName()) << Endl;
452  else Log() << GetName() << Endl;
453 
454  // extension for transformation type
455  TString transfType = "";
456  if (theDirectory == 0) {
457  transfType += "_";
458  transfType += GetName();
459  }else{ // you plot for the individual classifiers. Note, here the "statistics" still need to be calculated as you are in the testing phase
460  CalcStats(events);
461  }
462 
463  const UInt_t nvar = fDataSetInfo.GetNVariables();
464  const UInt_t ntgt = fDataSetInfo.GetNTargets();
465  const Int_t ncls = fDataSetInfo.GetNClasses();
466 
467  // Create all histograms
468  // do both, scatter and profile plots
469  std::vector<std::vector<TH1*> > hVars( ncls ); // histograms for variables
470  std::vector<std::vector<std::vector<TH2F*> > > mycorr( ncls ); // histograms for correlations
471  std::vector<std::vector<std::vector<TProfile*> > > myprof( ncls ); // histograms for profiles
472 
473  for (Int_t cls = 0; cls < ncls; cls++) {
474  hVars.at(cls).resize ( nvar+ntgt );
475  hVars.at(cls).assign ( nvar+ntgt, 0 ); // fill with zeros
476  mycorr.at(cls).resize( nvar+ntgt );
477  myprof.at(cls).resize( nvar+ntgt );
478  for (UInt_t ivar=0; ivar < nvar+ntgt; ivar++) {
479  mycorr.at(cls).at(ivar).resize( nvar+ntgt );
480  myprof.at(cls).at(ivar).resize( nvar+ntgt );
481  mycorr.at(cls).at(ivar).assign( nvar+ntgt, 0 ); // fill with zeros
482  myprof.at(cls).at(ivar).assign( nvar+ntgt, 0 ); // fill with zeros
483  }
484  }
485 
486  // if there are too many input variables, the creation of correlations plots blows up
487  // memory and basically kills the TMVA execution
488  // --> avoid above critical number (which can be user defined)
489  if (nvar+ntgt > (UInt_t)gConfig().GetVariablePlotting().fMaxNumOfAllowedVariablesForScatterPlots) {
490  Int_t nhists = (nvar+ntgt)*(nvar+ntgt - 1)/2;
491  Log() << kINFO << gTools().Color("dgreen") << Endl;
492  Log() << kINFO << "<PlotVariables> Will not produce scatter plots ==> " << Endl;
493  Log() << kINFO
494  << "| The number of " << nvar << " input variables and " << ntgt << " target values would require "
495  << nhists << " two-dimensional" << Endl;
496  Log() << kINFO
497  << "| histograms, which would occupy the computer's memory. Note that this" << Endl;
498  Log() << kINFO
499  << "| suppression does not have any consequences for your analysis, other" << Endl;
500  Log() << kINFO
501  << "| than not disposing of these scatter plots. You can modify the maximum" << Endl;
502  Log() << kINFO
503  << "| number of input variables allowed to generate scatter plots in your" << Endl;
504  Log() << "| script via the command line:" << Endl;
505  Log() << kINFO
506  << "| \"(TMVA::gConfig().GetVariablePlotting()).fMaxNumOfAllowedVariablesForScatterPlots = <some int>;\""
507  << gTools().Color("reset") << Endl;
508  Log() << Endl;
509  Log() << kINFO << "Some more output" << Endl;
510  }
511 
515 
516  for (UInt_t var_tgt = 0; var_tgt < 2; var_tgt++) { // create the histos first for the variables, then for the targets
517  UInt_t nloops = ( var_tgt == 0? nvar:ntgt ); // number of variables or number of targets
518  for (UInt_t ivar=0; ivar<nloops; ivar++) {
519  const VariableInfo& info = ( var_tgt == 0 ? Variable( ivar ) : Target(ivar) ); // choose the appropriate one (variable or target)
520  TString myVari = info.GetInternalName();
521 
522  Double_t mean = fVariableStats.at(fNumC-1).at( ( var_tgt*nvar )+ivar).fMean;
523  Double_t rms = fVariableStats.at(fNumC-1).at( ( var_tgt*nvar )+ivar).fRMS;
524 
525  for (Int_t cls = 0; cls < ncls; cls++) {
526 
527  TString className = fDataSetInfo.GetClassInfo(cls)->GetName();
528 
529  // add "target" in case of target variable (required for plotting macros)
530  className += (ntgt == 1 && var_tgt == 1 ? "_target" : "");
531 
532  // choose reasonable histogram ranges, by removing outliers
533  TH1* h = 0;
534  if (info.GetVarType() == 'I') {
535  // special treatment for integer variables
536  Int_t xmin = TMath::Nint( GetMin( ( var_tgt*nvar )+ivar) );
537  Int_t xmax = TMath::Nint( GetMax( ( var_tgt*nvar )+ivar) + 1 );
538  Int_t nbins = xmax - xmin;
539 
540  h = new TH1F( Form("%s__%s%s", myVari.Data(), className.Data(), transfType.Data()),
541  info.GetTitle(), nbins, xmin, xmax );
542  }
543  else {
544  Double_t xmin = TMath::Max( GetMin( ( var_tgt*nvar )+ivar), mean - timesRMS*rms );
545  Double_t xmax = TMath::Min( GetMax( ( var_tgt*nvar )+ivar), mean + timesRMS*rms );
546 
547  //std::cout << "Class="<<cls<<" xmin="<<xmin << " xmax="<<xmax<<" mean="<<mean<<" rms="<<rms<<" timesRMS="<<timesRMS<<std::endl;
548  // protection
549  if (xmin >= xmax) xmax = xmin*1.1; // try first...
550  if (xmin >= xmax) xmax = xmin + 1; // this if xmin == xmax == 0
551  // safety margin for values equal to the maximum within the histogram
552  xmax += (xmax - xmin)/nbins1D;
553 
554  h = new TH1F( Form("%s__%s%s", myVari.Data(), className.Data(), transfType.Data()),
555  info.GetTitle(), nbins1D, xmin, xmax );
556  }
557 
558  h->GetXaxis()->SetTitle( gTools().GetXTitleWithUnit( GetVariableAxisTitle( info ), info.GetUnit() ) );
559  h->GetYaxis()->SetTitle( gTools().GetYTitleWithUnit( *h, info.GetUnit(), kFALSE ) );
560  hVars.at(cls).at((var_tgt*nvar)+ivar) = h;
561 
562  // profile and scatter plots
563  if (nvar+ntgt <= (UInt_t)gConfig().GetVariablePlotting().fMaxNumOfAllowedVariablesForScatterPlots) {
564 
565  for (UInt_t v_t = 0; v_t < 2; v_t++) {
566  UInt_t nl = ( v_t==0?nvar:ntgt );
567  UInt_t start = ( v_t==0? (var_tgt==0?ivar+1:0):(var_tgt==0?nl:ivar+1) );
568  for (UInt_t j=start; j<nl; j++) {
569  // choose the appropriate one (variable or target)
570  const VariableInfo& infoj = ( v_t == 0 ? Variable( j ) : Target(j) );
571  TString myVarj = infoj.GetInternalName();
572 
573  Double_t rxmin = fVariableStats.at(fNumC-1).at( ( v_t*nvar )+ivar).fMin;
574  Double_t rxmax = fVariableStats.at(fNumC-1).at( ( v_t*nvar )+ivar).fMax;
575  Double_t rymin = fVariableStats.at(fNumC-1).at( ( v_t*nvar )+j).fMin;
576  Double_t rymax = fVariableStats.at(fNumC-1).at( ( v_t*nvar )+j).fMax;
577 
578  // scatter plot
579  TH2F* h2 = new TH2F( Form( "scat_%s_vs_%s_%s%s" , myVarj.Data(), myVari.Data(),
580  className.Data(), transfType.Data() ),
581  Form( "%s versus %s (%s)%s", infoj.GetTitle(), info.GetTitle(),
582  className.Data(), transfType.Data() ),
583  nbins2D, rxmin , rxmax,
584  nbins2D, rymin , rymax );
585 
586  h2->GetXaxis()->SetTitle( gTools().GetXTitleWithUnit( GetVariableAxisTitle( info ), info .GetUnit() ) );
587  h2->GetYaxis()->SetTitle( gTools().GetXTitleWithUnit( GetVariableAxisTitle( infoj ), infoj.GetUnit() ) );
588  mycorr.at(cls).at((var_tgt*nvar)+ivar).at((v_t*nvar)+j) = h2;
589 
590  // profile plot
591  TProfile* p = new TProfile( Form( "prof_%s_vs_%s_%s%s", myVarj.Data(),
592  myVari.Data(), className.Data(),
593  transfType.Data() ),
594  Form( "profile %s versus %s (%s)%s",
595  infoj.GetTitle(), info.GetTitle(),
596  className.Data(), transfType.Data() ), nbins1D,
597  rxmin, rxmax );
598  // info.GetMin(), info.GetMax() );
599 
600  p->GetXaxis()->SetTitle( gTools().GetXTitleWithUnit( GetVariableAxisTitle( info ), info .GetUnit() ) );
601  p->GetYaxis()->SetTitle( gTools().GetXTitleWithUnit( GetVariableAxisTitle( infoj ), infoj.GetUnit() ) );
602  myprof.at(cls).at((var_tgt*nvar)+ivar).at((v_t*nvar)+j) = p;
603  }
604  }
605  }
606  }
607  }
608  }
609 
610  UInt_t nevts = events.size();
611 
612  // compute correlation coefficient between target value and variables (regression only)
613  std::vector<Double_t> xregmean ( nvar+1, 0 );
614  std::vector<Double_t> x2regmean( nvar+1, 0 );
615  std::vector<Double_t> xCregmean( nvar+1, 0 );
616 
617  // fill the histograms (this approach should be faster than individual projection
618  for (UInt_t ievt=0; ievt<nevts; ievt++) {
619 
620  const Event* ev = events[ievt];
621 
622  Float_t weight = ev->GetWeight();
623  Int_t cls = ev->GetClass();
624 
625  // average correlation between first target and variables (so far only for single-target regression)
626  if (ntgt == 1) {
627  Float_t valr = ev->GetTarget(0);
628  xregmean[nvar] += valr;
629  x2regmean[nvar] += valr*valr;
630  for (UInt_t ivar=0; ivar<nvar; ivar++) {
631  Float_t vali = ev->GetValue(ivar);
632  xregmean[ivar] += vali;
633  x2regmean[ivar] += vali*vali;
634  xCregmean[ivar] += vali*valr;
635  }
636  }
637 
638  // fill correlation histograms
639  for (UInt_t var_tgt = 0; var_tgt < 2; var_tgt++) { // create the histos first for the variables, then for the targets
640  UInt_t nloops = ( var_tgt == 0? nvar:ntgt ); // number of variables or number of targets
641  for (UInt_t ivar=0; ivar<nloops; ivar++) {
642  Float_t vali = ( var_tgt == 0 ? ev->GetValue(ivar) : ev->GetTarget(ivar) );
643 
644  // variable histos
645  hVars.at(cls).at( ( var_tgt*nvar )+ivar)->Fill( vali, weight );
646 
647  // correlation histos
648  if (nvar+ntgt <= (UInt_t)gConfig().GetVariablePlotting().fMaxNumOfAllowedVariablesForScatterPlots) {
649 
650  for (UInt_t v_t = 0; v_t < 2; v_t++) {
651  UInt_t nl = ( v_t==0 ? nvar : ntgt );
652  UInt_t start = ( v_t==0 ? (var_tgt==0?ivar+1:0) : (var_tgt==0?nl:ivar+1) );
653  for (UInt_t j=start; j<nl; j++) {
654  Float_t valj = ( v_t == 0 ? ev->GetValue(j) : ev->GetTarget(j) );
655  mycorr.at(cls).at( ( var_tgt*nvar )+ivar).at( ( v_t*nvar )+j)->Fill( vali, valj, weight );
656  myprof.at(cls).at( ( var_tgt*nvar )+ivar).at( ( v_t*nvar )+j)->Fill( vali, valj, weight );
657  }
658  }
659  }
660  }
661  }
662  }
663 
664  // correlation analysis for ranking (single-target regression only)
665  if (ntgt == 1) {
666  for (UInt_t ivar=0; ivar<=nvar; ivar++) {
667  xregmean[ivar] /= nevts;
668  x2regmean[ivar] = x2regmean[ivar]/nevts - xregmean[ivar]*xregmean[ivar];
669  }
670  for (UInt_t ivar=0; ivar<nvar; ivar++) {
671  xCregmean[ivar] = xCregmean[ivar]/nevts - xregmean[ivar]*xregmean[nvar];
672  xCregmean[ivar] /= TMath::Sqrt( x2regmean[ivar]*x2regmean[nvar] );
673  }
674 
675  fRanking.push_back( new Ranking( GetName() + "Transformation", "|Correlation with target|" ) );
676  for (UInt_t ivar=0; ivar<nvar; ivar++) {
677  Double_t abscor = TMath::Abs( xCregmean[ivar] );
678  fRanking.back()->AddRank( Rank( fDataSetInfo.GetVariableInfo(ivar).GetLabel(), abscor ) );
679  }
680 
682 
683  // compute also mutual information (non-linear correlation measure)
684  fRanking.push_back( new Ranking( GetName() + "Transformation", "Mutual information" ) );
685  for (UInt_t ivar=0; ivar<nvar; ivar++) {
686  TH2F* h1 = mycorr.at(0).at( nvar ).at( ivar );
687  Double_t mi = gTools().GetMutualInformation( *h1 );
688  fRanking.back()->AddRank( Rank( fDataSetInfo.GetVariableInfo(ivar).GetLabel(), mi ) );
689  }
690 
691  // compute correlation ratio (functional correlations measure)
692  fRanking.push_back( new Ranking( GetName() + "Transformation", "Correlation Ratio" ) );
693  for (UInt_t ivar=0; ivar<nvar; ivar++) {
694  TH2F* h2 = mycorr.at(0).at( nvar ).at( ivar );
695  Double_t cr = gTools().GetCorrelationRatio( *h2 );
696  fRanking.back()->AddRank( Rank( fDataSetInfo.GetVariableInfo(ivar).GetLabel(), cr ) );
697  }
698 
699  // additionally compute correlation ratio from transposed histograms since correlation ratio is asymmetric
700  fRanking.push_back( new Ranking( GetName() + "Transformation", "Correlation Ratio (T)" ) );
701  for (UInt_t ivar=0; ivar<nvar; ivar++) {
702  TH2F* h2T = gTools().TransposeHist( *mycorr.at(0).at( nvar ).at( ivar ) );
703  Double_t cr = gTools().GetCorrelationRatio( *h2T );
704  fRanking.back()->AddRank( Rank( fDataSetInfo.GetVariableInfo(ivar).GetLabel(), cr ) );
705  delete h2T;
706  }
707  }
708  }
709  // computes ranking of input variables
710  // separation for 2-class classification
711  else if (fDataSetInfo.GetNClasses() == 2
712  && fDataSetInfo.GetClassInfo("Signal") != NULL
713  && fDataSetInfo.GetClassInfo("Background") != NULL
714  ) { // TODO: ugly hack.. adapt to new framework
715  fRanking.push_back( new Ranking( GetName() + "Transformation", "Separation" ) );
716  for (UInt_t i=0; i<nvar; i++) {
717  Double_t sep = gTools().GetSeparation( hVars.at(fDataSetInfo.GetClassInfo("Signal") ->GetNumber()).at(i),
718  hVars.at(fDataSetInfo.GetClassInfo("Background")->GetNumber()).at(i) );
719  fRanking.back()->AddRank( Rank( hVars.at(fDataSetInfo.GetClassInfo("Signal")->GetNumber()).at(i)->GetTitle(),
720  sep ) );
721  }
722  }
723 
724  // for regression compute performance from correlation with target value
725 
726  // write histograms
727 
728  TDirectory* localDir = theDirectory;
729  if (theDirectory == 0) {
730  // create directory in root dir
731  fRootBaseDir->cd();
732  TString outputDir = TString("InputVariables");
734  while (VariableTransformBase *trf = (VariableTransformBase*) trIt())
735  outputDir += "_" + TString(trf->GetShortName());
736 
737  TString uniqueOutputDir = outputDir;
738  Int_t counter = 0;
739  TObject* o = NULL;
740  while( (o = fRootBaseDir->FindObject(uniqueOutputDir)) != 0 ){
741  uniqueOutputDir = outputDir+Form("_%d",counter);
742  Log() << kINFO << "A " << o->ClassName() << " with name " << o->GetName() << " already exists in "
743  << fRootBaseDir->GetPath() << ", I will try with "<<uniqueOutputDir<<"." << Endl;
744  ++counter;
745  }
746 
747  // TObject* o = fRootBaseDir->FindObject(outputDir);
748  // if (o != 0) {
749  // Log() << kFATAL << "A " << o->ClassName() << " with name " << o->GetName() << " already exists in "
750  // << fRootBaseDir->GetPath() << "("<<outputDir<<")" << Endl;
751  // }
752  localDir = fRootBaseDir->mkdir( uniqueOutputDir );
753  localDir->cd();
754 
755  Log() << kVERBOSE << "Create and switch to directory " << localDir->GetPath() << Endl;
756  }
757  else {
758  theDirectory->cd();
759  }
760 
761  for (UInt_t i=0; i<nvar+ntgt; i++) {
762  for (Int_t cls = 0; cls < ncls; cls++) {
763  if (hVars.at(cls).at(i) != 0) {
764  hVars.at(cls).at(i)->Write();
765  hVars.at(cls).at(i)->SetDirectory(0);
766  delete hVars.at(cls).at(i);
767  }
768  }
769  }
770 
771  // correlation plots have dedicated directory
772  if (nvar+ntgt <= (UInt_t)gConfig().GetVariablePlotting().fMaxNumOfAllowedVariablesForScatterPlots) {
773 
774  localDir = localDir->mkdir( "CorrelationPlots" );
775  localDir ->cd();
776  Log() << kDEBUG << "Create scatter and profile plots in target-file directory: " << Endl;
777  Log() << kDEBUG << localDir->GetPath() << Endl;
778 
779 
780  for (UInt_t i=0; i<nvar+ntgt; i++) {
781  for (UInt_t j=i+1; j<nvar+ntgt; j++) {
782  for (Int_t cls = 0; cls < ncls; cls++) {
783  if (mycorr.at(cls).at(i).at(j) != 0 ) {
784  mycorr.at(cls).at(i).at(j)->Write();
785  mycorr.at(cls).at(i).at(j)->SetDirectory(0);
786  delete mycorr.at(cls).at(i).at(j);
787  }
788  if (myprof.at(cls).at(i).at(j) != 0) {
789  myprof.at(cls).at(i).at(j)->Write();
790  myprof.at(cls).at(i).at(j)->SetDirectory(0);
791  delete myprof.at(cls).at(i).at(j);
792  }
793  }
794  }
795  }
796  }
797  if (theDirectory != 0 ) theDirectory->cd();
798  else fRootBaseDir->cd();
799 }
800 
801 ////////////////////////////////////////////////////////////////////////////////
802 /// returns string for transformation
803 
805 {
807  if (!trf) return 0;
809 }
810 
811 ////////////////////////////////////////////////////////////////////////////////
812 /// returns string for transformation
813 
815 {
817  if (!trf) return 0;
818  else return trf->GetName();
819 }
820 
821 ////////////////////////////////////////////////////////////////////////////////
822 /// write transformatino to stream
823 
824 void TMVA::TransformationHandler::WriteToStream( std::ostream& o ) const
825 {
827  std::vector< Int_t >::const_iterator rClsIt = fTransformationsReferenceClasses.begin();
828 
829  o << "NTransformtations " << fTransformations.GetSize() << std::endl << std::endl;
830 
831  ClassInfo* ci;
832  UInt_t i = 1;
833  while (VariableTransformBase *trf = (VariableTransformBase*) trIt()) {
834  o << "#TR -*-*-*-*-*-*-* transformation " << i++ << ": " << trf->GetName() << " -*-*-*-*-*-*-*-" << std::endl;
835  trf->WriteTransformationToStream(o);
836  ci = fDataSetInfo.GetClassInfo( (*rClsIt) );
837  TString clsName;
838  if (ci == 0 ) clsName = "AllClasses";
839  else clsName = ci->GetName();
840  o << "ReferenceClass " << clsName << std::endl;
841  rClsIt++;
842  }
843 }
844 
845 
846 ////////////////////////////////////////////////////////////////////////////////
847 /// XML node describing the transformation
848 /// return;
849 
850 void TMVA::TransformationHandler::AddXMLTo( void* parent ) const
851 {
852  if(!parent) return;
853  void* trfs = gTools().AddChild(parent, "Transformations");
854  gTools().AddAttr( trfs, "NTransformations", fTransformations.GetSize() );
856  while (VariableTransformBase *trf = (VariableTransformBase*) trIt()) trf->AttachXMLTo(trfs);
857 }
858 
859 ////////////////////////////////////////////////////////////////////////////////
860 ///VariableTransformBase* trf = ((VariableTransformBase*)GetTransformationList().Last());
861 ///trf->ReadTransformationFromStream(fin);
862 
864 {
865  Log() << kFATAL << "Read transformations not implemented" << Endl;
866  // TODO
867 }
868 
869 ////////////////////////////////////////////////////////////////////////////////
870 
872 {
873  void* ch = gTools().GetChild( trfsnode );
874  while(ch) {
875  Int_t idxCls = -1;
876  TString trfname;
877  gTools().ReadAttr(ch, "Name", trfname);
878 
879  VariableTransformBase* newtrf = 0;
880 
881  if (trfname == "Decorrelation" ) {
883  }
884  else if (trfname == "PCA" ) {
885  newtrf = new VariablePCATransform(fDataSetInfo);
886  }
887  else if (trfname == "Gauss" ) {
888  newtrf = new VariableGaussTransform(fDataSetInfo);
889  }
890  else if (trfname == "Uniform" ) {
891  newtrf = new VariableGaussTransform(fDataSetInfo, "Uniform");
892  }
893  else if (trfname == "Normalize" ) {
895  }
896  else if (trfname == "Rearrange" ) {
898  }
899  else if (trfname != "None") {
900  }
901  else {
902  Log() << kFATAL << "<ReadFromXML> Variable transform '"
903  << trfname << "' unknown." << Endl;
904  }
905  newtrf->ReadFromXML( ch );
906  AddTransformation( newtrf, idxCls );
907  ch = gTools().GetNextChild(ch);
908  }
909 }
910 
911 ////////////////////////////////////////////////////////////////////////////////
912 /// prints ranking of input variables
913 
915 {
916  //Log() << kINFO << " " << Endl;
917  Log() << kINFO << "Ranking input variables (method unspecific)..." << Endl;
918  std::vector<Ranking*>::const_iterator it = fRanking.begin();
919  for (; it != fRanking.end(); it++) (*it)->Print();
920 }
921 
922 ////////////////////////////////////////////////////////////////////////////////
923 
925 {
926  try {
927  return fVariableStats.at(cls).at(ivar).fMean;
928  }
929  catch(...) {
930  try {
931  return fVariableStats.at(fNumC-1).at(ivar).fMean;
932  }
933  catch(...) {
934  Log() << kWARNING << "Inconsistent variable state when reading the mean value. " << Endl;
935  }
936  }
937  Log() << kWARNING << "Inconsistent variable state when reading the mean value. Value 0 given back" << Endl;
938  return 0;
939 }
940 
941 
942 ////////////////////////////////////////////////////////////////////////////////
943 
945 {
946  try {
947  return fVariableStats.at(cls).at(ivar).fRMS;
948  }
949  catch(...) {
950  try {
951  return fVariableStats.at(fNumC-1).at(ivar).fRMS;
952  }
953  catch(...) {
954  Log() << kWARNING << "Inconsistent variable state when reading the RMS value. " << Endl;
955  }
956  }
957  Log() << kWARNING << "Inconsistent variable state when reading the RMS value. Value 0 given back" << Endl;
958  return 0;
959 }
960 
961 ////////////////////////////////////////////////////////////////////////////////
962 
964 {
965  try {
966  return fVariableStats.at(cls).at(ivar).fMin;
967  }
968  catch(...) {
969  try {
970  return fVariableStats.at(fNumC-1).at(ivar).fMin;
971  }
972  catch(...) {
973  Log() << kWARNING << "Inconsistent variable state when reading the minimum value. " << Endl;
974  }
975  }
976  Log() << kWARNING << "Inconsistent variable state when reading the minimum value. Value 0 given back" << Endl;
977  return 0;
978 }
979 
980 ////////////////////////////////////////////////////////////////////////////////
981 
983 {
984  try {
985  return fVariableStats.at(cls).at(ivar).fMax;
986  }
987  catch(...) {
988  try {
989  return fVariableStats.at(fNumC-1).at(ivar).fMax;
990  }
991  catch(...) {
992  Log() << kWARNING << "Inconsistent variable state when reading the maximum value. " << Endl;
993  }
994  }
995  Log() << kWARNING << "Inconsistent variable state when reading the maximum value. Value 0 given back" << Endl;
996  return 0;
997 }
Double_t GetRMS(Int_t ivar, Int_t cls=-1) const
std::vector< std::vector< TMVA::TransformationHandler::VariableStat > > fVariableStats
reference classes for the transformations
Config & gConfig()
Definition: Config.cxx:43
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
UInt_t GetNVariables() const
Definition: DataSetInfo.h:128
Int_t fMaxNumOfAllowedVariablesForScatterPlots
Definition: Config.h:88
float xmin
Definition: THbookFile.cxx:93
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:162
std::vector< Ranking * > fRanking
const TString & GetInternalName() const
Definition: VariableInfo.h:66
float Float_t
Definition: RtypesCore.h:53
TDirectory * fRootBaseDir
ranking object
TransformationHandler(DataSetInfo &, const TString &callerName)
constructor
const TList & GetTransformationList() const
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
Definition: THist.hxx:302
TH1 * h
Definition: legend2.C:5
void PlotVariables(const std::vector< Event *> &events, TDirectory *theDirectory=0)
create histograms from the input variables
virtual Int_t GetEntries() const
Definition: TCollection.h:92
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TList.cxx:581
virtual TObject * FindObject(const char *name) const
Find object by name in the list of memory objects.
Definition: TDirectory.cxx:647
Basic string class.
Definition: TString.h:137
const TString & GetUnit() const
Definition: VariableInfo.h:68
Double_t GetMutualInformation(const TH2F &)
Mutual Information method for non-linear correlations estimates in 2D histogram Author: Moritz Backes...
Definition: Tools.cxx:598
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:170
int Int_t
Definition: RtypesCore.h:41
virtual TDirectory * mkdir(const char *name, const char *title="")
Create a sub-directory and return a pointer to the created directory.
Definition: TDirectory.cxx:957
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
UInt_t GetNClasses() const
Definition: DataSetInfo.h:154
virtual const char * GetName() const
Returns name of object.
int nbins[3]
const Event * Transform(const Event *) const
the transformation
const TString & GetLabel() const
Definition: VariableInfo.h:67
static std::string format(double x, double y, int digits, int width)
Profile Historam.
Definition: TProfile.h:34
void AddAttr(void *node, const char *, const T &value, Int_t precision=16)
Definition: Tools.h:309
void * AddChild(void *parent, const char *childname, const char *content=0, bool isRootNode=false)
add child node
Definition: Tools.cxx:1134
Short_t Abs(Short_t d)
Definition: TMathBase.h:110
Iterator of linked list.
Definition: TList.h:187
const TString & GetExpression() const
Definition: VariableInfo.h:65
void ReadFromStream(std::istream &istr)
VariableTransformBase* trf = ((VariableTransformBase*)GetTransformationList().Last()); trf->ReadTrans...
virtual std::vector< TString > * GetTransformationStrings(Int_t cls) const
TODO –> adapt to variable,target,spectator selection default transformation output –> only indicate...
Tools & gTools()
Definition: Tools.cxx:79
char GetVarType() const
Definition: VariableInfo.h:69
static const double x2[5]
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:188
Double_t x[n]
Definition: legend1.C:17
void SetTransformationReferenceClass(Int_t cls)
overrides the setting for all classes! (this is put in basically for the likelihood-method) be carefu...
void AddXMLTo(void *parent=0) const
XML node describing the transformation return;.
void * GetChild(void *parent, const char *childname=0)
get child node
Definition: Tools.cxx:1158
TString GetVariableAxisTitle(const VariableInfo &info) const
incorporates transformation type into title axis (usually for histograms)
UInt_t GetClass() const
Definition: Event.h:89
void SetCallerName(const TString &name)
std::vector< std::vector< double > > Data
Double_t GetMean(Int_t ivar, Int_t cls=-1) const
std::vector< Int_t > fTransformationsReferenceClasses
list of transformations
TH1F * h1
Definition: legend1.C:5
Double_t GetWeight() const
return the event weight - depending on whether the flag IgnoreNegWeightsInTraining is or not...
Definition: Event.cxx:378
virtual void ReadFromXML(void *trfnode)=0
Read the input variables from the XML node.
const std::vector< Event * > * CalcTransformations(const std::vector< Event *> &, Bool_t createNewVector=kFALSE)
computation of transformation
Float_t GetTarget(UInt_t itgt) const
Definition: Event.h:104
UInt_t GetNTargets() const
Definition: DataSetInfo.h:129
void AddStats(Int_t k, UInt_t ivar, Double_t mean, Double_t rms, Double_t min, Double_t max)
ClassInfo * GetClassInfo(Int_t clNum) const
tomato 2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:255
unsigned int UInt_t
Definition: RtypesCore.h:42
char * Form(const char *fmt,...)
const Event * InverseTransform(const Event *, Bool_t suppressIfNoTargets=true) const
Ssiz_t Length() const
Definition: TString.h:390
void ReadAttr(void *node, const char *, T &value)
Definition: Tools.h:296
TAxis * GetYaxis()
Definition: TH1.h:325
float xmax
Definition: THbookFile.cxx:93
void MakeFunction(std::ostream &fout, const TString &fncName, Int_t part) const
create transformation function
virtual const char * GetPath() const
Returns the full path of the directory.
Definition: TDirectory.cxx:911
const char * GetNameOfLastTransform() const
returns string for transformation
Float_t GetValue(UInt_t ivar) const
return value of i&#39;th variable
Definition: Event.cxx:233
TString fCallerName
if set put input var hists
void WriteToStream(std::ostream &o) const
write transformatino to stream
double Double_t
Definition: RtypesCore.h:55
Double_t GetMax(Int_t ivar, Int_t cls=-1) const
Describe directory structure in memory.
Definition: TDirectory.h:44
void * GetNextChild(void *prevchild, const char *childname=0)
XML helpers.
Definition: Tools.cxx:1170
TString GetName() const
return transformation name
The TH1 histogram class.
Definition: TH1.h:80
VariableInfo & GetVariableInfo(Int_t i)
Definition: DataSetInfo.h:114
UInt_t GetNumber() const
Definition: ClassInfo.h:73
void PrintVariableRanking() const
prints ranking of input variables
const TString & Color(const TString &)
human readable color strings
Definition: Tools.cxx:837
Mother of all ROOT objects.
Definition: TObject.h:37
void SetSource(const std::string &source)
Definition: MsgLogger.h:74
MsgLogger & Log() const
message logger
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
Definition: TDirectory.cxx:435
virtual void Add(TObject *obj)
Definition: TList.h:81
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:202
const TMVA::VariableInfo & Variable(UInt_t ivar) const
MsgLogger * fLogger
name of the caller for output
#define NULL
Definition: Rtypes.h:82
TString()
TString default ctor.
Definition: TString.cxx:88
Double_t Sqrt(Double_t x)
Definition: TMath.h:464
const Bool_t kIterBackward
Definition: TCollection.h:44
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:416
virtual Int_t GetSize() const
Definition: TCollection.h:95
std::vector< TString > * GetTransformationStringsOfLastTransform() const
returns string for transformation
void CalcStats(const std::vector< Event *> &events)
TH2F * TransposeHist(const TH2F &)
Transpose quadratic histogram.
Definition: Tools.cxx:666
const TMVA::VariableInfo & Target(UInt_t itgt) const
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
THist< 2, float, THistStatContent, THistStatUncertainty > TH2F
Definition: THist.hxx:308
Int_t Nint(T x)
Definition: TMath.h:480
VariablePlotting & GetVariablePlotting()
Definition: Config.h:77
Double_t GetCorrelationRatio(const TH2F &)
Compute Correlation Ratio of 2D histogram to estimate functional dependency between two variables Aut...
Definition: Tools.cxx:629
char name[80]
Definition: TGX11.cxx:109
TAxis * GetXaxis()
Definition: TH1.h:324
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
VariableTransformBase * AddTransformation(VariableTransformBase *, Int_t cls)
Double_t GetSeparation(TH1 *S, TH1 *B) const
compute "separation" defined as <s2> = (1/2) Int_-oo..+oo { (S(x) - B(x))^2/(S(x) + B(x)) dx } ...
Definition: Tools.cxx:136
const char * Data() const
Definition: TString.h:349
Double_t GetMin(Int_t ivar, Int_t cls=-1) const