34void TMVAMulticlass( TString myMethodList =
"" )
51 std::map<std::string,int> Use;
59 std::cout << std::endl;
60 std::cout <<
"==> Start TMVAMulticlass" << std::endl;
62 if (myMethodList !=
"") {
63 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
66 for (
UInt_t i=0; i<mlist.size(); i++) {
67 std::string regMethod(mlist[i]);
69 if (Use.find(regMethod) == Use.end()) {
70 std::cout <<
"Method \"" << regMethod <<
"\" not known in TMVA under this name. Choose among the following:" << std::endl;
71 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first <<
" ";
72 std::cout << std::endl;
80 TString outfileName =
"TMVAMulticlass.root";
81 TFile* outputFile =
TFile::Open( outfileName,
"RECREATE" );
84 "!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=multiclass" );
88 dataloader->AddVariable(
"var2",
"Variable 2",
"",
'F' );
89 dataloader->AddVariable(
"var3",
"Variable 3",
"units",
'F' );
90 dataloader->AddVariable(
"var4",
"Variable 4",
"units",
'F' );
93 TString fname =
"./tmva_example_multiple_background.root";
96 std::cout <<
"--- TMVAMulticlass : Accessing " << fname << std::endl;
100 std::cout <<
"Creating testdata...." << std::endl;
103 gROOT->ProcessLine(
"create_MultipleBackground(2000)");
104 std::cout <<
" created tmva_example_multiple_background.root for tests of the multiclass features"<<std::endl;
108 std::cout <<
"ERROR: could not open data file" << std::endl;
112 TTree *signalTree = (TTree*)input->Get(
"TreeS");
117 gROOT->cd( outfileName+TString(
":/") );
123 dataloader->PrepareTrainingAndTestTree(
"",
"SplitMode=Random:NormMode=NumEvents:!V" );
126 factory->BookMethod(
dataloader,
TMVA::Types::kBDT,
"BDTG",
"!H:!V:NTrees=1000:BoostType=Grad:Shrinkage=0.10:UseBaggedBoost:BaggedSampleFraction=0.50:nCuts=20:MaxDepth=2");
130 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" );
134 if (Use[
"DNN_CPU"]) {
135 TString layoutString(
"Layout=TANH|100,TANH|50,TANH|10,LINEAR");
136 TString training0(
"LearningRate=1e-1, Momentum=0.5, Repetitions=1, ConvergenceSteps=10,"
137 " BatchSize=256, TestRepetitions=10, Multithreading=True");
138 TString training1(
"LearningRate=1e-2, Momentum=0.0, Repetitions=1, ConvergenceSteps=10,"
139 " BatchSize=256, TestRepetitions=7, Multithreading=True");
140 TString trainingStrategyString(
"TrainingStrategy=");
141 trainingStrategyString += training0 +
"|" + training1;
142 TString nnOptions(
"!H:V:ErrorStrategy=CROSSENTROPY:VarTransform=N:"
143 "WeightInitialization=XAVIERUNIFORM:Architecture=CPU");
144 nnOptions.Append(
":");
145 nnOptions.Append(layoutString);
146 nnOptions.Append(
":");
147 nnOptions.Append(trainingStrategyString);
165 std::cout <<
"==> Wrote root file: " << outputFile->GetName() << std::endl;
166 std::cout <<
"==> TMVAMulticlass is done!" << std::endl;
177int main(
int argc,
char** argv )
181 for (
int i=1; i<argc; i++) {
182 TString regMethod(argv[i]);
183 if(regMethod==
"-b" || regMethod==
"--batch")
continue;
184 if (!methodList.IsNull()) methodList += TString(
",");
185 methodList += regMethod;
187 TMVAMulticlass(methodList);
R__EXTERN TSystem * gSystem
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose, Int_t netopt=0)
Create / open a file.
This is the main MVA steering class.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
int main(int argc, char **argv)
Abstract ClassifierFactory template that handles arbitrary types.
void TMVAMultiClassGui(const char *fName="TMVAMulticlass.root", TString dataset="")