10 static TList* TMVARegGui_keyContent;
11 static std::vector<TString> TMVARegGui_inactiveButtons;
14 TList* TMVA::RegGuiGetKeyList(
const TString& pattern )
16 TList* list =
new TList();
18 TIter next( TMVARegGui_keyContent );
20 while ((key = (TKey*)next())) {
21 if (TString(key->GetName()).Contains( pattern )) { list->Add(
new TObjString( key->GetName() ) ); }
27 void TMVA::RegGuiActionButton( TControlBar* cbar,
28 const TString& title,
const TString& macro,
const TString& comment,
29 const TString& buttonType, TString requiredKey)
31 cbar->AddButton( title, macro, comment, buttonType );
34 if (requiredKey !=
"") {
35 Bool_t found = kFALSE;
36 TIter next( TMVARegGui_keyContent );
38 while ((key = (TKey*)next())) {
39 if (TString(key->GetName()).Contains( requiredKey )) { found = kTRUE;
break; }
41 if (!found) TMVARegGui_inactiveButtons.push_back( title );
46 void TMVA::TMVARegGui(
const char* fName ,TString dataset)
52 TString curMacroPath(gROOT->GetMacroPath());
54 gROOT->SetMacroPath(curMacroPath+
":./:$ROOTSYS/tmva/test/:");
61 TString curIncludePath=gSystem->GetIncludePath();
63 TString newIncludePath=TString(
"-I../ ")+curIncludePath;
64 gSystem->SetIncludePath(newIncludePath);
66 cout <<
"--- Launch TMVA GUI to view input file: " << fName << endl;
69 TMVARegGui_inactiveButtons.clear();
72 TFile* file = TFile::Open( fName );
74 cout <<
"==> Abort TMVARegGui, please verify filename" << endl;
78 if(file->GetListOfKeys()->GetEntries()<=0)
80 cout <<
"==> Abort TMVARegGui, please verify if dataset exist" << endl;
83 if( (dataset==
""||dataset.IsWhitespace()) && (file->GetListOfKeys()->GetEntries()==1))
85 TKey *key=(TKey*)file->GetListOfKeys()->At(0);
86 dataset=key->GetName();
87 }
else if((dataset==
""||dataset.IsWhitespace()) && (file->GetListOfKeys()->GetEntries()>=1))
90 gStyle->SetScreenFactor(2);
92 TControlBar *bar=
new TControlBar(
"vertical",
"Select dataset", 0, 0);
93 bar->SetButtonWidth(300);
94 for(
int i=0;i<file->GetListOfKeys()->GetEntries();i++)
96 TKey *key=(TKey*)file->GetListOfKeys()->At(i);
97 dataset=key->GetName();
98 bar->AddButton(dataset.Data(),Form(
"TMVA::TMVARegGui(\"%s\",\"%s\")",fName,dataset.Data()),dataset.Data());
102 bar->AddButton(
"Quit",
".q",
"Quit",
"button");
105 bar->SetTextColor(
"black");
107 gROOT->SaveContext();
111 TMVARegGui_keyContent = (TList*)file->GetDirectory(dataset.Data())->GetListOfKeys()->Clone();
116 TString defaultRequiredClassifier =
"";
122 TControlBar* cbar =
new TControlBar(
"vertical",
"TMVA Plotting Macros for Regression", 0, 0 );
124 const TString buttonType(
"button" );
130 TList* keylist = RegGuiGetKeyList(
"InputVariables" );
131 TListIter it( keylist );
134 while ( (str = (TObjString*)it()) ) {
135 TString tmp = str->GetString();
136 TString title = Form(
"Input variables and target(s) '%s'-transformed (training sample)",
137 tmp.ReplaceAll(
"InputVariables_",
"").Data() );
138 if (tmp.Contains(
"Id" )) title =
"Input variables and target(s) (training sample)";
139 RegGuiActionButton( cbar,
140 Form(
" (%i%c) %s ", ic, ch++, title.Data() ),
141 Form(
"TMVA::variables(\"%s\",\"%s\",\"%s\",\"%s\",kTRUE)",dataset.Data() , fName, str->GetString().Data(), title.Data() ),
142 Form(
"Plots all '%s'-transformed input variables and target(s) (macro variables(...))",
143 str->GetString().Data() ),
144 buttonType, str->GetString() );
149 it.Reset(); ch =
'a';
150 while ( (str = (TObjString*)it()) ) {
151 TString tmp = str->GetString();
152 TString title = Form(
"Input variable correlations '%s'-transformed (scatter profiles)",
153 tmp.ReplaceAll(
"InputVariables_",
"").Data() );
154 if (tmp.Contains(
"Id" )) title =
"Input variable correlations (scatter profiles)";
155 RegGuiActionButton( cbar,
156 Form(
"(%i%c) %s", ic, ch++, title.Data() ),
157 Form(
"TMVA::CorrGui(\"%s\",\"%s\",\"%s\",\"%s\",kTRUE)",dataset.Data() , fName, str->GetString().Data(), title.Data() ),
158 Form(
"Plots all correlation profiles between '%s'-transformed input variables (macro CorrGui(...))",
159 str->GetString().Data() ),
160 buttonType, str->GetString() );
164 RegGuiActionButton( cbar,
165 Form(
"(%i) Input Variable Linear Correlation Coefficients", ++ic ),
166 Form(
"TMVA::correlations(\"%s\",\"%s\",kTRUE)",dataset.Data(), fName ),
167 "Plots signal and background correlation summaries for all input variables (macro correlations.cxx)",
170 RegGuiActionButton( cbar,
171 Form(
"(%ia) Regression Output Deviation versus Target (test sample)", ++ic ),
172 Form(
"TMVA::deviations(\"%s\",\"%s\",TMVA::kMVAType,kTRUE)",dataset.Data(), fName ),
173 "Plots the deviation between regression output and target versus target on test data (macro deviations(...,0))",
174 buttonType, defaultRequiredClassifier );
176 RegGuiActionButton( cbar,
177 Form(
"(%ib) Regression Output Deviation versus Target (training sample)", ic ),
178 Form(
"TMVA::deviations(\"%s\",\"%s\",TMVA::kCompareType,kTRUE)",dataset.Data() , fName ),
179 "Plots the deviation between regression output and target versus target on test data (macro deviations(...,0))",
180 buttonType, defaultRequiredClassifier );
182 RegGuiActionButton( cbar,
183 Form(
"(%ic) Regression Output Deviation versus Input Variables (test sample)", ic ),
184 Form(
"TMVA::deviations(\"%s\",\"%s\",TMVA::kMVAType,kFALSE)",dataset.Data(), fName ),
185 "Plots the deviation between regression output and target versus target on test data (macro deviations(...,0))",
186 buttonType, defaultRequiredClassifier );
188 RegGuiActionButton( cbar,
189 Form(
" (%id) Regression Output Deviation versus Input Variables (training sample) ", ic ),
190 Form(
"TMVA::deviations(\"%s\",\"%s\",TMVA::kCompareType,kFALSE)",dataset.Data() , fName ),
191 "Plots the deviation between regression output and target versus target on test data (macro deviations(...,0))",
192 buttonType, defaultRequiredClassifier );
194 RegGuiActionButton( cbar,
195 Form(
"(%i) Summary of Average Regression Deviations ", ++ic ),
196 Form(
"TMVA::regression_averagedevs(\"%s\",\"%s\")",dataset.Data() , fName ),
197 "Plot Summary of average deviations: MVAvalue - target (macro regression_averagedevs.cxx)",
200 RegGuiActionButton( cbar,
201 Form(
"(%ia) Network Architecture", ++ic ),
202 Form(
"TMVA::network(\"%s\",\"%s\")",dataset.Data(), fName ),
203 "Plots the MLP weights (macro network.cxx)",
206 RegGuiActionButton( cbar,
207 Form(
"(%ib) Network Convergence Test", ic ),
208 Form(
"TMVA::annconvergencetest(\"%s\",\"%s\")",dataset.Data() , fName ),
209 "Plots error estimator versus training epoch for training and test samples (macro annconvergencetest.cxx)",
212 RegGuiActionButton( cbar,
213 Form(
"(%i) Plot Foams", ++ic ),
214 Form(
"TMVA::PlotFoams(\"%s/weights/TMVARegression_PDEFoam.weights_foams.root\")",dataset.Data()),
215 "Plot Foams (macro PlotFoams.cxx)",
216 buttonType,
"PDEFoam" );
218 RegGuiActionButton( cbar,
219 Form(
"(%i) Regression Trees (BDT)", ++ic ),
220 Form(
"TMVA::BDT_Reg(\"%s\",\"%s\")",dataset.Data() , fName ),
221 "Plots the Regression Trees trained by BDT algorithms (macro BDT_Reg(itree,...))",
224 RegGuiActionButton( cbar,
225 Form(
"(%i) Regression Tree Control Plots (BDT)", ++ic ),
226 Form(
"TMVA::BDTControlPlots(\"%s\",\"%s\")",dataset.Data(), fName ),
227 "Plots to monitor boosting and pruning of regression trees (macro BDTControlPlots.cxx)",
230 cbar->AddSeparator();
232 cbar->AddButton( Form(
"(%i) Quit", ++ic ),
".q",
"Quit", buttonType );
235 cbar->SetTextColor(
"black");
244 for (UInt_t i=0; i<TMVARegGui_inactiveButtons.size(); i++) cbar->SetButtonState( TMVARegGui_inactiveButtons[i], 3 );
245 if (TMVARegGui_inactiveButtons.size() > 0) {
246 cout <<
"=== Note: inactive buttons indicate that the corresponding methods were not trained ===" << endl;
249 gROOT->SaveContext();