64 if(
fType==VIType::kShort)
66 fLogger<<kINFO<<
"Variable Importance Results (Short)"<<
Endl;
67 }
else if(
fType==VIType::kAll)
69 fLogger<<kINFO<<
"Variable Importance Results (All)"<<
Endl;
71 fLogger<<kINFO<<
"Variable Importance Results (Random)"<<
Endl;
94 fClassifier=std::unique_ptr<Factory>(
new TMVA::Factory(
"VariableImportance",
"!V:!ROC:!ModelPersistence:Silent:Color:!DrawProgressBar:AnalysisType=Classification"));
110 if(
fType==VIType::kShort)
113 }
else if(
fType==VIType::kAll)
119 Log()<<kERROR<<
"Running variable importance with less that 10 varibales in Random mode "<<
120 "can to produce inconsisten results"<<
Endl;
126 Log()<<kINFO<<
"Evaluation done."<<
Endl;
143 TH1F *vihist =
new TH1F(
"vihist",
"", nbits, 0, nbits);
145 gStyle->SetOptStat(000000);
148 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
152 gStyle->SetTitleXOffset(0.4);
153 gStyle->SetTitleXOffset(1.2);
156 for (
UInt_t i = 1; i < nbits + 1; i++) {
157 roc = 100.0 * importances[i - 1] / normalization;
195 std::vector<TString> varNames =
fDataLoader->GetDefaultDataSetInfo().GetListOfVariables();
200 std::vector<Float_t> importances(nbits);
201 for (
UInt_t i = 0; i < nbits; i++)
208 std::bitset<NBITS> xbitset(
x);
210 Log() << kFATAL <<
"Error: need at least one variable.";
216 for (
UInt_t index = 0; index < nbits; index++) {
225 fClassifier->BookMethod(seeddl, methodName, methodTitle, methodOptions);
233 SROC =
fClassifier->GetROCIntegral(xbitset.to_string(), methodTitle);
239 for (uint32_t i = 0; i <
NBITS; ++i) {
242 std::bitset<NBITS> ybitset(
y);
248 importances[ny] = SROC - 0.5;
255 for (
UInt_t index = 0; index < nbits; index++) {
256 if (ybitset[index]) subseeddl->
AddVariable(varNames[index],
'F');
263 fClassifier->BookMethod(subseeddl, methodName, methodTitle, methodOptions);
271 SSROC =
fClassifier->GetROCIntegral(ybitset.to_string(), methodTitle);
272 importances[ny] += SROC - SSROC;
280 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
282 for(
UInt_t i=0;i<nbits;i++){
284 fResults.fImportanceValues[varNames[i]]=(100.0 * importances[i] / normalization);
309 std::vector<TString> varNames =
fDataLoader->GetDefaultDataSetInfo().GetListOfVariables();
314 std::vector<Float_t> importances(nbits);
316 for (
UInt_t i = 0; i < nbits; i++)
324 x = rangen->Integer(range);
326 std::bitset<NBITS> xbitset(
x);
334 for (
UInt_t index = 0; index < nbits; index++) {
335 if (xbitset[index]) seeddl->
AddVariable(varNames[index],
'F');
342 fClassifier->BookMethod(seeddl, methodName, methodTitle, methodOptions);
350 SROC =
fClassifier->GetROCIntegral(xbitset.to_string(), methodTitle);
356 for (uint32_t i = 0; i < 32; ++i) {
359 std::bitset<NBITS> ybitset(
y);
365 importances[ny] = SROC - 0.5;
372 for (
UInt_t index = 0; index < nbits; index++) {
373 if (ybitset[index]) subseeddl->
AddVariable(varNames[index],
'F');
380 fClassifier->BookMethod(subseeddl, methodName, methodTitle, methodOptions);
388 SSROC =
fClassifier->GetROCIntegral(ybitset.to_string(), methodTitle);
389 importances[ny] += SROC - SSROC;
399 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
401 for(
UInt_t i=0;i<nbits;i++){
403 fResults.fImportanceValues[varNames[i]]=(100.0 * importances[i] / normalization);
426 std::vector<TString> varNames =
fDataLoader->GetDefaultDataSetInfo().GetListOfVariables();
431 std::vector<Float_t> importances(nbits);
434 std::vector<Float_t> ROC(range);
436 for (
UInt_t i = 0; i < nbits; i++)
440 for (
x = 1;
x < range;
x++) {
442 std::bitset<NBITS> xbitset(
x);
450 for (
UInt_t index = 0; index < nbits; index++) {
451 if (xbitset[index]) seeddl->
AddVariable(varNames[index],
'F');
459 fClassifier->BookMethod(seeddl, methodName, methodTitle, methodOptions);
467 ROC[
x] =
fClassifier->GetROCIntegral(xbitset.to_string(), methodTitle);
475 for (
x = 0;
x <range ;
x++)
478 for (uint32_t i = 0; i <
NBITS; ++i) {
481 std::bitset<NBITS> ybitset(
y);
485 importances[ny] = SROC - 0.5;
491 importances[ny] += SROC - SSROC;
497 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
499 for(
UInt_t i=0;i<nbits;i++){
501 fResults.fImportanceValues[varNames[i]]=(100.0 * importances[i] / normalization);
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
virtual void SetTitleSize(Float_t size=0.04)
Set size of axis title.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
void CenterTitle(Bool_t center=kTRUE)
Center axis title.
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
Set the viewing range for the axis from ufirst to ulast (in user coordinates, that is,...
static Int_t GetColor(const char *hexcolor)
1-D histogram with a float per channel (see TH1 documentation)
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
virtual void LabelsOption(Option_t *option="h", Option_t *axis="X")
Sort bins with labels or set option(s) to draw axis with labels.
virtual void SetBarWidth(Float_t width=0.5)
Set the width of bars as fraction of the bin width for drawing mode "B".
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
void PrepareTrainingAndTestTree(const TCut &cut, const TString &splitOpt)
prepare the training and test trees -> same cuts for signal and background
void AddVariable(const TString &expression, const TString &title, const TString &unit, char type='F', Double_t min=0, Double_t max=0)
user inserts discriminating variable in data set info
std::vector< OptionMap > fMethods
! Booked method information
std::shared_ptr< DataLoader > fDataLoader
! data
Envelope(const TString &name, DataLoader *dataloader=nullptr, TFile *file=nullptr, const TString options="")
Constructor for the initialization of Envelopes, differents Envelopes may needs differents constructo...
This is the main MVA steering class.
ostringstream derivative to redirect and format output
static void EnableOutput()
std::shared_ptr< TH1F > fImportanceHist
TCanvas * Draw(const TString name="VariableImportance") const
VariableImportanceResult()
OptionMap fImportanceValues
void Evaluate() override
Virtual method to be implemented with your algorithm.
std::unique_ptr< Factory > fClassifier
void EvaluateImportanceShort()
void EvaluateImportanceRandom(UInt_t nseeds)
VariableImportanceResult fResults
VariableImportance(DataLoader *loader)
TH1F * GetImportance(const UInt_t nbits, std::vector< Float_t > &importances, std::vector< TString > &varNames)
void EvaluateImportanceAll()
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Random number generator class based on M.
create variable transformations
void DataLoaderCopy(TMVA::DataLoader *des, TMVA::DataLoader *src)
MsgLogger & Endl(MsgLogger &ml)
static uint64_t sum(uint64_t i)