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
0.0165810585022
92.8736460209
Processing /mnt/build/workspace/root-makedoc-v614/rootspi/rdoc/src/v6-14-00-patches/tutorials/tmva/TMVACrossValidationApplication.C...
Weightfile for method BDTG not found. Did you run TMVACrossValidation with a specified splitExpr?
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
{
for (
Int_t n = 0; n < nPoints; ++
n) {
x = rng.
Gaus(offset, scale);
y = rng.
Gaus(offset, scale);
++eventID;
}
}
int TMVACrossValidationApplication()
{
TString jobname(
"TMVACrossEvaluation");
{
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);
}
}
{
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(
"eventID", &eventID,
"eventID/I");
fillTree(tree, 1000, 1.0, 1.0, 100);
fillTree(tree, 1000, -1.0, 1.0, 101);
TH1F histBDTG{
"BDTG",
"BDTG", nbin, -1, 1};
TH1F histFisher{
"Fisher",
"Fisher", nbin, -1, 1};
histBDTG.Fill(valBDTG);
histFisher.Fill(valFisher);
}
{
TFile *target =
new TFile(
"TMVACrossEvaluationApp.root",
"RECREATE");
histBDTG.Write();
histFisher.Write();
delete target;
}
return 0;
}
int main(
int argc,
char **argv)
{
TMVACrossValidationApplication();
}
- Author
- Kim Albertsson (adapted from code originally by Andreas Hoecker)
Definition in file TMVACrossValidationApplication.C.