34 void TMVAMulticlass(
TString myMethodList =
"" )
51 std::map<std::string,int> Use;
58 std::cout << std::endl;
59 std::cout <<
"==> Start TMVAMulticlass" << std::endl;
61 if (myMethodList !=
"") {
62 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
65 for (
UInt_t i=0; i<mlist.size(); i++) {
66 std::string regMethod(mlist[i]);
68 if (Use.find(regMethod) == Use.end()) {
69 std::cout <<
"Method \"" << regMethod <<
"\" not known in TMVA under this name. Choose among the following:" << std::endl;
70 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first <<
" ";
71 std::cout << std::endl;
79 TString outfileName =
"TMVAMulticlass.root";
83 "!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=multiclass" );
87 dataloader->
AddVariable(
"var2",
"Variable 2",
"",
'F' );
88 dataloader->
AddVariable(
"var3",
"Variable 3",
"units",
'F' );
89 dataloader->
AddVariable(
"var4",
"Variable 4",
"units",
'F' );
92 TString fname =
"./tmva_example_multiple_background.root";
95 std::cout <<
"--- TMVAMulticlass : Accessing " << fname << std::endl;
99 std::cout <<
"Creating testdata...." << std::endl;
102 gROOT->ProcessLine(
"create_MultipleBackground(2000)");
103 std::cout <<
" created tmva_example_multiple_background.root for tests of the multiclass features"<<std::endl;
107 std::cout <<
"ERROR: could not open data file" << std::endl;
111 TTree *signalTree = (
TTree*)input->Get(
"TreeS");
112 TTree *background0 = (
TTree*)input->Get(
"TreeB0");
113 TTree *background1 = (
TTree*)input->Get(
"TreeB1");
114 TTree *background2 = (
TTree*)input->Get(
"TreeB2");
117 dataloader->
AddTree (signalTree,
"Signal");
118 dataloader->
AddTree (background0,
"bg0");
119 dataloader->
AddTree (background1,
"bg1");
120 dataloader->
AddTree (background2,
"bg2");
125 factory->
BookMethod( dataloader,
TMVA::Types::kBDT,
"BDTG",
"!H:!V:NTrees=1000:BoostType=Grad:Shrinkage=0.10:UseBaggedBoost:BaggedSampleFraction=0.50:nCuts=20:MaxDepth=2");
127 factory->
BookMethod( dataloader,
TMVA::Types::kMLP,
"MLP",
"!H:!V:NeuronType=tanh:NCycles=1000:HiddenLayers=N+5,5:TestRate=5:EstimatorType=MSE");
129 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" );
131 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" );
147 std::cout <<
"==> Wrote root file: " << outputFile->
GetName() << std::endl;
148 std::cout <<
"==> TMVAClassification is done!" << std::endl;
159 int main(
int argc,
char** argv )
163 for (
int i=1; i<argc; i++) {
165 if(regMethod==
"-b" || regMethod==
"--batch")
continue;
167 methodList += regMethod;
169 TMVAMulticlass(methodList);
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
MethodBase * BookMethod(DataLoader *loader, TString theMethodName, TString methodTitle, TString theOption="")
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
void TrainAllMethods()
iterates through all booked methods and calls training
void AddVariable(const TString &expression, const TString &title, const TString &unit, char type='F', Double_t min=0, Double_t max=0)
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
const char * Data() const
void TMVAMultiClassGui(const char *fName="TMVAMulticlass.root", TString dataset="")
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
R__EXTERN TSystem * gSystem
void EvaluateAllMethods(void)
iterates over all MVAs that have been booked, and calls their evaluation methods
virtual const char * GetName() const
Returns name of object.
void AddTree(TTree *tree, const TString &className, Double_t weight=1.0, const TCut &cut="", Types::ETreeType tt=Types::kMaxTreeType)
void PrepareTrainingAndTestTree(const TCut &cut, const TString &splitOpt)
Abstract ClassifierFactory template that handles arbitrary types.
A TTree object has a header with a name and a title.
int main(int argc, char **argv)
virtual void Close(Option_t *option="")
Close a file.