99 fInput->
Connect(
"ValueSet(Long_t)",
"TMVA::StatDialogBDT",
this,
"SetItree()");
116 std::ifstream fin(
fWfile );
118 cout <<
"*** ERROR: Weight file: " <<
fWfile <<
" does not exist" << endl;
131 cout <<
"*** Huge problem: could not locate term \"NTrees\" in BDT weight file: " 133 cout <<
"==> panic abort (please contact the TMVA authors)" << endl;
139 fNtrees = dummy.ReplaceAll(
"\"",
"").Atoi();
148 if(nodeName==
"Weights") {
155 cout <<
"--- Found " <<
fNtrees <<
" decision trees in weight file" << endl;
169 if (xsize>0.15) xsize=0.1;
171 TLine *a1 =
new TLine(x-xscale/4,y-ysize,x-xscale,y-ysize*2);
177 TLine *a1 =
new TLine(x+xscale/4,y-ysize,x+xscale,y-ysize*2);
188 t->SetFillStyle(1001);
197 sprintf( buffer,
"S/(S+B)=%4.3f", n->
GetPurity() );
214 cout <<
"--- Reading Tree " << itree <<
" from weight file: " <<
fWfile << endl;
217 std::ifstream fin(
fWfile );
219 cout <<
"*** ERROR: Weight file: " <<
fWfile <<
" does not exist" << endl;
226 cout <<
"*** ERROR: requested decision tree: " << itree
227 <<
", but number of trained trees only: " <<
fNtrees << endl;
232 while (!dummy.
Contains(
"#VAR")) fin >> dummy;
233 fin >> dummy >> dummy >>
dummy;
237 fin >> dummy >> nVars;
241 for (
Int_t i = 0; i < nVars; i++) fin >> vars[i] >> dummy >> dummy >> dummy >>
dummy;
242 vars[nVars]=
"FisherCrit";
246 sprintf(buffer,
"Tree %d",itree);
248 while (!dummy.Contains(buffer)) {
249 fin.getline(line,256);
259 cout <<
"*** ERROR: requested decision tree: " << itree
260 <<
", but number of trained trees only: " <<
fNtrees << endl;
269 if(nodeName==
"Variables"){
273 for (
Int_t i = 0; i < nVars; i++){
277 vars[nVars]=
"FisherCrit";
279 if(nodeName==
"Weights")
break;
300 cout <<
"--- Tree depth: " << depth << endl;
312 Int_t MyPalette[100];
321 TString tbuffer =
Form(
"Decision Tree no.: %d", itree );
344 signalleaf->
AddText(
"Pure Signal Nodes");
348 ydown = ydown - ystep/2.5 -dy;
349 yup = yup - ystep/2.5 -dy;
355 backgroundleaf->
AddText(
"Pure Backgr. Nodes");
357 backgroundleaf->
Draw();
362 cout <<
"--- Creating image: " << fname << endl;
384 cout <<
"*** Error in macro \"BDT.C\": cannot find directory \"Method_BDT\" in file: " << fin << endl;
391 std::vector<TString> methname;
392 std::vector<TString> path;
393 std::vector<TString> wfile;
394 while ((key = (
TKey*)next())) {
397 cout <<
"*** Error in macro \"BDT.C\": cannot find sub-directory: " << key->
GetName()
398 <<
" in directory: " << dir->
GetName() << endl;
405 if (!strPath || !strWFile) {
406 cout <<
"*** Error in macro \"BDT.C\": could not find TObjStrings \"TrainingPath\" and/or \"WeightFileName\" *** " << endl;
407 cout <<
"*** Maybe you are using TMVA >= 3.8.15 with an older training target file ? *** " << endl;
411 methname.push_back( key->GetName() );
413 wfile .push_back( strWFile->
GetString() );
420 for (
UInt_t im=0; im<path.size(); im++) {
422 if (fname[fname.
Length()-1] !=
'/') fname +=
"/";
424 TString macro =
Form(
"TMVA::BDT(\"%s\",0,\"%s\",\"%s\")",dataset.
Data(), fname.
Data(), methname[im].Data() );
425 cbar->
AddButton( fname, macro,
"Plot decision trees from this weight file",
"button" );
429 #if ROOT_VERSION_CODE < ROOT_VERSION(5,19,0) 459 wfile = dataset+
"/weights/TMVAnalysis_test_BDT.weights.txt";
462 std::ifstream fin( wfile );
464 cout <<
"*** ERROR: Weight file: " << wfile <<
" does not exist" << endl;
468 std::cout <<
"test1";
void Show()
Show control bar.
virtual const char * GetName() const
Returns name of object.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
void DrawTree(Int_t itree)
void AddButton(TControlBarButton *button)
Add button.
void imgconv(TCanvas *c, const TString &fname)
A Control Bar is a fully user configurable tool which provides fast access to frequently used operati...
virtual TList * GetListOfKeys() const
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.
Float_t GetNEvents(void) const
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
Collectable string class.
void BDT(TString dataset, const TString &fin="TMVA.root")
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.
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.
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 ...
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)
Set the fill area style.
Bool_t GetCutType(void) const
virtual DecisionTreeNode * GetRoot() const
void SetCanvasColor(Color_t color=19)
TMVA::DecisionTree * ReadTree(TString *&vars, Int_t itree)
static std::vector< TControlBar * > BDT_Global__cbar
StatDialogBDT(TString dataset, const TGWindow *p, TString wfile, TString methName="BDT", Int_t itree=0)
Float_t GetCutValue(void) const
void Clear(Option_t *option="")
Remove all primitives from the canvas.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
TStyle objects may be created to define special styles.
TGTextButton * fDrawButton
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...
Int_t GetNodeType(void) const
void Initialize(Bool_t useTMVAStyle=kTRUE)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
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 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".
TString GetString() const
Float_t GetPurity(void) const
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.
TGHorizontalFrame * fButtons
static StatDialogBDT * fThis
virtual Double_t GetNumber() const
Describe directory structure in memory.
static RooMathCoreReg dummy
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TGTextButton * fCloseButton
UInt_t GetTotalTreeDepth() const
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.
virtual void Draw(Option_t *option="")
Draw a canvas.
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
XMLNodePointer_t GetChild(XMLNodePointer_t xmlnode, Bool_t realnode=kTRUE)
returns first child of xml node
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.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
virtual DecisionTreeNode * GetLeft() const
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual DecisionTreeNode * GetRight() const
Color_t GetCanvasColor() const
Short_t GetSelector() const
virtual void Update()
Update canvas pad buffers.
static Int_t CreateGradientColorTable(UInt_t Number, Double_t *Stops, Double_t *Red, Double_t *Green, Double_t *Blue, UInt_t NColors, Float_t alpha=1.)
Static function creating a color table with several connected linear gradients.
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
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 void SetBorderSize(Int_t bordersize=4)
const char * Data() const
void BDT_DeleteTBar(int i)