42 fSigs.resize(numFolds);
43 fSeps.resize(numFolds);
99 for(
auto &roc:
fROCs) avg+=roc.second;
100 return avg/fROCs.size();
120 fLogger << kHEADER <<
" ==== Results ====" <<
Endl;
121 for(
auto &item:
fROCs)
122 fLogger << kINFO <<
Form(
"Fold %i ROC-Int : %.4f",item.first,item.second) << std::endl;
124 fLogger << kINFO <<
"------------------------" <<
Endl;
136 fROCCurves->GetXaxis()->SetTitle(
" Signal Efficiency ");
137 fROCCurves->GetYaxis()->SetTitle(
" Background Rejection ");
140 c->
SetTitle(
"Cross Validation ROC Curves");
182 :
TMVA::
Envelope(jobName, dataloader, nullptr, options),
183 fAnalysisType(
Types::kMaxAnalysisType),
184 fAnalysisTypeStr(
"auto"),
186 fCvFactoryOptions(
""),
193 fOutputFactoryOptions(
""),
194 fOutputFile(outputFile),
196 fSplitExprString(
""),
198 fTransformations(
""),
227 "Batch mode: boolean silent flag inhibiting any output from TMVA after the creation of the factory " 228 "class object (default: False)");
236 "List of transformations to test; formatting example: \"Transformations=I;D;P;U;G,D\", for " 237 "identity, decorrelation, PCA, Uniform and Gaussianisation followed by decorrelation " 246 "Set the analysis type (Classification, Regression, Multiclass, Auto) (default: Auto)");
256 "Determines how many processes to use for evaluation. 1 means no" 257 " parallelisation. 2 means use 2 processes. 0 means figure out the" 258 " number automatically based on the number of cpus available. Default" 262 "If given a TMVA output file will be generated for each fold. Filename will be the same as " 263 "specifed for the combined output with a _foldX suffix. (default: false)");
266 "Combines output from contained methods. If None, no combination is performed. (default None)");
304 fOutputFactoryOptions +=
"!DrawProgressBar:";
314 fOutputFactoryOptions +=
"Correlations:";
317 fOutputFactoryOptions +=
"!Correlations:";
322 fOutputFactoryOptions +=
"ROC:";
325 fOutputFactoryOptions +=
"!ROC:";
330 fOutputFactoryOptions +=
Form(
"Silent:");
333 fCvFactoryOptions +=
"!Correlations:!ROC:!Color:!DrawProgressBar:Silent";
337 Log() << kFATAL <<
"No output file given, cannot generate per fold output." <<
Endl;
396 Log() << kDEBUG <<
"Fold (" << methodTitle <<
"): " << iFold <<
Endl;
399 TString foldTitle = methodTitle;
400 foldTitle +=
"_fold";
401 foldTitle += iFold + 1;
404 TFile *foldOutputFile =
nullptr;
408 std::cout <<
"PATH: " << path << std::endl;
455 foldOutputFile->
Close();
490 if (methodTypeName ==
"") {
491 Log() << kFATAL <<
"No method booked for cross-validation" <<
Endl;
495 Log() << kINFO <<
"Evaluate method: " << methodTitle <<
Endl;
506 result.Fill(fold_result);
510 std::vector<CrossValidationFoldResult> result_vector;
512 auto workItem = [
this, iMethod](
UInt_t iFold) {
518 for (
auto && fold_result : result_vector) {
519 result.Fill(fold_result);
527 Form(
"SplitExpr=%s:NumFolds=%i" 528 ":EncapsulatedMethodName=%s" 529 ":EncapsulatedMethodTypeName=%s" 530 ":OutputEnsembling=%s",
555 fFactory->WriteDataInformation(method->fDataSetInfo);
569 Log() << kINFO <<
"Evaluation done." <<
Endl;
576 Log() << kFATAL <<
"No cross-validation results available" <<
Endl;
std::vector< Double_t > fSigs
virtual const char * GetName() const
Returns name of object.
Float_t GetROCAverage() const
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
TFile * fOutputFile
How to combine output of individual folds.
MsgLogger & Endl(MsgLogger &ml)
Singleton class for Global types used by TMVA.
Bool_t fFoldStatus
If true: generate output file for each fold.
std::unique_ptr< CvSplitKFolds > fSplit
void SetTitle(const char *title="")
Set canvas title.
std::map< UInt_t, Float_t > fROCs
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
A TMultiGraph is a collection of TGraph (or derived) objects.
Virtual base Class for all MVA method.
Class to save the results of cross validation, the metric for the classification ins ROC and you can ...
void ToLower()
Change string to lower-case.
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
virtual void SetTitle(const char *title="")
Set graph title.
Types::EAnalysisType fAnalysisType
TString fOutputEnsembling
UInt_t GetNumWorkers() const
std::vector< Double_t > fEff10s
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
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 void SetIsTraining(Bool_t)
when this static function is called, it sets the flag whether events with negative event weight shoul...
std::vector< CrossValidationResult > fResults
void SetNumFolds(UInt_t i)
Abstract base class for all high level ml algorithms, you can book ml methods like BDT...
std::vector< Double_t > fTrainEff01s
UInt_t fNumWorkerProcs
Number of folds to prepare.
std::vector< Double_t > fTrainEff10s
virtual Double_t GetEfficiency(const TString &, Types::ETreeType, Double_t &err)
fill background efficiency (resp.
TString fCvFactoryOptions
void Fill(CrossValidationFoldResult const &fr)
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void ParseOptions()
Method to parse the internal option string.
This class provides a simple interface to execute the same task multiple times in parallel...
R__EXTERN TSystem * gSystem
std::vector< Double_t > fEff01s
char * Form(const char *fmt,...)
Float_t GetROCStandardDeviation() const
const std::vector< CrossValidationResult > & GetResults() const
This is the main MVA steering class.
std::vector< Double_t > fTrainEff30s
virtual Double_t GetSignificance() const
compute significance of mean difference
void Evaluate()
Does training, test set evaluation and performance evaluation of using cross-evalution.
void DeleteAllResults(Types::ETreeType type, Types::EAnalysisType analysistype)
Deletes all results currently in the dataset.
void ParseOptions()
Method to parse the internal option string.
std::unique_ptr< Factory > fFoldFactory
virtual Double_t GetSeparation(TH1 *, TH1 *) const
compute "separation" defined as
A pseudo container class which is a generator of indices.
Class to perform cross validation, splitting the dataloader into folds.
CrossValidationFoldResult ProcessFold(UInt_t iFold, UInt_t iMethod)
Evaluates each fold in turn.
std::unique_ptr< Factory > fFactory
std::shared_ptr< DataLoader > fDataLoader
Booked method information.
void AddPreDefVal(const T &)
TMultiGraph * GetROCCurves(Bool_t fLegend=kTRUE)
ostringstream derivative to redirect and format output
void SetSplitExpr(TString splitExpr)
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Interface for all concrete MVA method implementations.
std::vector< Double_t > fEffAreas
virtual void Draw(Option_t *option="")
Draw a canvas.
CrossValidationResult(UInt_t numFolds)
std::vector< Double_t > fSeps
Abstract ClassifierFactory template that handles arbitrary types.
virtual TLegend * BuildLegend(Double_t x1=0.3, Double_t y1=0.21, Double_t x2=0.3, Double_t y2=0.21, const char *title="", Option_t *option="")
Build a legend from the graphical objects in the pad.
auto Map(F func, unsigned nTimes) -> std::vector< typename std::result_of< F()>::type >
Execute func (with no arguments) nTimes in parallel.
A Graph is a graphics object made of two arrays X and Y with npoints each.
TCanvas * Draw(const TString name="CrossValidation") const
std::vector< Double_t > fEff30s
virtual Double_t GetTrainingEfficiency(const TString &)
TString()
TString default ctor.
Types::EAnalysisType GetAnalysisType() const
Double_t Sqrt(Double_t x)
static void EnableOutput()
std::map< const TMVA::Event *, UInt_t > fEventToFoldMapping
void CheckForUnusedOptions() const
checks for unused options in option string
CrossValidation(TString jobName, TMVA::DataLoader *dataloader, TString options)
std::shared_ptr< TMultiGraph > fROCCurves
std::vector< OptionMap > fMethods
TString fJobName
If true: dataset is prepared.
TString fOutputFactoryOptions
Number of processes to use for fold evaluation.
virtual void Close(Option_t *option="")
Close a file.
const char * Data() const