24 TString outfileName(
"TMVA.root");
28 "!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=Classification");
30 factory->AddVariable(
"myvar1 := var1+var2",
'F');
31 factory->AddVariable(
"myvar2 := var1-var2",
"Expression 2",
"",
'F');
32 factory->AddVariable(
"var3",
"Variable 3",
"units",
'F');
33 factory->AddVariable(
"var4",
"Variable 4",
"units",
'F');
34 factory->AddSpectator(
"spec1 := var1*2",
"Spectator 1",
"units",
'F');
35 factory->AddSpectator(
"spec2 := var1*3",
"Spectator 2",
"units",
'F');
38 TString fname =
"./tmva_class_example.root";
44 input =
TFile::Open(
"http://root.cern.ch/files/tmva_class_example.root",
"CACHEREAD");
47 std::cout <<
"ERROR: could not open data file" << std::endl;
51 std::cout <<
"--- TMVAClassification : Using input file: " << input->
GetName() << std::endl;
63 factory->AddSignalTree(tsignal, signalWeight);
64 factory->AddBackgroundTree(tbackground, backgroundWeight);
68 factory->SetBackgroundWeightExpression(
"weight");
76 factory->PrepareTrainingAndTestTree(mycuts, mycutb,
77 "nTrain_Signal=0:nTrain_Background=0:nTest_Signal=0:nTest_Background=0:SplitMode=Random:NormMode=NumEvents:!V");
87 "!V:NEstimators=150:Criterion=gini:MaxFeatures=auto:MaxDepth=3:MinSamplesLeaf=1:MinWeightFractionLeaf=0:Bootstrap=kTRUE");
89 "!V:BaseEstimator=None:NEstimators=100:LearningRate=1:Algorithm=SAMME.R:RandomState=None");
91 "!V:NEstimators=150:Loss=deviance:LearningRate=0.1:Subsample=1:MaxDepth=6:MaxFeatures='auto'");
107 std::cout <<
"==> Wrote root file: " << outputFile->
GetName() << std::endl;
108 std::cout <<
"==> TMVAClassification is done!" << std::endl;
virtual const char * GetName() const
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.
MethodBase * BookMethod(DataLoader *loader, TString theMethodName, TString methodTitle, TString theOption="")
Book a classifier or regression method.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
void TrainAllMethods()
Iterates through all booked methods and calls training.
static void PyInitialize()
Initialize Python interpreter.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
A specialized string object used for TTree selections.
R__EXTERN TSystem * gSystem
void EvaluateAllMethods(void)
Iterates over all MVAs that have been booked, and calls their evaluation methods. ...
This is the main MVA steering class.
static Bool_t SetCacheFileDir(const char *cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
A TTree object has a header with a name and a title.
virtual void Close(Option_t *option="")
Close a file.