95 fInput->
Connect(
"ValueSet(Long_t)",
"TMVA::StatDialogBDTReg",
this,
"SetItree()");
111 if(!fWfile.EndsWith(
".xml") ){
112 std::ifstream fin( fWfile );
114 std::cout <<
"*** ERROR: Weight file: " << fWfile <<
" does not exist" << std::endl;
126 std::cout << std::endl;
127 std::cout <<
"*** Huge problem: could not locate term \"NTrees\" in BDT weight file: "
128 << fWfile << std::endl;
129 std::cout <<
"==> panic abort (please contact the TMVA authors)" << std::endl;
130 std::cout << std::endl;
135 fNtrees = dummy.ReplaceAll(
"\"",
"").Atoi();
144 if(nodeName==
"Weights") {
151 std::cout <<
"--- Found " << fNtrees <<
" decision trees in weight file" << std::endl;
165 if (xsize>0.15) xsize=0.1;
167 TLine *a1 =
new TLine(x-xscale/4,y-ysize,x-xscale,y-ysize*2);
173 TLine *a1 =
new TLine(x+xscale/4,y-ysize,x+xscale,y-ysize*2);
210 std::cout <<
"--- Reading Tree " << itree <<
" from weight file: " << fWfile << std::endl;
214 if(!fWfile.EndsWith(
".xml") ){
216 std::ifstream fin( fWfile );
218 std::cout <<
"*** ERROR: Weight file: " << fWfile <<
" does not exist" << std::endl;
223 if (itree >= fNtrees) {
224 std::cout <<
"*** ERROR: requested decision tree: " << itree
225 <<
", but number of trained trees only: " << fNtrees << std::endl;
230 while (!dummy.
Contains(
"#VAR")) fin >> dummy;
231 fin >> dummy >> dummy >>
dummy;
235 fin >> dummy >> nVars;
239 for (
Int_t i = 0; i < nVars; i++) fin >> vars[i] >> dummy >> dummy >> dummy >>
dummy;
240 vars[nVars]=
"FisherCrit";
244 sprintf(buffer,
"Tree %d",itree);
246 while (!dummy.Contains(buffer)) {
247 fin.getline(line,256);
256 if (itree >= fNtrees) {
257 std::cout <<
"*** ERROR: requested decision tree: " << itree
258 <<
", but number of trained trees only: " << fNtrees << std::endl;
267 if(nodeName==
"Variables"){
271 for (
Int_t i = 0; i < nVars; i++){
275 vars[nVars]=
"FisherCrit";
277 if(nodeName==
"Weights")
break;
299 std::cout <<
"--- Tree depth: " << depth << std::endl;
304 TString cbuffer =
Form(
"Reading weight file: %s", fWfile.Data() );
305 TString tbuffer =
Form(
"Regression Tree no.: %d", itree );
306 if (!fCanvas) fCanvas =
new TCanvas(
"c1", cbuffer, 200, 0, 1000, 600 );
307 else fCanvas->Clear();
327 intermediate->
AddText(
"Intermediate Nodes");
329 intermediate->
Draw();
331 ydown = ydown - ystep/2.5 -dy;
332 yup = yup - ystep/2.5 -dy;
337 signalleaf->
AddText(
"Leaf Nodes");
353 TString fname =
Form(
"plots/%s_%i", fMethName.Data(), itree );
354 std::cout <<
"--- Creating image: " << fname << std::endl;
375 std::cout <<
"*** Error in macro \"BDT_Reg.C\": cannot find directory \"Method_BDT\" in file: " << fin << std::endl;
382 std::vector<TString> methname;
383 std::vector<TString> path;
384 std::vector<TString> wfile;
388 std::cout <<
"*** Error in macro \"BDT_Reg.C\": cannot find sub-directory: " << key->
GetName()
389 <<
" in directory: " << dir->
GetName() << std::endl;
396 if (!strPath || !strWFile) {
397 std::cout <<
"*** Error in macro \"BDT_Reg.C\": could not find TObjStrings \"TrainingPath\" and/or \"WeightFileName\" *** " << std::endl;
398 std::cout <<
"*** Maybe you are using TMVA >= 3.8.15 with an older training target file ? *** " << std::endl;
402 methname.push_back( key->GetName() );
404 wfile .push_back( strWFile->
GetString() );
411 for (
UInt_t im=0; im<path.size(); im++) {
413 if (fname[fname.
Length()-1] !=
'/') fname +=
"/";
415 TString macro =
Form(
"TMVA::BDT_Reg(0,\"%s\",\"%s\")", fname.
Data(), methname[im].Data() );
416 cbar->
AddButton( fname, macro,
"Plot decision trees from this weight file",
"button" );
420 #if ROOT_VERSION_CODE < ROOT_VERSION(5,19,0)
452 std::ifstream fin( wfile );
454 std::cout <<
"*** ERROR: Weight file: " << wfile <<
" does not exist" << std::endl;
458 std::cout <<
"test1";
void Show()
Show control bar.
virtual void SetLineWidth(Width_t lwidth)
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
void AddButton(TControlBarButton *button)
Add button.
static const Int_t kSigColorF
void imgconv(TCanvas *c, const TString &fname)
A Control Bar is a fully user configurable tool which provides fast access to frequently used operati...
void SetTextColor(const char *colorName)
Sets text color for control bar buttons, e.g.
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
static const Int_t kSigColorT
virtual TList * GetListOfKeys() const
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
Collectable string class.
StatDialogBDTReg(const TGWindow *p, TString wfile="weights/TMVARegression_BDT.weights.xml", TString methName="BDT", Int_t itree=0)
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
virtual void Read(std::istream &istr, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
Read the binary tree from an input stream.
UInt_t GetTotalTreeDepth() const
TFile * OpenFile(const TString &fin)
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
virtual DecisionTreeNode * GetRight() const
Float_t GetRMS(void) const
TGTextButton * fDrawButton
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 ...
Int_t GetNodeType(void) const
static const Int_t kIntColorF
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
virtual void SetLimits(ELimit limits=TGNumberFormat::kNELNoLimits, Double_t min=0, Double_t max=1)
virtual void SetFillStyle(Style_t fstyle)
virtual DecisionTreeNode * GetLeft() const
virtual DecisionTreeNode * GetRoot() const
void SetCanvasColor(Color_t color=19)
const char * Data() const
TMVA::DecisionTree * ReadTree(TString *&vars, Int_t itree)
Bool_t GetCutType(void) const
Book space in a file, create I/O buffers, to fill them, (un)compress them.
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
TStyle objects may be created to define special styles.
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...
TString GetString() const
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
void Initialize(Bool_t useTMVAStyle=kTRUE)
virtual void SetFillColor(Color_t fcolor)
char * Form(const char *fmt,...)
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb"...
virtual const char * GetName() const
Returns name of object.
virtual void ReadXML(void *node, UInt_t tmva_Version_Code=TMVA_VERSION_CODE)
read attributes from XML
virtual TDirectory * GetDirectory(const char *apath, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory named "apath".
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
A Pave (see TPave) with text, lines or/and boxes inside.
Describe directory structure in memory.
static RooMathCoreReg dummy
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
static StatDialogBDTReg * fThis
Short_t GetSelector() const
TGHorizontalFrame * fButtons
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
static const Int_t kBkgColorF
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
returns first child of xml node
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
void DrawTree(Int_t itree)
virtual void SetTextColor(Color_t tcolor=1)
virtual Double_t GetNumber() const
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
static const Int_t kIntColorT
static const Int_t kBkgColorT
Float_t GetResponse(void) const
Color_t GetCanvasColor() const
virtual void SetBorderSize(Int_t bordersize=4)
void BDTReg_DeleteTBar(int i)
void BDT_Reg(const TString &fin="TMVAReg.root")
static std::vector< TControlBar * > BDTReg_Global__cbar
Float_t GetCutValue(void) const