89 class EfficiencyPlotWrapper {
114 TLegend *newEfficiencyLegend();
142 std::cout <<
"Could not locate directory '" << dataset <<
"/InputVariables_Id' in file: " << fin << std::endl;
160 cout <<
"ups .. no methods found in to plot ROC curve for ... give up" << endl;
164 TIter next(&methods);
168 while ((key = (
TKey *)next())) {
174 TIter nextTitle(&titles);
193 TString classname = hname(index + 1, hname.
Length() - (index + 1));
195 rocCurves.push_back(std::make_tuple(methodTitle, classname, h));
217 for (
auto &item : rocCurves) {
219 TString methodTitle = std::get<0>(item);
220 TString classname = std::get<1>(item);
224 EfficiencyPlotWrapper *plotWrapper = classCanvasMap.at(classname);
225 plotWrapper->addGraph(h);
226 plotWrapper->addLegendEntry(methodTitle, h);
227 }
catch (
const std::out_of_range &oor) {
228 cout <<
Form(
"ERROR: Class %s discovered among plots but was not found by TMVAMulticlassGui. Skipping.",
261 if (plotType != EEfficiencyPlotType::kRejBvsEffS) {
262 std::cout <<
"For multiclass, only rejB vs effS is currently implemented.";
268 if (file ==
nullptr) {
269 std::cout <<
"ERROR: filename \"" << filename_input <<
"\" is not found.";
277 TString graphNameRef =
"_rejBvsS_";
280 for (
auto &classname : classnames) {
282 TString title =
Form(
"ROC Curve %s vs rest", classname.Data());
283 EfficiencyPlotWrapper *plotWrapper =
new EfficiencyPlotWrapper(name, title, dataset, iPlot++);
284 classCanvasMap.emplace(classname.Data(), plotWrapper);
290 for (
auto const &item : classCanvasMap) {
291 auto plotWrapper = item.second;
304 std::cout <<
"--- Running Roc1v1Gui for input file: " << fin << std::endl;
309 TString title =
"1v1 ROC curve comparison";
316 for (
auto &classname : classnames) {
318 Form(
"TMVA::plotEfficienciesMulticlass1vs1(\"%s\", \"%s\", \"%s\")", dataset.
Data(), fin.
Data(),
326 gROOT->SaveContext();
354 TString graphNameRef =
Form(
"_1v1rejBvsS_%s_vs_", baseClassname.
Data());
357 if (file ==
nullptr) {
358 std::cout <<
"ERROR: filename \"" << fin <<
"\" is not found.";
364 for (
auto &classname : classnames) {
366 if (classname == baseClassname) {
371 TString title =
Form(
"ROC Curve %s (Sig) vs %s (Bkg)", baseClassname.
Data(), classname.Data());
372 EfficiencyPlotWrapper *plotWrapper =
new EfficiencyPlotWrapper(name, title, dataset, iPlot++);
373 classCanvasMap.emplace(classname.Data(), plotWrapper);
379 for (
auto const &item : classCanvasMap) {
380 auto plotWrapper = item.second;
401 fy0H = 1 - fy0H + fdyH + 0.07;
408 fCanvas = newEfficiencyCanvas(name, title, i);
409 fLegend = newEfficiencyLegend();
422 if (fColor == 5 || fColor == 10 || fColor == 11) {
441 void EfficiencyPlotWrapper::addLegendEntry(
TString methodTitle,
TGraph *graph)
443 fLegend->AddEntry(graph, methodTitle,
"l");
446 fLegend->SetY2(fy0H + dyH_local);
462 TCanvas *c =
new TCanvas(name, title, 200 + i * 50, 0 + i * 50, 650, 500);
468 TString xtit =
"Signal Efficiency";
469 TString ytit =
"Background Rejection (1 - eff)";
475 TH2F *frame =
new TH2F(
Form(
"%s_%s", title.
Data(),
"frame"), title, 500, x1, x2, 500, y1, y2);
487 TLegend *EfficiencyPlotWrapper::newEfficiencyLegend()
489 TLegend *legend =
new TLegend(fx0L, fy0H - fdyH, fx0L + fdxL, fy0H);
502 void EfficiencyPlotWrapper::save()
504 TString fname = fDataset +
"/plots/" + fCanvas->GetName();
void Show()
Show control bar.
virtual const char * GetName() const
Returns name of object.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
void AddButton(TControlBarButton *button)
Add button.
void imgconv(TCanvas *c, const TString &fname)
A Control Bar is a fully user configurable tool which provides fast access to frequently used operati...
virtual TList * GetListOfKeys() const
void SetTextColor(const char *colorName)
Sets text color for control bar buttons, e.g.
This class displays a legend box (TPaveText) containing several legend entries.
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad...
void efficienciesMulticlass1vsRest(TString dataset, TString filename_input="TMVAMulticlass.root", EEfficiencyPlotType plotType=EEfficiencyPlotType::kRejBvsEffS, Bool_t useTMVAStyle=kTRUE)
TFile * OpenFile(const TString &fin)
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
std::vector< TString > GetClassNames(TDirectory *dir)
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
void SetFrameStyle(TH1 *frame, Float_t scale=1.0)
Short_t Min(Short_t a, Short_t b)
void SetMargin(Float_t margin)
TKey * NextKey(TIter &keyIter, TString className)
static const double x2[5]
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)
void GetMethodTitle(TString &name, TKey *ikey)
std::vector< std::tuple< TString, TString, TGraph * > > roccurvelist_t
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
roccurvelist_t getRocCurves(TDirectory *binDir, TString methodPrefix, TString graphNameRef)
void Initialize(Bool_t useTMVAStyle=kTRUE)
2-D histogram with a float per channel (see TH1 documentation)}
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
char * Form(const char *fmt,...)
virtual TDirectory * GetDirectory(const char *apath, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory named "apath".
void plotEfficienciesMulticlass(roccurvelist_t rocCurves, classcanvasmap_t classCanvasMap)
static constexpr double nm
std::map< TString, EfficiencyPlotWrapper * > classcanvasmap_t
void efficienciesMulticlass1vs1(TString dataset, TString fin)
void plotEfficienciesMulticlass1vsRest(TString dataset, EEfficiencyPlotType plotType=EEfficiencyPlotType::kRejBvsEffS, TString filename_input="TMVAMulticlass.root")
static const double x1[5]
void plotEfficienciesMulticlass1vs1(TString dataset, TString fin, TString baseClassname)
UInt_t GetListOfMethods(TList &methods, TDirectory *dir=0)
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Describe directory structure in memory.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
std::vector< TString > getclassnames(TString dataset, TString fin)
virtual void SetTicks(Int_t valuex=1, Int_t valuey=1)
virtual TObject * ReadObj()
To read a TObject* from the file.
Abstract ClassifierFactory template that handles arbitrary types.
A Graph is a graphics object made of two arrays X and Y with npoints each.
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
THist< 2, float, THistStatContent, THistStatUncertainty > TH2F
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
const char * Data() const
UInt_t GetListOfTitles(TDirectory *rfdir, TList &titles)
virtual void SetHeader(const char *header="", Option_t *option="")
Sets the header, which is the "title" that appears at the top of the legend.