Home | News | Documentation | Download

TMVAGui() not working for multiple methods of BDT in file

This relates to another post where I didn’t receive a satisfactory answer.

I create the following file MVAAllUpdate.C (14.0 KB) containing the results of training training and multiple TMVA methods. When I then do TMVA::TMVAGui("AllMVA40K.root"), the buttons labeled (10) Decision Trees (BDT) and (11) Decision Tree Control Plots (BDT) in the window titled “TMVA Plotting Macros for Classification” return the error
*** Error in macro "BDT.C": cannot find directory "Method_BDT" in file: AllMVA40K.root
Listing the contents of the file AllMVA40K.root, I get

TFile**		AllMVA40K.root	
 TFile*		AllMVA40K.root	
  TDirectoryFile*		AllResults	AllResults
   KEY: TH2F	CorrelationMatrixS;1	Correlation Matrix (signal)
   KEY: TH2F	CorrelationMatrixB;1	Correlation Matrix (background)
   KEY: TDirectoryFile	InputVariables_Id;1	InputVariables_Id
   KEY: TDirectoryFile	Method_hPolIdealFisher;1	Directory for all Fisher methods
   KEY: TDirectoryFile	Method_vPolIdealFisher;1	Directory for all Fisher methods
   KEY: TDirectoryFile	Method_hPolFisher;1	Directory for all Fisher methods
   KEY: TDirectoryFile	Method_vPolFisher;1	Directory for all Fisher methods
   KEY: TDirectoryFile	Method_hPolBDT;1	Directory for all BDT methods
   KEY: TDirectoryFile	Method_vPolBDT;1	Directory for all BDT methods
   KEY: TDirectoryFile	Method_hPolCorrBDT;1	Directory for all BDT methods
   KEY: TDirectoryFile	Method_vPolCorrBDT;1	Directory for all BDT methods
   KEY: TTree	TestTree;2	TestTree
   KEY: TTree	TestTree;1	TestTree
   KEY: TTree	TrainTree;2	TrainTree
   KEY: TTree	TrainTree;1	TrainTree
  KEY: TDirectoryFile	AllResults;1	AllResults

I think this problem would be resolved if all of the BDT methods were saved under a single Method_BDT TDirectoryFile. For example, rather than having directory paths Method_hPolBDT/hPolBDT and Method_vPolBDT/vPolBDT, how would I go about instead getting Method_BDT/hPolBDT and Method_BDT/vPolBDT?

Hi,

This indeed seems like a bug. A fix has been submitted. You can follow the development here: https://github.com/root-project/root/pull/3253.

Working around this issue in the current version is a bit involved but it can be done using this function:

void BDT(TString dataset, Int_t itree, TString wfile,
         TString methName = "BDT",
         Bool_t useTMVAStyle = kTRUE);

Calling it looks e.g. like this directly in your terminal:

root -l -e 'TMVA::BDT("dataset", 0, "dataset/weights/TMVAClassification_BDT.weights.xml", "BDT")'

Edit: And for the control plots you need something akin to:

root -l -e 'auto f = TFile::Open("TMVA.root"); TMVA::bdtcontrolplots("dataset", (TDirectory *)f->Get("dataset/Method_BDT/BDT"))'

Hi Kim,

Thank you for submitting a fix to this bug. Will this fix apply to other methods as well? For example, if I train two Fisher methods, Class_1 and Class_2, will the training results be saved under the directory paths Method_Fisher/Class_1 and Method_Fisher/Class_2? And will this fix allow differing methods to have the same label? if I were to name two also BDT methods Class_1 and Class_2 as well, can I get a file with directory paths

Method_Fisher/Class_1
Method_Fisher/Class_2
Method_BDT/Class_1
Method_BDT/Class_2

I think because of the bug, BookMethod() doesn’t allow different booking if different methods with the same title.

Hi,

Yes, this fix will apply to all methods. However, TMVA is designed such that the name of a method must be unique, so unfortunately it will, explicitly, not be possible to have both Method_Fisher/Class_1 and Method_BDT/Class_1.

Cheers,
Kim

Thanks, Kim, this answers my questions.

There is now a fix landed in lastest master. This means that this should be included in the v6.18 release!

So if you have two BDT trainings in a single run, they will now be placed in Method_BDT/BDT1 and Method_BDT/BDT2 in the output root file. This means that the GUI should now be able to generate the two plots for all trained BDT’s.

Cheers,
Kim

1 Like