45 fImportanceHist(nullptr)
66 if(
fType==VIType::kShort)
68 fLogger<<kINFO<<
"Variable Importance Results (Short)"<<
Endl;
69 }
else if(
fType==VIType::kAll)
71 fLogger<<kINFO<<
"Variable Importance Results (All)"<<
Endl;
73 fLogger<<kINFO<<
"Variable Importance Results (Random)"<<
Endl;
96 fClassifier=std::unique_ptr<Factory>(
new TMVA::Factory(
"VariableImportance",
"!V:!ROC:!ModelPersistence:Silent:Color:!DrawProgressBar:AnalysisType=Classification"));
115 if(
fType==VIType::kShort)
118 }
else if(
fType==VIType::kAll)
124 Log()<<kERROR<<
"Running variable importance with less that 10 varibales in Random mode "<<
125 "can to produce inconsisten results"<<
Endl;
131 Log()<<kINFO<<
"Evaluation done."<<
Endl;
148 TH1F *vihist =
new TH1F(
"vihist",
"", nbits, 0, nbits);
153 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
161 for (
UInt_t i = 1; i < nbits + 1; i++) {
162 roc = 100.0 * importances[i - 1] / normalization;
199 std::vector<TString> varNames =
fDataLoader->GetDefaultDataSetInfo().GetListOfVariables();
204 std::vector<Float_t> importances(nbits);
205 for (
UInt_t i = 0; i < nbits; i++)importances[i] = 0;
211 std::bitset<NBITS> xbitset(x);
212 if (x == 0)
Log()<<kFATAL<<
"Error: need at least one variable.";
219 for (
UInt_t index = 0; index < nbits; index++){
220 if (xbitset[index]) seeddl->
AddVariable(varNames[index],
'F');
227 fClassifier->BookMethod(seeddl, methodName, methodTitle, methodOptions);
235 SROC =
fClassifier->GetROCIntegral(xbitset.to_string(), methodTitle);
241 for (uint32_t i = 0; i <
NBITS; ++i) {
244 std::bitset<NBITS> ybitset(y);
250 importances[
ny] = SROC - 0.5;
257 for (
UInt_t index = 0; index < nbits; index++) {
258 if (ybitset[index]) subseeddl->
AddVariable(varNames[index],
'F');
265 fClassifier->BookMethod(subseeddl, methodName, methodTitle, methodOptions);
273 SSROC =
fClassifier->GetROCIntegral(ybitset.to_string(), methodTitle);
274 importances[
ny] += SROC - SSROC;
282 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
284 for(
UInt_t i=0;i<nbits;i++){
308 std::vector<TString> varNames =
fDataLoader->GetDefaultDataSetInfo().GetListOfVariables();
313 std::vector<Float_t> importances(nbits);
316 for (
UInt_t i = 0; i < nbits; i++)importances[i] = 0;
323 x = rangen -> Integer(range);
325 std::bitset<NBITS> xbitset(x);
326 if (x == 0)
continue;
333 for (
UInt_t index = 0; index < nbits; index++) {
334 if (xbitset[index]) seeddl->
AddVariable(varNames[index],
'F');
341 fClassifier->BookMethod(seeddl, methodName, methodTitle, methodOptions);
349 SROC =
fClassifier->GetROCIntegral(xbitset.to_string(), methodTitle);
355 for (uint32_t i = 0; i < 32; ++i) {
358 std::bitset<NBITS> ybitset(y);
364 importances[
ny] = SROC - 0.5;
365 importances_norm += importances[
ny];
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++){
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++) importances[i] = 0;
439 for ( x = 1; x <range ; x++) {
441 std::bitset<NBITS> xbitset(x);
442 if (x == 0)
continue;
448 for (
UInt_t index = 0; index < nbits; index++) {
449 if (xbitset[index]) seeddl->
AddVariable(varNames[index],
'F');
457 fClassifier->BookMethod(seeddl, methodName, methodTitle, methodOptions);
465 ROC[
x] =
fClassifier->GetROCIntegral(xbitset.to_string(), methodTitle);
473 for ( x = 0; x <range ; x++)
476 for (uint32_t i = 0; i <
NBITS; ++i) {
479 std::bitset<NBITS> ybitset(y);
483 importances[
ny] = SROC - 0.5;
489 importances[
ny] += SROC - SSROC;
495 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
497 for(
UInt_t i=0;i<nbits;i++){
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title Offset is a correction factor with respect to the "s...
static long int sum(long int i)
Random number generator class based on M.
MsgLogger & Endl(MsgLogger &ml)
virtual void LabelsOption(Option_t *option="h", Option_t *axis="X")
Set option(s) to draw axis with labels.
virtual void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list of histogram objects in the current ...
virtual void Evaluate()
Virtual method to be implemented with your algorithm.
T GetValue(const TString &key)
R__EXTERN TStyle * gStyle
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
OptionMap fImportanceValues
tomato 1-D histogram with a float per channel (see TH1 documentation)}
void DataLoaderCopy(TMVA::DataLoader *des, TMVA::DataLoader *src)
void CenterTitle(Bool_t center=kTRUE)
Center axis title.
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::shared_ptr< TH1F > fImportanceHist
virtual void SetBarWidth(Float_t width=0.5)
TCanvas * Draw(const TString name="VariableImportance") const
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
Set the viewing range for the axis from ufirst to ulast (in user coordinates).
std::unique_ptr< Factory > fClassifier
double pow(double, double)
std::vector< std::vector< double > > Data
Base class for all machine learning algorithms.
VariableImportance(DataLoader *loader)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
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...
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb"...
This is the main MVA steering class.
virtual void SetTitleSize(Float_t size=0.04)
Set size of axis title The size is expressed in per cent of the pad width.
void EvaluateImportanceShort()
void PrepareTrainingAndTestTree(const TCut &cut, const TString &splitOpt)
prepare the training and test trees -> same cuts for signal and background
std::shared_ptr< DataLoader > fDataLoader
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
TH1F * GetImportance(const UInt_t nbits, std::vector< Float_t > &importances, std::vector< TString > &varNames)
ostringstream derivative to redirect and format output
virtual void Draw(Option_t *option="")
Draw a canvas.
void SetTitleXOffset(Float_t offset=1)
Abstract ClassifierFactory template that handles arbitrary types.
VariableImportanceResult()
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
static void EnableOutput()
VariableImportanceResult fResults
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
void EvaluateImportanceAll()
void EvaluateImportanceRandom(UInt_t nseeds)
const char * Data() const