18 void TMVA::DrawNetworkMovie(TString dataset, TFile* file,
const TString& methodType,
const TString& methodTitle )
21 TString dirname = methodType +
"/" + methodTitle +
"/" +
"EpochMonitoring";
22 TDirectory *epochDir = (TDirectory*)file->GetDirectory(dataset.Data())->Get( dirname );
24 cout <<
"Big troubles: could not find directory \"" << dirname <<
"\"" << endl;
30 TIter keyIt(epochDir->GetListOfKeys());
32 std::vector<TString> epochList;
34 while ((key = (TKey*)keyIt())) {
36 if (!gROOT->GetClass(key->GetClassName())->InheritsFrom(
"TH2F"))
continue;
37 TString name = key->GetName();
39 if (!name.BeginsWith(
"epochmonitoring___"))
continue;
42 TObjArray* tokens = name.Tokenize(
"_");
43 TString es = ((TObjString*)tokens->At(2))->GetString();
46 Bool_t isOld = kFALSE;
47 for (std::vector<TString>::const_iterator it = epochList.begin(); it < epochList.end(); ++it) {
48 if (*it == es) isOld = kTRUE;
51 epochList.push_back( es );
54 TString bulkname = Form(
"epochmonitoring___epoch_%s_weights_hist", es.Data() );
57 if (ic <= 60) draw_network(dataset, file, epochDir, bulkname, kTRUE, es );
63 void TMVA::DrawMLPoutputMovie(TString dataset, TFile* file,
const TString& methodType,
const TString& methodTitle )
68 const Int_t width = 600;
78 Float_t maxMult = 6.0;
79 Int_t countCanvas = 0;
82 TString dirname = methodType +
"/" + methodTitle +
"/" +
"EpochMonitoring";
83 TDirectory *epochDir = (TDirectory*)file->GetDirectory(dataset.Data())->Get( dirname );
85 cout <<
"Big troubles: could not find directory \"" << dirname <<
"\"" << endl;
90 TIter keyItTit(epochDir->GetListOfKeys());
92 while ((titkeyTit = (TKey*)keyItTit())) {
94 if (!gROOT->GetClass(titkeyTit->GetClassName())->InheritsFrom(
"TH1F"))
continue;
95 TString name = titkeyTit->GetName();
97 if (!name.BeginsWith(
"convergencetest___"))
continue;
98 if (!name.Contains(
"_train_"))
continue;
99 if (name.EndsWith(
"_B"))
continue;
102 if (!name.EndsWith(
"_S")) {
103 cout <<
"Big troubles with histogram: " << name <<
" -> should end with _S" << endl;
109 TString ctitle = Form(
"TMVA response %s",methodTitle.Data());
110 c =
new TCanvas( Form(
"canvas%d", countCanvas), ctitle, 0, 0, width, (Int_t)width*0.78 );
112 TH1F* sig = (TH1F*)titkeyTit->ReadObj();
113 sig->SetTitle( Form(
"TMVA response for classifier: %s", methodTitle.Data()) );
115 TString dataType = (name.Contains(
"_train_") ?
"(training sample)" :
"(test sample)");
118 TString nbn = sig->GetName(); nbn[nbn.Length()-1] =
'B';
119 TH1F* bgd =
dynamic_cast<TH1F*
>(epochDir->Get( nbn ));
121 cout <<
"Big troubles with histogram: " << bgd <<
" -> cannot find!" << endl;
125 cout <<
"sig = " << sig->GetName() << endl;
126 cout <<
"bgd = " << bgd->GetName() << endl;
129 TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd );
132 TMVAGlob::NormalizeHists( sig, bgd );
136 if (xmin == 0 && xmax == 0) {
137 xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(),
138 bgd->GetMean() - nrms*bgd->GetRMS() ),
139 sig->GetXaxis()->GetXmin() );
140 xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(),
141 bgd->GetMean() + nrms*bgd->GetRMS() ),
142 sig->GetXaxis()->GetXmax() );
145 ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*maxMult;
151 TString hFrameName(TString(
"frame") + methodTitle);
152 TObject *o = gROOT->FindObject(hFrameName);
154 TH2F* frame =
new TH2F( hFrameName, sig->GetTitle(),
155 nb, xmin, xmax, nb, ymin, ymax );
156 frame->GetXaxis()->SetTitle( methodTitle +
" response" );
157 frame->GetYaxis()->SetTitle(
"(1/N) dN^{ }/^{ }dx");
158 TMVAGlob::SetFrameStyle( frame );
161 TObjArray* tokens = name.Tokenize(
"_");
162 TString es = ((TObjString*)tokens->At(4))->GetString();
164 cout <<
"Big troubles in epoch parsing: \"" << es <<
"\" is not float" << endl;
167 Int_t epoch = es.Atoi();
172 c->GetPad(0)->SetLeftMargin( 0.105 );
173 frame->GetYaxis()->SetTitleOffset( 1.2 );
176 TLegend *legend=
new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.12,
177 c->GetLeftMargin() + 0.5, 1 - c->GetTopMargin() );
178 legend->SetFillStyle( 1 );
179 legend->AddEntry(sig,TString(
"Signal ") + dataType,
"F");
180 legend->AddEntry(bgd,TString(
"Background ") + dataType,
"F");
181 legend->SetBorderSize(1);
182 legend->SetMargin( 0.15 );
183 legend->Draw(
"same");
185 TText* t =
new TText();
186 t->SetTextSize( 0.04 );
187 t->SetTextColor( 1 );
188 t->SetTextAlign( 31 );
189 t->DrawTextNDC( 1 - c->GetRightMargin(), 1 - c->GetTopMargin() + 0.015, Form(
"Epoch: %i", epoch) );
192 sig->Draw(
"samehist");
193 bgd->Draw(
"samehist");
196 TString outdirname =
"movieplots";
197 TString foutname = outdirname +
"/" + name;
198 foutname.Resize( foutname.Length()-2 );
199 foutname.ReplaceAll(
"convergencetest___",
"");
202 cout <<
"storing file: " << foutname << endl;
211 void TMVA::MovieMaker(TString dataset, TString methodType , TString methodTitle )
213 TString fname =
"TMVA.root";
214 TFile* file = TMVAGlob::OpenFile( fname );
217 DrawNetworkMovie(dataset, file, methodType, methodTitle );