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);
102 data->ResetBranchAddresses();
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(
"TMVACV.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");
241 std::cout <<
"Summary for method " << cv.
GetMethods()[iMethod++].GetValue<
TString>(
"MethodName")
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()) {
283int main(
int argc,
char **argv)
285 TMVACrossValidation();
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
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.
const std::vector< CrossValidationResult > & GetResults() const
void Evaluate() override
Does training, test set evaluation and performance evaluation of using cross-evalution.
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 void BookMethod(TString methodname, TString methodtitle, TString options="")
Method to book the machine learning method to perform the algorithm.
std::vector< OptionMap > & GetMethods()
Method get the Booked methods in a option map object.
const char * GetName() const override
Returns name of object.
Random number generator class based on M.
const char * Data() const
A TTree represents a columnar dataset.
void TMVAGui(const char *fName="TMVA.root", TString dataset="")