45 std::map<std::string,int> Use;
52 std::cout << std::endl;
53 std::cout <<
"==> Start TMVAMulticlass" << std::endl;
55 if (myMethodList !=
"") {
56 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
59 for (
UInt_t i=0; i<mlist.size(); i++) {
60 std::string regMethod(mlist[i]);
62 if (Use.find(regMethod) == Use.end()) {
63 std::cout <<
"Method \"" << regMethod <<
"\" not known in TMVA under this name. Choose among the following:" << std::endl;
64 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first <<
" ";
65 std::cout << std::endl;
73 TString outfileName =
"TMVAMulticlass.root";
74 TFile* outputFile =
TFile::Open( outfileName,
"RECREATE" );
77 "!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=multiclass" );
79 factory->
AddVariable(
"var2",
"Variable 2",
"",
'F' );
80 factory->
AddVariable(
"var3",
"Variable 3",
"units",
'F' );
81 factory->
AddVariable(
"var4",
"Variable 4",
"units",
'F' );
84 TString fname =
"./tmva_example_multiple_background.root";
87 std::cout <<
"--- TMVAMulticlass : Accessing " << fname << std::endl;
91 std::cout <<
"Creating testdata...." << std::endl;
92 gROOT->ProcessLine(
".L createData.C");
93 gROOT->ProcessLine(
"create_MultipleBackground(2000)");
94 std::cout <<
" created tmva_example_multiple_background.root for tests of the multiclass features"<<std::endl;
98 std::cout <<
"ERROR: could not open data file" << std::endl;
103 TTree *background0 = (
TTree*)input->Get(
"TreeB0");
104 TTree *background1 = (
TTree*)input->Get(
"TreeB1");
105 TTree *background2 = (
TTree*)input->Get(
"TreeB2");
108 factory->
AddTree (signal,
"Signal");
109 factory->
AddTree (background0,
"bg0");
110 factory->
AddTree (background1,
"bg1");
111 factory->
AddTree (background2,
"bg2");
116 factory->
BookMethod(
TMVA::Types::kBDT,
"BDTG",
"!H:!V:NTrees=1000:BoostType=Grad:Shrinkage=0.10:UseBaggedBoost:BaggedSampleFraction=0.50:nCuts=20:MaxDepth=2");
118 factory->
BookMethod(
TMVA::Types::kMLP,
"MLP",
"!H:!V:NeuronType=tanh:NCycles=1000:HiddenLayers=N+5,5:TestRate=5:EstimatorType=MSE");
120 factory->
BookMethod(
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" );
122 factory->
BookMethod(
TMVA::Types::kPDEFoam,
"PDEFoam",
"!H:!V:TailCut=0.001:VolFrac=0.0666:nActiveCells=500:nSampl=2000:nBin=5:Nmin=100:Kernel=None:Compress=T" );
138 std::cout <<
"==> Wrote root file: " << outputFile->GetName() << std::endl;
139 std::cout <<
"==> TMVAClassification is done!" << std::endl;
149 int main(
int argc,
char** argv )
153 for (
int i=1; i<argc; i++) {
155 if(regMethod==
"-b" || regMethod==
"--batch")
continue;
157 methodList += regMethod;
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
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
void TrainAllMethods()
iterates through all booked methods and calls training
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
void TMVAMultiClassGui(const char *fName="TMVAMulticlass.root")
void TMVAMulticlass(TString myMethodList="")
int main(int argc, char **argv)
R__EXTERN TSystem * gSystem
MethodBase * BookMethod(TString theMethodName, TString methodTitle, TString theOption="")
Book a classifier or regression method.
void EvaluateAllMethods(void)
iterates over all MVAs that have been booked, and calls their evaluation methods
void AddTree(TTree *tree, const TString &className, Double_t weight=1.0, const TCut &cut="", Types::ETreeType tt=Types::kMaxTreeType)
A TTree object has a header with a name and a title.
void PrepareTrainingAndTestTree(const TCut &cut, const TString &splitOpt)
prepare the training and test trees -> same cuts for signal and background