30std::vector<TControlBar*> TMVA::BDTReg_Global__cbar;
97 fInput->
Connect(
"ValueSet(Long_t)",
"TMVA::StatDialogBDTReg",
this,
"SetItree()");
113 if(!fWfile.EndsWith(
".xml") ){
114 std::ifstream fin( fWfile );
116 std::cout <<
"*** ERROR: Weight file: " << fWfile <<
" does not exist" << std::endl;
124 while (!
dummy.Contains(
"NTrees")) {
128 std::cout << std::endl;
129 std::cout <<
"*** Huge problem: could not locate term \"NTrees\" in BDT weight file: "
130 << fWfile << std::endl;
131 std::cout <<
"==> panic abort (please contact the TMVA authors)" << std::endl;
132 std::cout << std::endl;
137 fNtrees =
dummy.ReplaceAll(
"\"",
"").Atoi();
146 if(nodeName==
"Weights") {
153 std::cout <<
"--- Found " << fNtrees <<
" decision trees in weight file" << std::endl;
167 if (xsize>0.15) xsize=0.1;
168 if (
n->GetLeft() != NULL){
174 if (
n->GetRight() != NULL){
194 sprintf( buffer,
"R=%4.1f +- %4.1f",
n->GetResponse(),
n->GetRMS() );
197 if (
n->GetNodeType() == 0){
198 if (
n->GetCutType()){
212 std::cout <<
"--- Reading Tree " << itree <<
" from weight file: " << fWfile << std::endl;
216 if(!fWfile.EndsWith(
".xml") ){
218 std::ifstream fin( fWfile );
220 std::cout <<
"*** ERROR: Weight file: " << fWfile <<
" does not exist" << std::endl;
227 if (itree >= fNtrees) {
228 std::cout <<
"*** ERROR: requested decision tree: " << itree
229 <<
", but number of trained trees only: " << fNtrees << std::endl;
241 fin >>
dummy >> nVars;
246 vars[nVars]=
"FisherCrit";
250 sprintf(buffer,
"Tree %d",itree);
252 while (!
dummy.Contains(buffer)) {
253 fin.getline(
line,256);
262 if (itree >= fNtrees) {
263 std::cout <<
"*** ERROR: requested decision tree: " << itree
264 <<
", but number of trained trees only: " << fNtrees << std::endl;
275 if(nodeName==
"Variables"){
279 for (
Int_t i = 0; i < nVars; i++){
283 vars[nVars]=
"FisherCrit";
285 if(nodeName==
"Weights")
break;
304 UInt_t depth =
d->GetTotalTreeDepth();
307 std::cout <<
"--- Tree depth: " << depth << std::endl;
312 TString cbuffer =
Form(
"Reading weight file: %s", fWfile.Data() );
313 TString tbuffer =
Form(
"Regression Tree no.: %d", itree );
314 if (!fCanvas) fCanvas =
new TCanvas(
"c1", cbuffer, 200, 0, 1000, 600 );
315 else fCanvas->Clear();
335 intermediate->
AddText(
"Intermediate Nodes");
337 intermediate->
Draw();
339 ydown = ydown - ystep/2.5 -dy;
340 yup = yup - ystep/2.5 -dy;
345 signalleaf->
AddText(
"Leaf Nodes");
361 TString fname = fDataset+
Form(
"/plots/%s_%i", fMethName.Data(), itree );
362 std::cout <<
"--- Creating image: " << fname << std::endl;
383 std::cout <<
"*** Error in macro \"BDT_Reg.C\": cannot find directory \"Method_BDT\" in file: " << fin << std::endl;
390 std::vector<TString> methname;
391 std::vector<TString> path;
392 std::vector<TString> wfile;
393 while ((key = (
TKey*)next())) {
396 std::cout <<
"*** Error in macro \"BDT_Reg.C\": cannot find sub-directory: " << key->
GetName()
397 <<
" in directory: " << dir->
GetName() << std::endl;
404 if (!strPath || !strWFile) {
405 std::cout <<
"*** Error in macro \"BDT_Reg.C\": could not find TObjStrings \"TrainingPath\" and/or \"WeightFileName\" *** " << std::endl;
406 std::cout <<
"*** Maybe you are using TMVA >= 3.8.15 with an older training target file ? *** " << std::endl;
410 methname.push_back( key->GetName() );
412 wfile .push_back( strWFile->
GetString() );
417 BDTReg_Global__cbar.push_back(cbar);
419 for (
UInt_t im=0; im<path.size(); im++) {
421 if (fname[fname.
Length()-1] !=
'/') fname +=
"/";
423 TString macro =
Form(
"TMVA::BDT_Reg(\"%s\",0,\"%s\",\"%s\")",dataset.
Data(), fname.
Data(), methname[im].Data() );
424 cbar->
AddButton( fname, macro,
"Plot decision trees from this weight file",
"button" );
428#if ROOT_VERSION_CODE < ROOT_VERSION(5,19,0)
429 cbar->
AddButton(
"Close",
Form(
"BDTReg_DeleteTBar(%i)", BDTReg_Global__cbar.size()-1),
"Close this control bar",
"button" );
446 delete BDTReg_Global__cbar[i];
447 BDTReg_Global__cbar[i] = 0;
458 wfile = dataset+
"/weights/TMVARegression_BDT.weights.xml";
462 std::ifstream fin( wfile );
464 std::cout <<
"*** ERROR: Weight file: " << wfile <<
" does not exist" << std::endl;
468 std::cout <<
"test1";
472 StatDialogBDTReg* gGui =
new StatDialogBDTReg(dataset,
gClient->GetRoot(), wfile, methName, itree );
474 gGui->DrawTree( itree );
static RooMathCoreReg dummy
char * Form(const char *fmt,...)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
A Control Bar is a fully user configurable tool which provides fast access to frequently used operati...
void Show()
Show control bar.
void AddButton(TControlBarButton *button)
Add button.
void SetTextColor(const char *colorName)
Sets text color for control bar buttons, e.g.
Describe directory structure in memory.
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual TList * GetListOfKeys() const
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
virtual void SetLimits(ELimit limits=TGNumberFormat::kNELNoLimits, Double_t min=0, Double_t max=1)
virtual Double_t GetNumber() const
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Implementation of a Decision Tree.
TMVA::DecisionTree * ReadTree(TString *&vars, Int_t itree)
TGHorizontalFrame * fButtons
static StatDialogBDTReg * fThis
StatDialogBDTReg(TString dataset, const TGWindow *p, TString wfile, TString methName="BDT", Int_t itree=0)
void DrawTree(Int_t itree)
TGTextButton * fDrawButton
TGTextButton * fCloseButton
void DrawNode(TMVA::DecisionTreeNode *n, Double_t x, Double_t y, Double_t xscale, Double_t yscale, TString *vars)
recursively puts an entries in the histogram for the node and its daughters
virtual const char * GetName() const
Returns name of object.
Collectable string class.
const TString & GetString() const
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
A Pave (see TPave) with text, lines or/and boxes inside.
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
virtual void SetBorderSize(Int_t bordersize=4)
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
const char * Data() const
TStyle objects may be created to define special styles.
void SetCanvasColor(Color_t color=19)
Color_t GetCanvasColor() const
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
returns first child of xmlnode
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
XMLNodePointer_t GetNext(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
return next to xmlnode node if realnode==kTRUE, any special nodes in between will be skipped
void Initialize(Bool_t useTMVAStyle=kTRUE)
TFile * OpenFile(const TString &fin)
void imgconv(TCanvas *c, const TString &fname)
void BDTReg_DeleteTBar(int i)
void BDT_Reg(TString dataset, const TString &fin="TMVAReg.root")