88 data->
Branch(
"eventID", &eventID,
"eventID/I");
90 for (
Int_t n = 0;
n < nPoints; ++
n) {
91 x = rng.Gaus(offset, scale);
92 y = rng.Gaus(offset, scale);
106int TMVACrossValidation(
bool useRandomSplitting =
false)
120 TTree *sigTree = genTree(1000, 1.0, 1.0, 100);
121 TTree *bkgTree = genTree(1000, -1.0, 1.0, 101);
124 TString outfileName(
"TMVA.root");
158 ":nTest_Background=1"
160 ":NormMode=NumEvents"
176 TString analysisType =
"Classification";
178 TString splitType = (useRandomSplitting) ?
"Random" :
"Deterministic";
197 TString splitExpr = (!useRandomSplitting) ?
"int(fabs([eventID]))%int([NumFolds])" :
"";
206 analysisType.
Data(), splitType.
Data(), numFolds,
217 "!H:!V:NTrees=100:MinNodeSize=2.5%:BoostType=Grad"
218 ":NegWeightTreatment=Pray:Shrinkage=0.10:nCuts=20"
222 "!H:!V:Fisher:VarTransform=None");
240 for (
auto && result : cv.GetResults()) {
241 std::cout <<
"Summary for method " << cv.GetMethods()[iMethod++].GetValue<
TString>(
"MethodName")
243 for (
UInt_t iFold = 0; iFold<cv.GetNumFolds(); ++iFold) {
244 std::cout <<
"\tFold " << iFold <<
": "
245 <<
"ROC int: " << result.GetROCValues()[iFold]
247 <<
"BkgEff@SigEff=0.3: " << result.GetEff30Values()[iFold]
259 std::cout <<
"==> Wrote root file: " << outputFile->
GetName() << std::endl;
260 std::cout <<
"==> TMVACrossValidation is done!" << std::endl;
267 if (!
gROOT->IsBatch()) {
269 cv.GetResults()[0].DrawAvgROCCurve(
kTRUE,
"Avg ROC for BDTG");
270 cv.GetResults()[0].DrawAvgROCCurve(
kTRUE,
"Avg ROC for Fisher");
283int main(
int argc,
char **argv)
285 TMVACrossValidation();
char * Form(const char *fmt,...)
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
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.
Class to perform cross validation, splitting the dataloader into folds.
void AddSignalTree(TTree *signal, Double_t weight=1.0, Types::ETreeType treetype=Types::kMaxTreeType)
number of signal events (used to compute significance)
void AddSpectator(const TString &expression, const TString &title="", const TString &unit="", Double_t min=0, Double_t max=0)
user inserts target in data set info
void PrepareTrainingAndTestTree(const TCut &cut, const TString &splitOpt)
prepare the training and test trees -> same cuts for signal and background
void AddBackgroundTree(TTree *background, Double_t weight=1.0, Types::ETreeType treetype=Types::kMaxTreeType)
number of signal events (used to compute significance)
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
virtual const char * GetName() const
Returns name of object.
Random number generator class based on M.
const char * Data() const
A TTree represents a columnar dataset.
virtual Int_t Fill()
Fill all branches.
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
virtual void ResetBranchAddresses()
Tell all of our branches to drop their current objects and allocate new ones.
void TMVAGui(const char *fName="TMVA.root", TString dataset="")