34void TMVAMulticlass(
TString myMethodList =
"" )
51 std::map<std::string,int> Use;
66 std::cout << std::endl;
67 std::cout <<
"==> Start TMVAMulticlass" << std::endl;
69 if (myMethodList !=
"") {
70 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
74 std::string regMethod(mlist[
i]);
76 if (Use.find(regMethod) == Use.end()) {
77 std::cout <<
"Method \"" << regMethod <<
"\" not known in TMVA under this name. Choose among the following:" << std::endl;
78 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first <<
" ";
79 std::cout << std::endl;
87 TString outfileName =
"TMVAMulticlass.root";
91 "!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=multiclass" );
95 dataloader->
AddVariable(
"var2",
"Variable 2",
"",
'F' );
96 dataloader->
AddVariable(
"var3",
"Variable 3",
"units",
'F' );
97 dataloader->
AddVariable(
"var4",
"Variable 4",
"units",
'F' );
100 TString fname =
gROOT->GetTutorialDir() +
"/tmva/data/tmva_multiclass_example.root";
101 if (!
gSystem->AccessPathName( fname )) {
105 std::cout <<
"ERROR: could not open data file" << std::endl;
108 std::cout <<
"--- TMVAMulticlass: Using input file: " <<
input->GetName() << std::endl;
116 dataloader->
AddTree (signalTree,
"Signal");
117 dataloader->
AddTree (background0,
"bg0");
118 dataloader->
AddTree (background1,
"bg1");
119 dataloader->
AddTree (background2,
"bg2");
124 factory->
BookMethod( dataloader,
TMVA::Types::kBDT,
"BDTG",
"!H:!V:NTrees=1000:BoostType=Grad:Shrinkage=0.10:UseBaggedBoost:BaggedSampleFraction=0.50:nCuts=20:MaxDepth=2");
126 factory->
BookMethod( dataloader,
TMVA::Types::kMLP,
"MLP",
"!H:!V:NeuronType=tanh:NCycles=1000:HiddenLayers=N+5,5:TestRate=5:EstimatorType=MSE");
128 factory->
BookMethod( dataloader,
TMVA::Types::kFDA,
"FDA_GA",
"H:!V:Formula=(0)+(1)*x0+(2)*x1+(3)*x2+(4)*x3:ParRanges=(-1,1);(-10,10);(-10,10);(-10,10);(-10,10):FitMethod=GA:PopSize=300:Cycles=3:Steps=20:Trim=True:SaveBestGen=1" );
130 factory->
BookMethod( dataloader,
TMVA::Types::kPDEFoam,
"PDEFoam",
"!H:!V:TailCut=0.001:VolFrac=0.0666:nActiveCells=500:nSampl=2000:nBin=5:Nmin=100:Kernel=None:Compress=T" );
134 TString layoutString(
"Layout=TANH|100,TANH|50,TANH|10,LINEAR");
135 TString trainingStrategyString(
"TrainingStrategy=Optimizer=ADAM,LearningRate=1e-3,"
136 "TestRepetitions=1,ConvergenceSteps=10,BatchSize=100,MaxEpochs=20");
137 TString nnOptions(
"!H:V:ErrorStrategy=CROSSENTROPY:VarTransform=N:"
138 "WeightInitialization=XAVIERUNIFORM:Architecture=GPU");
139 nnOptions.Append(
":");
140 nnOptions.Append(layoutString);
141 nnOptions.Append(
":");
142 nnOptions.Append(trainingStrategyString);
146 TString layoutString(
"Layout=TANH|100,TANH|50,TANH|10,LINEAR");
147 TString trainingStrategyString(
"TrainingStrategy=Optimizer=ADAM,LearningRate=1e-3,"
148 "TestRepetitions=1,ConvergenceSteps=10,BatchSize=100,MaxEpochs=20");
149 TString nnOptions(
"!H:V:ErrorStrategy=CROSSENTROPY:VarTransform=N:"
150 "WeightInitialization=XAVIERUNIFORM:Architecture=GPU");
151 nnOptions.Append(
":");
152 nnOptions.Append(layoutString);
153 nnOptions.Append(
":");
154 nnOptions.Append(trainingStrategyString);
173 std::cout <<
"==> Wrote root file: " << outputFile->
GetName() << std::endl;
174 std::cout <<
"==> TMVAMulticlass is done!" << std::endl;
185int main(
int argc,
char** argv )
189 for (
int i=1;
i<argc;
i++) {
191 if(regMethod==
"-b" || regMethod==
"--batch")
continue;
193 methodList += regMethod;
195 TMVAMulticlass(methodList);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
R__EXTERN TSystem * gSystem
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
void Close(Option_t *option="") override
Close a file.
void PrepareTrainingAndTestTree(const TCut &cut, const TString &splitOpt)
prepare the training and test trees -> same cuts for signal and background
void AddTree(TTree *tree, const TString &className, Double_t weight=1.0, const TCut &cut="", Types::ETreeType tt=Types::kMaxTreeType)
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
This is the main MVA steering class.
void TrainAllMethods()
Iterates through all booked methods and calls training.
MethodBase * BookMethod(DataLoader *loader, TString theMethodName, TString methodTitle, TString theOption="")
Book a classifier or regression method.
void TestAllMethods()
Evaluates all booked methods on the testing data and adds the output to the Results in the corresponi...
void EvaluateAllMethods(void)
Iterates over all MVAs that have been booked, and calls their evaluation methods.
const char * GetName() const override
Returns name of object.
A TTree represents a columnar dataset.
create variable transformations
void TMVAMultiClassGui(const char *fName="TMVAMulticlass.root", TString dataset="")