This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
mva:mva [2016/08/06 12:43] – [Parameters to tune] iwn | mva:mva [2023/06/01 13:28] – [Tutorials and examples] iwn | ||
---|---|---|---|
Line 8: | Line 8: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// | ||
When using the neural netwerk method MLP, you might need ROOT 5.34.0.0 or newer, to have larger buffer for the xml reader, for example: | When using the neural netwerk method MLP, you might need ROOT 5.34.0.0 or newer, to have larger buffer for the xml reader, for example: | ||
- | < | + | < |
. / | . / | ||
</ | </ | ||
- | |||
Line 20: | Line 20: | ||
To run the MVA in python on a signal tree '' | To run the MVA in python on a signal tree '' | ||
- | < | + | < |
from ROOT import TFile, TTree, TMVA, TCut | from ROOT import TFile, TTree, TMVA, TCut | ||
f_out = TFile(" | f_out = TFile(" | ||
Line 34: | Line 34: | ||
</ | </ | ||
- | In the empty quote marks you can add cuts or options. More information on can be found on the [[https:// | + | In the empty quote marks you can add cuts or options. More information on can be found in section 3.1 in the [[http:// |
Then you can book multiple methods like the BDT and MLP for different parameters: | Then you can book multiple methods like the BDT and MLP for different parameters: | ||
- | < | + | < |
factory.BookMethod( TMVA.Types.kBDT, | factory.BookMethod( TMVA.Types.kBDT, | ||
factory.BookMethod( TMVA.Types.kBDT, | factory.BookMethod( TMVA.Types.kBDT, | ||
Line 50: | Line 50: | ||
Finally train, test and evaluate all the booked methods: | Finally train, test and evaluate all the booked methods: | ||
- | < | + | < |
factory.TrainAllMethods() | factory.TrainAllMethods() | ||
factory.TestAllMethods() | factory.TestAllMethods() | ||
Line 56: | Line 56: | ||
f_out.Close() | f_out.Close() | ||
</ | </ | ||
- | |||
Line 63: | Line 62: | ||
The factory will output weights in a XML file you can use to apply to a tree that contains the same variable. | The factory will output weights in a XML file you can use to apply to a tree that contains the same variable. | ||
- | < | + | < |
reader = TMVA.Reader() | reader = TMVA.Reader() | ||
vars = [ ] | vars = [ ] | ||
Line 69: | Line 68: | ||
vars.append(array(' | vars.append(array(' | ||
reader.AddVariable(name, | reader.AddVariable(name, | ||
- | reader.BookMVA(TMVAClassification.weights.xml" | + | reader.BookMVA("TMVAClassification.weights.xml" |
for i in range(len(config.varNames)): | for i in range(len(config.varNames)): | ||
tree.SetBranchAddress(config.varNames[i], | tree.SetBranchAddress(config.varNames[i], | ||
Line 89: | Line 88: | ||
* '' | * '' | ||
* '' | * '' | ||
- | * '' | + | * '' |
* '' | * '' | ||
Line 107: | Line 106: | ||
* [[https:// | * [[https:// | ||
* [[mva: | * [[mva: | ||
+ | * [[https:// | ||
+ | |||
+ | |||
+ | ===== Other information ===== | ||
+ | |||
+ | * The working principles of a [[https:// | ||
+ | * [[https:// | ||
+ | * TMVA BibTex reference: | ||
+ | <code latex> | ||
+ | @article{TMVA, | ||
+ | title = {TMVA: Toolkit for Multivariate Data Analysis}, | ||
+ | author | ||
+ | | ||
+ | von Toerne, Eckhard and Voss, Helge}, | ||
+ | journal | ||
+ | volume | ||
+ | year = {2007}, | ||
+ | month = {Mar}, | ||
+ | pages = {040}, | ||
+ | url = {http:// | ||
+ | reportNumber | ||
+ | eprint | ||
+ | archivePrefix = {arXiv}, | ||
+ | primaryClass | ||
+ | SLACcitation | ||
+ | } | ||
+ | </ |