This macro provides an example of how to use TMVA for k-folds cross evaluation in application. 
This requires that CrossValidation was run with a deterministic split, such as "...:splitExpr=int([eventID])%int([numFolds]):...".
- Project : TMVA - a ROOT-integrated toolkit for multivariate data analysis
 
- Package : TMVA
 
- Root Macro: TMVACrossValidationApplication
 
 
                         : Booking "BDTG" of type "CrossValidation" from datasetcv/weights/TMVACrossValidation_BDTG.weights.xml.
                         : Reading weight file: datasetcv/weights/TMVACrossValidation_BDTG.weights.xml
<HEADER> DataSetInfo              : [Default] : Added class "Signal"
<HEADER> DataSetInfo              : [Default] : Added class "Background"
                         : Reading weightfile: datasetcv/weights/TMVACrossValidation_BDTG_fold1.weights.xml
                         : Reading weight file: datasetcv/weights/TMVACrossValidation_BDTG_fold1.weights.xml
                         : Reading weightfile: datasetcv/weights/TMVACrossValidation_BDTG_fold2.weights.xml
                         : Reading weight file: datasetcv/weights/TMVACrossValidation_BDTG_fold2.weights.xml
                         : Booked classifier "BDTG" of type: "CrossValidation"
                         : Booking "Fisher" of type "CrossValidation" from datasetcv/weights/TMVACrossValidation_Fisher.weights.xml.
                         : Reading weight file: datasetcv/weights/TMVACrossValidation_Fisher.weights.xml
                         : Reading weightfile: datasetcv/weights/TMVACrossValidation_Fisher_fold1.weights.xml
                         : Reading weight file: datasetcv/weights/TMVACrossValidation_Fisher_fold1.weights.xml
                         : Reading weightfile: datasetcv/weights/TMVACrossValidation_Fisher_fold2.weights.xml
                         : Reading weight file: datasetcv/weights/TMVACrossValidation_Fisher_fold2.weights.xml
                         : Booked classifier "Fisher" of type: "CrossValidation"
                         : Rebuilding Dataset Default
(int) 0
   
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
 
 
 
{
 
   tree->SetBranchAddress(
"x", &
x);
 
   tree->SetBranchAddress(
"y", &
y);
 
   tree->SetBranchAddress(
"eventID", &eventID);
 
 
 
      
      
      ++eventID;
 
   }
 
   
   tree->ResetBranchAddresses();
 
}
 
int TMVACrossValidationApplication()
{
   
 
   
 
 
 
   
   TString jobname(
"TMVACrossValidation");
 
   {
      TString weightfile = 
TString(
"datasetcv/weights/") + jobname + 
"_" + methodName + 
TString(
".weights.xml");
 
 
      if (weightfileExists) {
         reader->
BookMVA(methodName, weightfile);
 
      } else {
         std::cout << "Weightfile for method " << methodName << " not found."
                      " Did you run TMVACrossValidation with a specified"
                      " splitExpr?" << std::endl;
         exit(0);
      }
 
   }
   {
      TString weightfile = 
TString(
"datasetcv/weights/") + jobname + 
"_" + methodName + 
TString(
".weights.xml");
 
 
      if (weightfileExists) {
         reader->
BookMVA(methodName, weightfile);
 
      } else {
         std::cout << "Weightfile for method " << methodName << " not found."
                      " Did you run TMVACrossValidation with a specified"
                      " splitExpr?" << std::endl;
         exit(0);
      }
   }
 
   
   tree->Branch(
"x", &
x, 
"x/F");
 
   tree->Branch(
"y", &
y, 
"y/F");
 
   tree->Branch(
"eventID", &eventID, 
"eventID/I");
 
 
   fillTree(
tree, 1000, 1.0, 1.0, 100);
 
   fillTree(
tree, 1000, -1.0, 1.0, 101);
 
   tree->SetBranchAddress(
"x", &
x);
 
   tree->SetBranchAddress(
"y", &
y);
 
   tree->SetBranchAddress(
"eventID", &eventID);
 
 
   
   TH1F histBDTG{
"BDTG", 
"BDTG", nbin, -1, 1};
 
   TH1F histFisher{
"Fisher", 
"Fisher", nbin, -1, 1};
 
 
   
   for (
Long64_t ievt = 0; ievt < 
tree->GetEntries(); ievt++) {
 
 
 
      histBDTG.Fill(valBDTG);
      histFisher.Fill(valFisher);
   }
 
   tree->ResetBranchAddresses();
 
 
      histBDTG.DrawClone();
      histFisher.DrawClone();
   }
   else
   { 
      histBDTG.Write();
      histFisher.Write();
   }
 
   delete reader;
 
   return 0;
}
 
int main(
int argc, 
char **argv)
 
{
   TMVACrossValidationApplication();
}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
 
R__EXTERN TSystem * gSystem
 
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
 
1-D histogram with a float per channel (see TH1 documentation)}
 
The Reader class serves to use the MVAs in a specific analysis context.
 
Double_t EvaluateMVA(const std::vector< Float_t > &, const TString &methodTag, Double_t aux=0)
Evaluate a std::vector<float> of input data for a given method The parameter aux is obligatory for th...
 
IMethod * BookMVA(const TString &methodTag, const TString &weightfile)
read method name from weight file
 
void AddSpectator(const TString &expression, Float_t *)
Add a float spectator or expression to the reader.
 
void AddVariable(const TString &expression, Float_t *)
Add a float variable or expression to the reader.
 
Random number generator class based on M.
 
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.
 
  - Author
 - Kim Albertsson (adapted from code originally by Andreas Hoecker) 
 
Definition in file TMVACrossValidationApplication.C.