55 fLogger<<
kINFO<<
"Variable Importance Results (Short)"<<
Endl;
58 fLogger<<
kINFO<<
"Variable Importance Results (All)"<<
Endl;
60 fLogger<<
kINFO<<
"Variable Importance Results (Random)"<<
Endl;
80 fClassifier=std::unique_ptr<Factory>(
new TMVA::Factory(
"VariableImportance",
"!V:!ROC:!ModelPersistence:Silent:Color:!DrawProgressBar:AnalysisType=Classification"));
105 Log()<<
kERROR<<
"Running variable importance with less that 10 varibales in Random mode "<<
106 "can to produce inconsisten results"<<
Endl;
125 TH1F *vihist =
new TH1F(
"vihist",
"", nbits, 0, nbits);
130 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
138 for (
UInt_t i = 1; i < nbits + 1; i++) {
139 roc = 100.0 * importances[i - 1] / normalization;
174 std::vector<TString> varNames =
fDataLoader->GetDefaultDataSetInfo().GetListOfVariables();
179 std::vector<Float_t> importances(nbits);
180 for (
UInt_t i = 0; i < nbits; i++)importances[i] = 0;
186 std::bitset<NBITS> xbitset(x);
187 if (x == 0)
Log()<<
kFATAL<<
"Error: need at least one variable.";
194 for (
UInt_t index = 0; index < nbits; index++){
195 if (xbitset[index]) seeddl->
AddVariable(varNames[index],
'F');
202 fClassifier->BookMethod(seeddl, methodName, methodTitle, methodOptions);
210 SROC =
fClassifier->GetROCIntegral(xbitset.to_string(), methodTitle);
216 for (uint32_t i = 0; i <
NBITS; ++i) {
219 std::bitset<NBITS> ybitset(y);
225 importances[
ny] = SROC - 0.5;
232 for (
UInt_t index = 0; index < nbits; index++) {
233 if (ybitset[index]) subseeddl->
AddVariable(varNames[index],
'F');
240 fClassifier->BookMethod(subseeddl, methodName, methodTitle, methodOptions);
248 SSROC =
fClassifier->GetROCIntegral(ybitset.to_string(), methodTitle);
249 importances[
ny] += SROC - SSROC;
257 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
259 for(
UInt_t i=0;i<nbits;i++){
281 std::vector<TString> varNames =
fDataLoader->GetDefaultDataSetInfo().GetListOfVariables();
286 std::vector<Float_t> importances(nbits);
289 for (
UInt_t i = 0; i < nbits; i++)importances[i] = 0;
296 x = rangen -> Integer(range);
298 std::bitset<NBITS> xbitset(x);
299 if (x == 0)
continue;
306 for (
UInt_t index = 0; index < nbits; index++) {
307 if (xbitset[index]) seeddl->
AddVariable(varNames[index],
'F');
314 fClassifier->BookMethod(seeddl, methodName, methodTitle, methodOptions);
322 SROC =
fClassifier->GetROCIntegral(xbitset.to_string(), methodTitle);
328 for (uint32_t i = 0; i < 32; ++i) {
331 std::bitset<NBITS> ybitset(y);
337 importances[
ny] = SROC - 0.5;
338 importances_norm += importances[
ny];
345 for (
UInt_t index = 0; index < nbits; index++) {
346 if (ybitset[index]) subseeddl->
AddVariable(varNames[index],
'F');
353 fClassifier->BookMethod(subseeddl, methodName, methodTitle, methodOptions);
361 SSROC =
fClassifier->GetROCIntegral(ybitset.to_string(), methodTitle);
362 importances[
ny] += SROC - SSROC;
372 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
374 for(
UInt_t i=0;i<nbits;i++){
398 std::vector<TString> varNames =
fDataLoader->GetDefaultDataSetInfo().GetListOfVariables();
403 std::vector<Float_t> importances(nbits);
406 std::vector<Float_t> ROC(range);
408 for (
UInt_t i = 0; i < nbits; i++) importances[i] = 0;
411 for ( x = 1; x <range ; x++) {
413 std::bitset<NBITS> xbitset(x);
414 if (x == 0)
continue;
420 for (
UInt_t index = 0; index < nbits; index++) {
421 if (xbitset[index]) seeddl->
AddVariable(varNames[index],
'F');
429 fClassifier->BookMethod(seeddl, methodName, methodTitle, methodOptions);
437 ROC[
x] =
fClassifier->GetROCIntegral(xbitset.to_string(), methodTitle);
445 for ( x = 0; x <range ; x++)
448 for (uint32_t i = 0; i <
NBITS; ++i) {
451 std::bitset<NBITS> ybitset(y);
455 importances[
ny] = SROC - 0.5;
461 importances[
ny] += SROC - SSROC;
467 for (
UInt_t i = 0; i < nbits; i++) normalization += importances[i];
469 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 implmented 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)
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"...
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)
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)
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