Logo ROOT   6.08/07
Reference Guide
VariableImportance.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Omar Zapata and Sergei Gleyzer. 2016
3 
4 
5 #ifndef ROOT_TMVA_VariableImportance
6 #define ROOT_TMVA_VariableImportance
7 
8 
9 #ifndef ROOT_TString
10 #include "TString.h"
11 #endif
12 
13 
14 #ifndef ROOT_TMVA_Configurable
15 #include "TMVA/Configurable.h"
16 #endif
17 #ifndef ROOT_TMVA_Types
18 #include "TMVA/Types.h"
19 #endif
20 
21 #ifndef ROOT_TMVA_Factory
22 #include<TMVA/Factory.h>
23 #endif
24 
25 #ifndef ROOT_TMVA_DataLoader
26 #include<TMVA/DataLoader.h>
27 #endif
28 
29 #ifndef ROOT_TMVA_OptionMap
30 #include<TMVA/OptionMap.h>
31 #endif
32 
33 #ifndef ROOT_TMVA_Envelope
34 #include<TMVA/Envelope.h>
35 #endif
36 
37 namespace TMVA {
38 
40  {
41  friend class VariableImportance;
42  private:
44  std::shared_ptr<TH1F> fImportanceHist;
46  public:
49  ~VariableImportanceResult(){fImportanceHist=nullptr;}
50 
52  TH1F *GetImportanceHist(){return fImportanceHist.get();}
53  void Print() const ;
54 
55  TCanvas* Draw(const TString name="VariableImportance") const;
56  };
57 
58 
59  class VariableImportance : public Envelope {
60  private:
64  public:
65  explicit VariableImportance(DataLoader *loader);
67 
68  virtual void Evaluate();
69 
70  void SetType(VIType type){fType=type;}
71  VIType GetType(){return fType;}
72 
73  const VariableImportanceResult& GetResults() const {return fResults;}//I need to think about this, which is the best way to get the results?
74  protected:
75  //evaluate the simple case that is removing 1 variable at time
76  void EvaluateImportanceShort();
77  //evaluate all variables combinations NOTE: use with care in huge datasets with a huge number of variables
78  void EvaluateImportanceAll();
79  //evaluate randomly given a number of seeds
80  void EvaluateImportanceRandom(UInt_t nseeds);
81 
82  //method to return a nice histogram with the results ;)
83  TH1F* GetImportance(const UInt_t nbits,std::vector<Float_t> &importances,std::vector<TString> &varNames);
84 
85  //method to compute the range(number total of operations for every bit configuration)
86  ULong_t Sum(ULong_t i);
87 
88  private:
89  std::unique_ptr<Factory> fClassifier;
91  };
92 }
93 
94 
95 #endif
96 
97 
98 
VIType
Definition: Types.h:75
class to storage options for the differents methods
Definition: OptionMap.h:43
Basic string class.
Definition: TString.h:137
tomato 1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:575
std::shared_ptr< TH1F > fImportanceHist
TCanvas * Draw(const TString name="VariableImportance") const
#define ClassDef(name, id)
Definition: Rtypes.h:254
std::unique_ptr< Factory > fClassifier
Base class for all machine learning algorithms.
Definition: Envelope.h:55
const VariableImportanceResult & GetResults() const
unsigned int UInt_t
Definition: RtypesCore.h:42
Double_t Sum(const double *x, const double *p)
The Canvas class.
Definition: TCanvas.h:41
int type
Definition: TGX11.cxx:120
unsigned long ULong_t
Definition: RtypesCore.h:51
Abstract ClassifierFactory template that handles arbitrary types.
VariableImportanceResult fResults
char name[80]
Definition: TGX11.cxx:109