15 std::cout <<
"Get test data..." << std::endl;
16 TString fname =
"./tmva_example_multiple_background.root";
18 std::cout <<
"Create multiclass test data..." << std::endl;
21 gROOT->ProcessLine(
"create_MultipleBackground(200)");
22 std::cout <<
"Created " << fname <<
" for tests of the multiclass features" << std::endl;
27 std::cout <<
"Setup TMVA..." << std::endl;
29 TFile* outputFile =
TFile::Open(
"ResultsTestPyRandomForestMulticlass.root",
"RECREATE");
31 "!V:Silent:Color:!DrawProgressBar:AnalysisType=multiclass");
40 dataloader->
AddTree(signal,
"Signal");
41 dataloader->
AddTree(background0,
"Background_0");
42 dataloader->
AddTree(background1,
"Background_1");
43 dataloader->
AddTree(background2,
"Background_2");
51 "SplitMode=Random:NormMode=NumEvents:!V");
55 "!H:!V:VarTransform=None:NEstimators=10:Verbose=0");
56 std::cout <<
"Train classifier..." << std::endl;
66 std::cout <<
"Run reader and classify " << numEvents <<
" events..." << std::endl;
73 reader->
BookMVA(
"PyRandomForest",
"datasetTestPyRandomForestMulticlass/weights/testPyRandomForestMulticlass_PyRandomForest.weights.xml");
100 for(
UInt_t i=0; i<numEvents; i++){
110 meanMvaSignal = meanMvaSignal/float(numEvents);
111 meanMvaBackground0 = meanMvaBackground0/float(numEvents);
112 meanMvaBackground1 = meanMvaBackground1/float(numEvents);
113 meanMvaBackground2 = meanMvaBackground2/float(numEvents);
116 std::cout <<
"Mean MVA response on signal: " << meanMvaSignal << std::endl;
117 if(meanMvaSignal < 0.3){
118 std::cout <<
"[ERROR] Mean response on signal is " << meanMvaSignal <<
" (<0.3)" << std::endl;
121 std::cout <<
"Mean MVA response on background 0: " << meanMvaBackground0 << std::endl;
122 if(meanMvaBackground0 < 0.3){
123 std::cout <<
"[ERROR] Mean response on background 0 is " << meanMvaBackground0 <<
" (<0.3)" << std::endl;
126 std::cout <<
"Mean MVA response on background 1: " << meanMvaBackground1 << std::endl;
127 if(meanMvaBackground0 < 0.3){
128 std::cout <<
"[ERROR] Mean response on background 1 is " << meanMvaBackground1 <<
" (<0.3)" << std::endl;
131 std::cout <<
"Mean MVA response on background 2: " << meanMvaBackground2 << std::endl;
132 if(meanMvaBackground0 < 0.3){
133 std::cout <<
"[ERROR] Mean response on background 2 is " << meanMvaBackground2 <<
" (<0.3)" << std::endl;
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.
void AddVariable(const TString &expression, Float_t *)
Add a float variable or expression to the reader.
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.
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
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)
user inserts discriminating variable in data set info
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.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
IMethod * BookMVA(const TString &methodTag, const TString &weightfile)
read method name from weight file
int testPyRandomForestMulticlass()
R__EXTERN TSystem * gSystem
This is the main MVA steering class.
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)
prepare the training and test trees -> same cuts for signal and background
The Reader class serves to use the MVAs in a specific analysis context.
A TTree object has a header with a name and a title.
const std::vector< Float_t > & EvaluateMulticlass(const TString &methodTag, Double_t aux=0)
evaluates MVA for given set of input variables
const char * Data() const