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"));
112 if(
fType==VIType::kShort)
115 }
else if(
fType==VIType::kAll)
121 Log()<<kERROR<<
"Running variable importance with less that 10 varibales in Random mode "<<
122 "can to produce inconsisten results"<<
Endl;
128 Log()<<kINFO<<
"Evaluation done."<<
Endl;
145 TH1F *vihist =
new TH1F(
"vihist",
"", nbits, 0, nbits);
150 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
158 for (
UInt_t i = 1; i < nbits + 1; i++) {
159 roc = 100.0 * importances[i - 1] / normalization;
197 std::vector<TString> varNames =
fDataLoader->GetDefaultDataSetInfo().GetListOfVariables();
202 std::vector<Float_t> importances(nbits);
203 for (
UInt_t i = 0; i < nbits; i++)
210 std::bitset<NBITS> xbitset(x);
212 Log() << kFATAL <<
"Error: need at least one variable.";
218 for (
UInt_t index = 0; index < nbits; index++) {
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++){
311 std::vector<TString> varNames =
fDataLoader->GetDefaultDataSetInfo().GetListOfVariables();
316 std::vector<Float_t> importances(nbits);
319 for (
UInt_t i = 0; i < nbits; i++)
327 x = rangen->Integer(range);
329 std::bitset<NBITS> xbitset(x);
337 for (
UInt_t index = 0; index < nbits; index++) {
338 if (xbitset[index]) seeddl->
AddVariable(varNames[index],
'F');
345 fClassifier->BookMethod(seeddl, methodName, methodTitle, methodOptions);
353 SROC =
fClassifier->GetROCIntegral(xbitset.to_string(), methodTitle);
359 for (uint32_t i = 0; i < 32; ++i) {
362 std::bitset<NBITS> ybitset(y);
368 importances[ny] = SROC - 0.5;
369 importances_norm += importances[ny];
376 for (
UInt_t index = 0; index < nbits; index++) {
377 if (ybitset[index]) subseeddl->
AddVariable(varNames[index],
'F');
384 fClassifier->BookMethod(subseeddl, methodName, methodTitle, methodOptions);
392 SSROC =
fClassifier->GetROCIntegral(ybitset.to_string(), methodTitle);
393 importances[ny] += SROC - SSROC;
403 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
405 for(
UInt_t i=0;i<nbits;i++){
430 std::vector<TString> varNames =
fDataLoader->GetDefaultDataSetInfo().GetListOfVariables();
435 std::vector<Float_t> importances(nbits);
438 std::vector<Float_t> ROC(range);
440 for (
UInt_t i = 0; i < nbits; i++)
444 for (x = 1; x < range; x++) {
446 std::bitset<NBITS> xbitset(x);
454 for (
UInt_t index = 0; index < nbits; index++) {
455 if (xbitset[index]) seeddl->
AddVariable(varNames[index],
'F');
463 fClassifier->BookMethod(seeddl, methodName, methodTitle, methodOptions);
471 ROC[
x] =
fClassifier->GetROCIntegral(xbitset.to_string(), methodTitle);
479 for ( x = 0; x <range ; x++)
482 for (uint32_t i = 0; i <
NBITS; ++i) {
485 std::bitset<NBITS> ybitset(y);
489 importances[ny] = SROC - 0.5;
495 importances[ny] += SROC - SSROC;
501 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
503 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
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)
Abstract base class for all high level ml algorithms, you can book ml methods like BDT...
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
Booked method information.
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)
std::vector< OptionMap > fMethods
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
const char * Data() const