36 return fROCCurves.get();
42 for(
auto &roc:fROCs) avg+=roc.second;
43 return avg/fROCs.size();
51 for(
auto &roc:fROCs) std+=
TMath::Power(roc.second-avg, 2);
63 fLogger <<
kINFO <<
Form(
"Fold %i ROC-Int : %.4f",item.first,item.second) << std::endl;
65 fLogger <<
kINFO <<
"------------------------" <<
Endl;
66 fLogger <<
kINFO <<
Form(
"Average ROC-Int : %.4f",GetROCAverage()) <<
Endl;
67 fLogger <<
kINFO <<
Form(
"Std-Dev ROC-Int : %.4f",GetROCStandardDeviation()) <<
Endl;
75 fROCCurves->
Draw(
"AL");
76 fROCCurves->GetXaxis()->SetTitle(
" Signal Efficiency ");
77 fROCCurves->GetYaxis()->SetTitle(
" Background Rejection ");
78 Float_t adjust=1+fROCs.size()*0.01;
80 c->
SetTitle(
"Cross Validation ROC Curves");
86 fNumFolds(5),fClassifier(new TMVA::
Factory(
"CrossValidation",
"!V:!ROC:Silent:!ModelPersistence:!Color:!DrawProgressBar:AnalysisType=Classification"))
99 fDataLoader->MakeKFoldDataSet(fNumFolds);
107 TString methodOptions = fMethod.GetValue<
TString>(
"MethodOptions");
108 if(methodName ==
"")
Log() <<
kFATAL <<
"No method booked for cross-validation" <<
Endl;
112 Log() <<
kINFO <<
"Evaluate method: " << methodTitle <<
Endl;
117 fDataLoader->MakeKFoldDataSet(fNumFolds);
122 for(
UInt_t i=0; i<fNumFolds; ++i){
123 Log() <<
kDEBUG <<
"Fold (" << methodTitle <<
"): " << i <<
Endl;
125 TString foldTitle = methodTitle;
126 foldTitle +=
"_fold";
130 MethodBase* smethod = fClassifier->BookMethod(fDataLoader.get(), methodName, methodTitle, methodOptions);
142 fResults.fROCs[i] = fClassifier->GetROCIntegral(fDataLoader->GetName(),methodTitle);
144 TGraph*
gr = fClassifier->GetROCCurve(fDataLoader->GetName(), methodTitle,
true);
148 fResults.fROCCurves->Add(gr);
165 fClassifier->DeleteAllMethods();
166 fClassifier->fMethodsMap.clear();
175 if(fResults.fROCs.size()==0)
Log() <<
kFATAL <<
"No cross-validation results available" <<
Endl;
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
MsgLogger & Endl(MsgLogger &ml)
void AddOutput(Types::ETreeType type, Types::EAnalysisType analysisType)
void SetTitle(const char *title="")
Set canvas title.
TCanvas * Draw(const TString name="CrossValidation") const
Float_t GetROCAverage() const
const CrossValidationResult & GetResults() const
Float_t GetROCStandardDeviation() const
A TMultiGraph is a collection of TGraph (or derived) objects.
virtual void SetTitle(const char *title="")
Set graph title.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
const TString & GetMethodName() const
const char * Data() const
Types::EAnalysisType GetAnalysisType() const
static void SetIsTraining(Bool_t)
when this static function is called, it sets the flag whether events with negative event weight shoul...
void SetNumFolds(UInt_t i)
Base class for all machine learning algorithms.
virtual Double_t GetEfficiency(const TString &, Types::ETreeType, Double_t &err)
fill background efficiency (resp.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
void DeleteResults(const TString &, Types::ETreeType type, Types::EAnalysisType analysistype)
delete the results stored for this particulary Method instance (here appareantly called resultsName i...
char * Form(const char *fmt,...)
virtual Double_t GetSignificance() const
compute significance of mean difference significance = |<S> - |/Sqrt(RMS_S2 + RMS_B2) ...
CrossValidation(DataLoader *loader)
virtual void Evaluate()
Virtual method to be implmented with your algorithm.
TMultiGraph * GetROCCurves(Bool_t fLegend=kTRUE)
virtual void Draw(Option_t *option="")
Draw a canvas.
virtual Double_t GetSeparation(TH1 *, TH1 *) const
compute "separation" defined as <s2> = (1/2) Int_-oo..+oo { (S(x) - B(x))^2/(S(x) + B(x)) dx } ...
std::map< UInt_t, Float_t > fROCs
A Graph is a graphics object made of two arrays X and Y with npoints each.
virtual Double_t GetTrainingEfficiency(const TString &)
virtual TLegend * BuildLegend(Double_t x1=0.5, Double_t y1=0.67, Double_t x2=0.88, Double_t y2=0.88, const char *title="", Option_t *option="")
Build a legend from the graphical objects in the pad.
Double_t Sqrt(Double_t x)
static void EnableOutput()
virtual void TestClassification()
initialization
std::shared_ptr< TMultiGraph > fROCCurves