16 void TMVA::deviations(TString dataset, TString fin,
17 HistType htype , Bool_t showTarget, Bool_t useTMVAStyle )
20 TMVAGlob::Initialize( useTMVAStyle );
21 gStyle->SetNumberContours(999);
24 TFile* file = TMVAGlob::OpenFile( fin );
27 const Int_t width = 650;
33 Int_t countCanvas = 0;
38 TIter next(file->GetDirectory(dataset.Data())->GetListOfKeys());
40 while ((key = (TKey*)next())) {
42 if (!TString(key->GetName()).BeginsWith(
"Method_"))
continue;
43 if (!gROOT->GetClass(key->GetClassName())->InheritsFrom(
"TDirectory"))
continue;
46 TMVAGlob::GetMethodName(methodName,key);
47 cout <<
"--- Plotting deviation for method: " << methodName << endl;
49 TDirectory* mDir = (TDirectory*)key->ReadObj();
51 TList* jobNames =
new TList();
53 TIter keyIt(mDir->GetListOfKeys());
55 while ((titkey = (TKey*)keyIt())) {
57 if (!gROOT->GetClass(titkey->GetClassName())->InheritsFrom(
"TDirectory"))
continue;
59 TDirectory *titDir = (TDirectory *)titkey->ReadObj();
61 TObjString *jN =
new TObjString( titDir->GetName() );
62 if (!jobNames->Contains( jN )) jobNames->Add( jN );
66 TMVAGlob::GetMethodTitle(methodTitle,titDir);
68 TString hname =
"MVA_" + methodTitle;
69 TIter dirKeyIt( titDir->GetListOfKeys() );
73 while ((dirKey = (TKey*)dirKeyIt())){
74 if (dirKey->ReadObj()->InheritsFrom(
"TH2F")) {
75 TString s(dirKey->ReadObj()->GetName());
76 if (s.Contains(
"_reg_") &&
77 ( (showTarget && s.Contains(
"_tgt")) || (!showTarget && !s.Contains(
"_tgt")) ) &&
78 s.Contains( (htype == kCompareType ?
"train" :
"test" ))) {
79 c[countCanvas] =
new TCanvas( Form(
"canvas%d", countCanvas+1),
80 Form(
"Regression output deviation versus %s for method: %s",
81 (showTarget ?
"target" :
"input variables"), methodName.Data() ),
82 countCanvas*50+100, (countCanvas+1)*20, width, (Int_t)width*0.72 );
83 c[countCanvas]->SetRightMargin(0.10);
84 TH1* h = (TH1*)dirKey->ReadObj();
85 h->SetTitle( Form(
"Output deviation for method: %s (%s sample)",
86 hname.Data(), (htype == kCompareType ?
"training" :
"test" )) );
89 TLine* l =
new TLine( h->GetXaxis()->GetXmin(), 0, h->GetXaxis()->GetXmax(), 0 );
94 cout <<
"plotting logo" << endl;
95 TMVAGlob::plot_logo(1.058);
96 c[countCanvas]->Update();
98 TString fname = Form(
"%s/plots/deviation_%s_%s_%s_c%i",
101 (showTarget ?
"target" :
"vars"),
102 (htype == kCompareType ?
"training" :
"test" ), countPlots );
103 TMVAGlob::imgconv( c[countCanvas], fname );