00001 #include <vector>
00002 #include <string>
00003 #include "tmvaglob.C"
00004
00005
00006
00007
00008
00009 void BoostControlPlots( TString fin = "TMVA.root", Bool_t useTMVAStyle = kTRUE )
00010 {
00011
00012 TMVAGlob::Initialize( useTMVAStyle );
00013
00014
00015 TFile* file = TMVAGlob::OpenFile( fin );
00016
00017
00018 TList titles;
00019 UInt_t ninst = TMVAGlob::GetListOfTitles("Method_Boost",titles);
00020 if (ninst==0) {
00021 cout << "Could not locate directory 'Method_Boost' in file " << fin << endl;
00022 return;
00023 }
00024
00025 TIter keyIter(&titles);
00026 TDirectory *boostdir;
00027 TKey *key;
00028 while ((key = TMVAGlob::NextKey(keyIter,"TDirectory"))) {
00029 boostdir = (TDirectory *)key->ReadObj();
00030 boostcontrolplots( boostdir );
00031 }
00032 }
00033
00034 void boostcontrolplots( TDirectory *boostdir ) {
00035
00036 const Int_t nPlots = 4;
00037
00038 Int_t width = 900;
00039 Int_t height = 900;
00040 char cn[100];
00041 const TString titName = boostdir->GetName();
00042 sprintf( cn, "cv_%s", titName.Data() );
00043 TCanvas *c = new TCanvas( cn, Form( "%s Control Plots", titName.Data() ),
00044 width, height );
00045 c->Divide(2,3);
00046
00047
00048 const TString titName = boostdir->GetName();
00049
00050 TString hname[nPlots]={"Booster_BoostWeight","Booster_MethodWeight","Booster_ErrFraction","Booster_OrigErrFraction"};
00051
00052 for (Int_t i=0; i<nPlots; i++){
00053 Int_t color = 4;
00054 TPad * cPad = (TPad*)c->cd(i+1);
00055 TH1 *h = (TH1*) boostdir->Get(hname[i]);
00056 TString plotname = h->GetName();
00057 h->SetMaximum(h->GetMaximum()*1.3);
00058 h->SetMinimum( 0 );
00059 h->SetMarkerColor(color);
00060 h->SetMarkerSize( 0.7 );
00061 h->SetMarkerStyle( 24 );
00062 h->SetLineWidth(2);
00063 h->SetLineColor(color);
00064 h->Draw();
00065 c->Update();
00066 }
00067
00068
00069
00070 TString hname_roctest[2] ={"Booster_ROCIntegral_test", "Booster_ROCIntegralBoosted_test"};
00071 TString hname_roctrain[2]={"Booster_ROCIntegral_train", "Booster_ROCIntegralBoosted_train"};
00072 TString htitle[2] = {"ROC integral of single classifier", "ROC integral of boosted method"}
00073
00074 for (Int_t i=0; i<2; i++){
00075 Int_t color = 4;
00076 TPad * cPad = (TPad*)c->cd(nPlots+i+1);
00077 TH1 *htest = (TH1*) boostdir->Get(hname_roctest[i]);
00078 TH1 *htrain = (TH1*) boostdir->Get(hname_roctrain[i]);
00079 htest->SetTitle(htitle[i]);
00080 htest->SetMaximum(1.0);
00081 htest->SetMinimum(0.0);
00082 htest->SetMarkerColor(color);
00083 htest->SetMarkerSize( 0.7 );
00084 htest->SetMarkerStyle( 24 );
00085 htest->SetLineWidth(2);
00086 htest->SetLineColor(color);
00087 htest->Draw();
00088 htrain->SetMaximum(1.0);
00089 htrain->SetMinimum(0.0);
00090 htrain->SetMarkerColor(color-2);
00091 htrain->SetMarkerSize( 0.7 );
00092 htrain->SetMarkerStyle( 24 );
00093 htrain->SetLineWidth(2);
00094 htrain->SetLineColor(color-2);
00095 htrain->Draw("same");
00096
00097 TLegend *legend= new TLegend( cPad->GetLeftMargin(),
00098 0.2 + cPad->GetBottomMargin(),
00099 cPad->GetLeftMargin() + 0.6,
00100 cPad->GetBottomMargin() );
00101 legend->AddEntry(htest, TString("testing sample"), "L");
00102 legend->AddEntry(htrain, TString("training sample (orig. weights)"), "L");
00103 legend->SetFillStyle( 1 );
00104 legend->SetBorderSize(1);
00105 legend->SetMargin( 0.3 );
00106 legend->Draw("same");
00107
00108 c->Update();
00109 }
00110
00111
00112 TString fname = Form( "plots/%s_ControlPlots", titName.Data() );
00113 TMVAGlob::imgconv( c, fname );
00114
00115 }
00116
00117