92 fInput->
Connect(
"ValueSet(Long_t)",
"TMVA::StatDialogBDTReg",
this,
"SetItree()");
108 if(!fWfile.EndsWith(
".xml") ){
109 std::ifstream fin( fWfile );
111 std::cout <<
"*** ERROR: Weight file: " << fWfile <<
" does not exist" << std::endl;
123 std::cout << std::endl;
124 std::cout <<
"*** Huge problem: could not locate term \"NTrees\" in BDT weight file: "
125 << fWfile << std::endl;
126 std::cout <<
"==> panic abort (please contact the TMVA authors)" << std::endl;
127 std::cout << std::endl;
141 if(nodeName==
"Weights") {
148 std::cout <<
"--- Found " << fNtrees <<
" decision trees in weight file" << std::endl;
162 if (xsize>0.15) xsize=0.1;
163 if (
n->GetLeft() != NULL){
169 if (
n->GetRight() != NULL){
189 snprintf( buffer, 25,
"R=%4.1f +- %4.1f",
n->GetResponse(),
n->GetRMS() );
192 if (
n->GetNodeType() == 0){
193 if (
n->GetCutType()){
207 std::cout <<
"--- Reading Tree " << itree <<
" from weight file: " << fWfile << std::endl;
211 if(!fWfile.EndsWith(
".xml") ){
213 std::ifstream fin( fWfile );
215 std::cout <<
"*** ERROR: Weight file: " << fWfile <<
" does not exist" << std::endl;
222 if (itree >= fNtrees) {
223 std::cout <<
"*** ERROR: requested decision tree: " << itree
224 <<
", but number of trained trees only: " << fNtrees << std::endl;
231 while (!dummy.
Contains(
"#VAR")) fin >> dummy;
232 fin >> dummy >> dummy >> dummy;
236 fin >> dummy >> nVars;
240 for (
Int_t i = 0; i < nVars; i++) fin >> vars[i] >> dummy >> dummy >> dummy >> dummy;
241 vars[nVars]=
"FisherCrit";
245 snprintf(buffer, 20,
"Tree %d",itree);
248 fin.getline(
line,256);
257 if (itree >= fNtrees) {
258 std::cout <<
"*** ERROR: requested decision tree: " << itree
259 <<
", but number of trained trees only: " << fNtrees << std::endl;
270 if(nodeName==
"Variables"){
274 for (
Int_t i = 0; i < nVars; i++){
278 vars[nVars]=
"FisherCrit";
280 if(nodeName==
"Weights")
break;
299 UInt_t depth =
d->GetTotalTreeDepth();
302 std::cout <<
"--- Tree depth: " << depth << std::endl;
309 if (!fCanvas) fCanvas =
new TCanvas(
"c1", cbuffer, 200, 0, 1000, 600 );
310 else fCanvas->Clear();
330 intermediate->
AddText(
"Intermediate Nodes");
332 intermediate->
Draw();
334 ydown = ydown - ystep/2.5 -dy;
335 yup = yup - ystep/2.5 -dy;
340 signalleaf->
AddText(
"Leaf Nodes");
357 std::cout <<
"--- Creating image: " << fname << std::endl;
378 std::cout <<
"*** Error in macro \"BDT_Reg.C\": cannot find directory \"Method_BDT\" in file: " << fin << std::endl;
385 std::vector<TString> methname;
386 std::vector<TString> path;
387 std::vector<TString> wfile;
388 while ((key = (
TKey*)next())) {
391 std::cout <<
"*** Error in macro \"BDT_Reg.C\": cannot find sub-directory: " << key->
GetName()
392 <<
" in directory: " << dir->
GetName() << std::endl;
399 if (!strPath || !strWFile) {
400 std::cout <<
"*** Error in macro \"BDT_Reg.C\": could not find TObjStrings \"TrainingPath\" and/or \"WeightFileName\" *** " << std::endl;
401 std::cout <<
"*** Maybe you are using TMVA >= 3.8.15 with an older training target file ? *** " << std::endl;
405 methname.push_back( key->GetName() );
407 wfile .push_back( strWFile->
GetString() );
414 for (
UInt_t im=0; im<path.size(); im++) {
416 if (fname[fname.
Length()-1] !=
'/') fname +=
"/";
419 cbar->
AddButton( fname, macro,
"Plot decision trees from this weight file",
"button" );
447 wfile = dataset+
"/weights/TMVARegression_BDT.weights.xml";
451 std::ifstream fin( wfile );
453 std::cout <<
"*** ERROR: Weight file: " << wfile <<
" does not exist" << std::endl;
457 std::cout <<
"test1";
461 StatDialogBDTReg* gGui =
new StatDialogBDTReg(dataset,
gClient->GetRoot(), wfile, methName, itree );
463 gGui->DrawTree( itree );
winID h TVirtualViewer3D TVirtualGLPainter p
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 composed of a header, followed by consecutive data records (TKey instances) with a wel...
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
void MapWindow() override
map window
A composite frame that layout their children in horizontal way.
This class handles GUI labels.
This class describes layout hints used by the layout classes.
Defines top level windows that interact with the system Window Manager.
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
TGNumberEntry is a number entry input widget with up/down buttons.
virtual void SetLimits(ELimit limits=TGNumberFormat::kNELNoLimits, Double_t min=0, Double_t max=1)
virtual Double_t GetNumber() const
Yield an action as soon as it is clicked.
ROOT GUI Window base class.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Use the TLine constructor to create a simple line.
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
std::vector< TControlBar * > BDTReg_Global__cbar
const char * GetName() const override
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.
void Draw(Option_t *option="") override
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.
Int_t Atoi() const
Return integer value of string.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) 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")