Using chopping for TMVA
training/using
Chopping is a technique to use the limited set of data for TMVA training. In this approach data are chopped into several categories and for each category i
TMV is trained using the remaing N-1
categories, and the trained TMVA
is applied to the events from category i
.
Training TMVA
-chopper
The trainig-with-chopping is fairly trivial. First one need to define the number of distinct categories and the function to classify the events into training categories. E.g. for TMVA
training
tSignal = ... ## signal TTree/TChain
tBkg = ... ## background TTree/TChain
## book TMVA trainer
from ostap.tools.chopping import Trainer
trainer = Trainer (
N = N , ## ATTENTION! N is number of categories
category = "137*evt+813*run" , ## ATTENTION! It is a classification function
chop_signal = False , ## chop the signal ? (default)
chop_background = True , ## chop the background ? (default)
...
All other arguments of Trainer
are the same as for regular TMVA
trainer. Arguments chop_signal
and chop_background
defined what sample (or both) to be chopped. The argument caterory described the integer-valued function, used for classification of events. Actually trainer construct classification function as category%N
.
How to choose chopping parameters?Click to expand
Using TMVA
-chopper
Again one needs to define the classification function for input data. Clealry this function should match the one used in training
category = lambda s : int ( s.evt*137 + 813*s.run ) % N ## the classification function
from ostap.tools.chopping import Reader ## ATTENTION
reader = Reader(
N = N , ## number of categories
categoryfunc = category , ## category
...
All other arguments of Reader
are the same as for regular TMVA
reader. The created reader is used exactly in the same way as for no-chopping-case:
tree = ... ## the tree
mlp = reader['MLP'] ## get one method
for i in tree : ## loop over the entries
print 'MLP value is %s' % mlp ( i ) ## get the value