00001 #include "tmvaglob.C"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 void annconvergencetest( TString fin = "TMVA.root", Bool_t useTMVAStyle = kTRUE )
00012 {
00013
00014 TMVAGlob::Initialize( useTMVAStyle );
00015
00016
00017 TFile* file = TMVAGlob::OpenFile( fin );
00018
00019
00020 TList titles;
00021 UInt_t ninst = TMVAGlob::GetListOfTitles("Method_MLP",titles);
00022 if (ninst==0) {
00023 cout << "Could not locate directory 'Method_MLP' in file " << fin << endl;
00024 return;
00025 }
00026
00027 TIter keyIter(&titles);
00028 TDirectory *lhdir;
00029 TKey *key;
00030 while ((key = TMVAGlob::NextKey(keyIter,"TDirectory"))) {
00031 lhdir = (TDirectory *)key->ReadObj();
00032 annconvergencetest( lhdir );
00033 }
00034 }
00035
00036 void annconvergencetest( TDirectory *lhdir )
00037 {
00038 TString jobName = lhdir->GetName();
00039 static icanvas = -1;
00040 icanvas++;
00041 TCanvas* c = new TCanvas( Form("MLPConvergenceTest_%s",jobName.Data()), Form("MLP Convergence Test, %s",jobName.Data()),
00042 100 + (icanvas)*40, 0 + (icanvas+1)*20, 600, 580*0.8 );
00043
00044 TH1* estimatorHistTrain = (TH1*)lhdir->Get( "estimatorHistTrain" );
00045 TH1* estimatorHistTest = (TH1*)lhdir->Get( "estimatorHistTest" );
00046
00047 Double_t m1 = estimatorHistTrain->GetMaximum();
00048 Double_t m2 = estimatorHistTest ->GetMaximum();
00049 Double_t max = TMath::Max( m1, m2 );
00050 m1 = estimatorHistTrain->GetMinimum();
00051 m2 = estimatorHistTest ->GetMinimum();
00052 Double_t min = TMath::Min( m1, m2 );
00053 estimatorHistTrain->SetMaximum( max + 0.1*(max - min) );
00054 estimatorHistTrain->SetMinimum( min - 0.1*(max - min) );
00055 estimatorHistTrain->SetLineColor( 2 );
00056 estimatorHistTrain->SetLineWidth( 2 );
00057 estimatorHistTrain->SetTitle( TString("MLP Convergence Test") );
00058
00059 estimatorHistTest->SetLineColor( 4 );
00060 estimatorHistTest->SetLineWidth( 2 );
00061
00062 estimatorHistTrain->GetXaxis()->SetTitle( "Epochs" );
00063 estimatorHistTrain->GetYaxis()->SetTitle( "Estimator" );
00064 estimatorHistTrain->GetXaxis()->SetTitleOffset( 1.20 );
00065 estimatorHistTrain->GetYaxis()->SetTitleOffset( 1.65 );
00066
00067 estimatorHistTrain->Draw();
00068 estimatorHistTest ->Draw("same");
00069
00070
00071 TLegend *legend= new TLegend( 1 - c->GetRightMargin() - 0.45, 1-c->GetTopMargin() - 0.20,
00072 1 - c->GetRightMargin() - 0.05, 1-c->GetTopMargin() - 0.05 );
00073
00074 legend->AddEntry(estimatorHistTrain,"Training Sample","l");
00075 legend->AddEntry(estimatorHistTest,"Test sample","l");
00076 legend->Draw("same");
00077 legend->SetMargin( 0.3 );
00078
00079 c->cd();
00080 TMVAGlob::plot_logo();
00081 c->Update();
00082
00083 TString fname = "plots/annconvergencetest";
00084 TMVAGlob::imgconv( c, fname );
00085 }