34void TMVAMulticlass(
TString myMethodList =
"" )
47 std::map<std::string,int> Use;
55 std::cout << std::endl;
56 std::cout <<
"==> Start TMVAMulticlass" << std::endl;
58 if (myMethodList !=
"") {
59 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
62 for (
UInt_t i=0; i<mlist.size(); i++) {
63 std::string regMethod(mlist[i]);
65 if (Use.find(regMethod) == Use.end()) {
66 std::cout <<
"Method \"" << regMethod <<
"\" not known in TMVA under this name. Choose among the following:" << std::endl;
67 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) std::cout << it->first <<
" ";
68 std::cout << std::endl;
76 TString outfileName =
"TMVAMulticlass.root";
80 "!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=multiclass" );
84 dataloader->
AddVariable(
"var2",
"Variable 2",
"",
'F' );
85 dataloader->
AddVariable(
"var3",
"Variable 3",
"units",
'F' );
86 dataloader->
AddVariable(
"var4",
"Variable 4",
"units",
'F' );
89 TString fname =
gROOT->GetTutorialDir() +
"/machine_learning/data/tmva_multiclass_example.root";
94 std::cout <<
"ERROR: could not open data file" << std::endl;
97 std::cout <<
"--- TMVAMulticlass: Using input file: " <<
input->GetName() << std::endl;
105 dataloader->
AddTree (signalTree,
"Signal");
106 dataloader->
AddTree (background0,
"bg0");
107 dataloader->
AddTree (background1,
"bg1");
108 dataloader->
AddTree (background2,
"bg2");
113 factory->
BookMethod( dataloader,
TMVA::Types::kBDT,
"BDTG",
"!H:!V:NTrees=1000:BoostType=Grad:Shrinkage=0.10:UseBaggedBoost:BaggedSampleFraction=0.50:nCuts=20:MaxDepth=2");
115 factory->
BookMethod( dataloader,
TMVA::Types::kMLP,
"MLP",
"!H:!V:NeuronType=tanh:NCycles=1000:HiddenLayers=N+5,5:TestRate=5:EstimatorType=MSE");
117 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" );
119 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" );
136 std::cout <<
"==> Wrote root file: " << outputFile->
GetName() << std::endl;
137 std::cout <<
"==> TMVAMulticlass is done!" << std::endl;
148int main(
int argc,
char** argv )
152 for (
int i=1; i<argc; i++) {
154 if(regMethod==
"-b" || regMethod==
"--batch")
continue;
156 methodList += regMethod;
158 TMVAMulticlass(methodList);
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
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.
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.
MethodBase * BookMethod(DataLoader *loader, MethodName theMethodName, TString methodTitle, TString theOption="")
Books an MVA classifier or regression method.
const char * GetName() const override
Returns name of object.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
A TTree represents a columnar dataset.
create variable transformations
void TMVAMultiClassGui(const char *fName="TMVAMulticlass.root", TString dataset="")