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