I use TMVA code for fitting data using BDT method.I complete more 70% code steps but isssues toward me and i cant fix them especially in the end part code
// Add data to the DataLoader
loader.AddTrainingEvent({b1_pt, b1_eta, b2_pt, b2_eta, h_mass,h_pt,h_eta,DR_b,jet_pt,jet_eta,jet_phi,jet_ET,jet_mass,
jet_DeltaEta, jet_Deltaphi, jet_bTag, jet_EhadOverEem, missingET_MET,missingEt_Phi,scalarHT_HT});
}
Thanks for the post. Let me add the expert in the loop @moneta .
In the meantime, could you please perhaps be a bit more specific? What are the issues you are facing?
Forshort time,i started by Histanalysis.c to generate file root .this part is completed. After than i began to use BDT_classification.C that based on TMVAclassification that use BDTmethod.some issues appeared as i mention in first successive message…
Thanks
Ahmed
Looking at your code, it seems a bit strange. You assign teh events for training directly from the histogram. But Is your plan to train on the bin content values and not on the variables? An histogram is like an event situated at the bin center and weighted by the bin content.
Also, the error you are getting is propbably because you assign only the training event, but you need to add also test events and in addition you need to call the function PrepareTrainingAndTestTree as it is done in the tutorial TMVAClassification.C
Hi,
You need to add the testing events and call the PrepareTrainingAndTestTree fucntion, otherwise it will not work
However, as I mentioned early, your code does not make much sense to me,. by adding bin contents as training values. You need first on how you want to train your BDT and which events you want to use
Hello Dr @moneta,
I understand your mean partially.do you mean to i use TMVA must be for TTree not use hostograms ?. Because when i add PrepareTrainingAndTestTree
,run issues appeared me .
في الثلاثاء، ١٢ نوفمبر ٢٠٢٤، ١١:٢٦ ص Lorenzo Moneta via ROOT Forum <root.discourse@cern.ch> كتب:
Hi,
The issue happens because you need to add training signal and traiing background events and also testing events for the two classes.
I attach here an example working training from histograms. It uses only one variable, but you can extend to your case of multiple variables. It is important you add both training and test events for both classes. If you have a single histogram you would need to split the histogram in two.
Hi Dr Lorenzo,
i follow all steps by adding train and test event but can nothing any data after running the code
ahmeedsayed@EndeavourOS TMVAHist]$ root -l
root [0] .L BDT_Classification.cpp
root [1] BDT_Classification()
Factory : Booking method: BDT
:
<WARNING> : Method BDT is not capable of handling classification with 0 classes.
Factory : Train all methods
: ...nothing found to train
Factory : Test all methods
: ...nothing found to test
Factory : Evaluate all methods
: ...nothing found to evaluate
BDT training completed using histograms!
(int) 0
root [2]
please insert my code (BDT_Classification) to solve my issues
Notes: to understand me completely in short i start by histAnalysis.C by putting inputfiles.root to constract output histograms.root that i used after that
in TMV (BDT_Classification.cpp) as input.root .
Hi @moneta ,
Are you mean in TMVA_hist in you example
In histogram to split ?! .for one histogram split into two for both of signal and background such as
you mentioned hs1training,hs2test,hb
1training and hb2test wothin TMVA or within
the code of histAbalysis.C
Could you explain by example at least
One variable in my code BDT_Classification.C
To avoid the confusion at me ,please ?
Hi,
Can you please share your code and I can try to adapt for your use case. Are you using the histograms as input distribution for your variables (e.g. b1_pt, b1_eta, etc…) ? You don’t have access to the values used to fill the histograms? Because it would be better to train directly on the ROOT TTree with the initial varaibles than on the histograms
Hi Dr @moneta ,
I actually was still confusion to appy your steps till i applied them successfully.Thank alot Dr Moneta for your a great effort But still i have a single problem espectially if I apply cuts, the code make issues such that
[ahmeedsayed@EndeavourOS TMVAHist]$ root -l
root [0] .L BDT_Classification.cpp
root [1] BDT_Classification()
DataSetInfo : [dataset] : Added class "Signal"
DataSetInfo : [dataset] : Added class "Background"
: Add Tree TrainAssignTree_Signal of type Signal with 3000 events
: Add Tree TestAssignTree_Signal of type Signal with 3000 events
: Add Tree TrainAssignTree_Background of type Background with 3000 events
: Add Tree TestAssignTree_Background of type Background with 3000 events
: Dataset[dataset] : Class index : 0 name : Signal
: Dataset[dataset] : Class index : 1 name : Background
Factory : Booking method: BDT
:
: Rebuilding Dataset dataset
: Building event vectors for type 0 Signal
: Dataset[dataset] : create input formulas for tree TrainAssignTree_Signal
: Building event vectors for type 1 Signal
: Dataset[dataset] : create input formulas for tree TestAssignTree_Signal
: Building event vectors for type 0 Background
: Dataset[dataset] : create input formulas for tree TrainAssignTree_Background
: Building event vectors for type 1 Background
: Dataset[dataset] : create input formulas for tree TestAssignTree_Background
DataSetFactory : [dataset] : Number of events in input trees
: Dataset[dataset] : Signal requirement: "(b1_pt > 40 && b2_pt > 30 && h_mass > 40 && h_pt > 40 && h_eta < 10 && scalarHT_HT > 60 )"
: Dataset[dataset] : Signal -- number of events passed: 0 / sum of weights: 0
: Dataset[dataset] : Signal -- efficiency : 0
: Dataset[dataset] : Background requirement: "(b1_pt > 40 && b2_pt > 30 && h_mass > 40 && h_pt > 40 && h_eta < 10 && scalarHT_HT > 60 )"
: Dataset[dataset] : Background -- number of events passed: 0 / sum of weights: 0
: Dataset[dataset] : Background -- efficiency : 0
: Dataset[dataset] : you have opted for interpreting the requested number of training/testing events
: to be the number of events AFTER your preselection cuts
:
<FATAL> : Dataset[dataset] : More events requested for training (3000) than available (0)!
***> abort program execution
Error in <TRint::HandleTermInput()>: std::runtime_error caught: FATAL error
root [2]