File indexing completed on 2025-01-30 10:23:05
0001
0002
0003
0004
0005 #ifndef ROOT_TMVA_VariableImportance
0006 #define ROOT_TMVA_VariableImportance
0007
0008
0009 #include "TString.h"
0010 #include <vector>
0011
0012 #include "TMVA/Configurable.h"
0013 #include "TMVA/Types.h"
0014
0015 #include <TMVA/Factory.h>
0016
0017 #include <TMVA/DataLoader.h>
0018
0019 #include <TMVA/OptionMap.h>
0020
0021 #include <TMVA/Envelope.h>
0022
0023 namespace TMVA {
0024
0025 class VariableImportanceResult
0026 {
0027 friend class VariableImportance;
0028 private:
0029 OptionMap fImportanceValues;
0030 std::shared_ptr<TH1F> fImportanceHist;
0031 VIType fType {kShort};
0032 public:
0033 VariableImportanceResult();
0034 VariableImportanceResult(const VariableImportanceResult &);
0035 ~VariableImportanceResult(){fImportanceHist=nullptr;}
0036
0037 OptionMap &GetImportanceValues(){return fImportanceValues;}
0038 TH1F *GetImportanceHist(){return fImportanceHist.get();}
0039 void Print() const ;
0040
0041 TCanvas* Draw(const TString name="VariableImportance") const;
0042 };
0043
0044 class VariableImportance : public Envelope {
0045 private:
0046 UInt_t fNumFolds = 0;
0047 VariableImportanceResult fResults;
0048 VIType fType {kShort};
0049 public:
0050 explicit VariableImportance(DataLoader *loader);
0051 ~VariableImportance();
0052
0053 virtual void Evaluate();
0054
0055 void SetType(VIType type){fType=type;}
0056 VIType GetType(){return fType;}
0057
0058 const VariableImportanceResult& GetResults() const {return fResults;}
0059 protected:
0060
0061 void EvaluateImportanceShort();
0062
0063 void EvaluateImportanceAll();
0064
0065 void EvaluateImportanceRandom(UInt_t nseeds);
0066
0067
0068 TH1F* GetImportance(const UInt_t nbits,std::vector<Float_t> &importances,std::vector<TString> &varNames);
0069
0070
0071 ULong_t Sum(ULong_t i);
0072
0073 private:
0074 std::unique_ptr<Factory> fClassifier;
0075 ClassDef(VariableImportance,0);
0076 };
0077 }
0078
0079
0080 #endif