As input data is used a toy-MC sample consisting of two guassian distributions.
The output file "TMVA.root" can be analysed with the use of dedicated macros (simply say: root -l <macro.C>), which can be conveniently invoked through a GUI that will appear at the end of the run of this macro. Launch the GUI via the command:
Cross evaluation is a special case of k-folds cross validation where the splitting into k folds is computed deterministically. This ensures that the a given event will always end up in the same fold.
In addition all resulting classifiers are saved and can be applied to new data using MethodCrossValidation
. One requirement for this to work is a splitting function that is evaluated for each event to determine into what fold it goes (for training/evaluation) or to what classifier (for application).
Cross evaluation uses a deterministic split to partition the data into folds called the split expression. The expression can be any valid TFormula
as long as all parts used are defined.
For each event the split expression is evaluated to a number and the event is put in the fold corresponding to that number.
The split expression has access to all spectators and variables defined in the dataloader. Additionally, the number of folds in the split can be accessed with NumFolds
(or numFolds
).
DataSetInfo : [dataset] : Added class "Signal"
: Add Tree of type Signal with 1000 events
DataSetInfo : [dataset] : Added class "Background"
: Add Tree of type Background with 1000 events
: Evaluate method: BDTG
<HEADER> Factory : Booking method: BDTG_fold1
:
<HEADER> BDTG_fold1 : #events: (reweighted) sig: 499.5 bkg: 499.5
: #events: (unweighted) sig: 493 bkg: 506
: Training 100 Decision Trees ... patience please
: Elapsed time for training with 999 events: 0.0475 sec
<HEADER> BDTG_fold1 : [dataset] : Evaluation of BDTG_fold1 on training sample (999 events)
: Elapsed time for evaluation of 999 events: 0.0036 sec
: Creating xml weight file: dataset/weights/TMVACrossValidation_BDTG_fold1.weights.xml
: Creating standalone class: dataset/weights/TMVACrossValidation_BDTG_fold1.class.C
<HEADER> Factory : Test all methods
<HEADER> Factory : Test method: BDTG_fold1 for Classification performance
:
<HEADER> BDTG_fold1 : [dataset] : Evaluation of BDTG_fold1 on testing sample (999 events)
: Elapsed time for evaluation of 999 events: 0.00362 sec
<HEADER> Factory : Evaluate all methods
<HEADER> Factory : Evaluate classifier: BDTG_fold1
:
<HEADER> BDTG_fold1 : [dataset] : Loop over test events and fill histograms with classifier response...
:
<HEADER> Factory : Thank you for using TMVA!
: For citation information, please visit: http://tmva.sf.net/citeTMVA.html
<HEADER> Factory : Booking method: BDTG_fold2
:
<HEADER> BDTG_fold2 : #events: (reweighted) sig: 499.5 bkg: 499.5
: #events: (unweighted) sig: 506 bkg: 493
: Training 100 Decision Trees ... patience please
: Elapsed time for training with 999 events: 0.0491 sec
<HEADER> BDTG_fold2 : [dataset] : Evaluation of BDTG_fold2 on training sample (999 events)
: Elapsed time for evaluation of 999 events: 0.00348 sec
: Creating xml weight file: dataset/weights/TMVACrossValidation_BDTG_fold2.weights.xml
: Creating standalone class: dataset/weights/TMVACrossValidation_BDTG_fold2.class.C
<HEADER> Factory : Test all methods
<HEADER> Factory : Test method: BDTG_fold2 for Classification performance
:
<HEADER> BDTG_fold2 : [dataset] : Evaluation of BDTG_fold2 on testing sample (999 events)
: Elapsed time for evaluation of 999 events: 0.00352 sec
<HEADER> Factory : Evaluate all methods
<HEADER> Factory : Evaluate classifier: BDTG_fold2
:
<HEADER> BDTG_fold2 : [dataset] : Loop over test events and fill histograms with classifier response...
:
<HEADER> Factory : Thank you for using TMVA!
: For citation information, please visit: http://tmva.sf.net/citeTMVA.html
<HEADER> Factory : Booking method: BDTG
:
: Reading weightfile: dataset/weights/TMVACrossValidation_BDTG_fold1.weights.xml
: Reading weight file: dataset/weights/TMVACrossValidation_BDTG_fold1.weights.xml
: Reading weightfile: dataset/weights/TMVACrossValidation_BDTG_fold2.weights.xml
: Reading weight file: dataset/weights/TMVACrossValidation_BDTG_fold2.weights.xml
: Evaluate method: Fisher
<HEADER> Factory : Booking method: Fisher_fold1
:
<HEADER> Fisher_fold1 : Results for Fisher coefficients:
: -----------------------
: Variable: Coefficient:
: -----------------------
: x: +0.471
: y: +0.440
: (offset): +0.000
: -----------------------
: Elapsed time for training with 999 events: 0.000377 sec
<HEADER> Fisher_fold1 : [dataset] : Evaluation of Fisher_fold1 on training sample (999 events)
: Elapsed time for evaluation of 999 events: 7.2e-05 sec
: Creating xml weight file: dataset/weights/TMVACrossValidation_Fisher_fold1.weights.xml
: Creating standalone class: dataset/weights/TMVACrossValidation_Fisher_fold1.class.C
<HEADER> Factory : Test all methods
<HEADER> Factory : Test method: Fisher_fold1 for Classification performance
:
<HEADER> Fisher_fold1 : [dataset] : Evaluation of Fisher_fold1 on testing sample (999 events)
: Elapsed time for evaluation of 999 events: 0.000124 sec
<HEADER> Factory : Evaluate all methods
<HEADER> Factory : Evaluate classifier: Fisher_fold1
:
<HEADER> Fisher_fold1 : [dataset] : Loop over test events and fill histograms with classifier response...
:
<HEADER> Factory : Thank you for using TMVA!
: For citation information, please visit: http://tmva.sf.net/citeTMVA.html
<HEADER> Factory : Booking method: Fisher_fold2
:
<HEADER> Fisher_fold2 : Results for Fisher coefficients:
: -----------------------
: Variable: Coefficient:
: -----------------------
: x: +0.475
: y: +0.463
: (offset): +0.020
: -----------------------
: Elapsed time for training with 999 events: 0.000263 sec
<HEADER> Fisher_fold2 : [dataset] : Evaluation of Fisher_fold2 on training sample (999 events)
: Elapsed time for evaluation of 999 events: 6.99e-05 sec
: Creating xml weight file: dataset/weights/TMVACrossValidation_Fisher_fold2.weights.xml
: Creating standalone class: dataset/weights/TMVACrossValidation_Fisher_fold2.class.C
<HEADER> Factory : Test all methods
<HEADER> Factory : Test method: Fisher_fold2 for Classification performance
:
<HEADER> Fisher_fold2 : [dataset] : Evaluation of Fisher_fold2 on testing sample (999 events)
: Elapsed time for evaluation of 999 events: 9.01e-05 sec
<HEADER> Factory : Evaluate all methods
<HEADER> Factory : Evaluate classifier: Fisher_fold2
:
<HEADER> Fisher_fold2 : [dataset] : Loop over test events and fill histograms with classifier response...
:
<HEADER> Factory : Thank you for using TMVA!
: For citation information, please visit: http://tmva.sf.net/citeTMVA.html
<HEADER> Factory : Booking method: Fisher
:
: Reading weightfile: dataset/weights/TMVACrossValidation_Fisher_fold1.weights.xml
: Reading weight file: dataset/weights/TMVACrossValidation_Fisher_fold1.weights.xml
: Reading weightfile: dataset/weights/TMVACrossValidation_Fisher_fold2.weights.xml
: Reading weight file: dataset/weights/TMVACrossValidation_Fisher_fold2.weights.xml
<HEADER> Factory : [dataset] : Create Transformation "I" with events from all classes.
:
<HEADER> : Transformation, Variable selection :
: Input : variable 'x' <---> Output : variable 'x'
: Input : variable 'y' <---> Output : variable 'y'
<HEADER> TFHandler_Factory : Variable Mean RMS [ Min Max ]
: -----------------------------------------------------------
: x: -0.014284 1.4061 [ -4.1075 4.0969 ]
: y: -0.0066370 1.4204 [ -4.8520 4.0761 ]
: -----------------------------------------------------------
: Ranking input variables (method unspecific)...
<HEADER> IdTransformation : Ranking result (top variable is best ranked)
: --------------------------
: Rank : Variable : Separation
: --------------------------
: 1 : x : 5.429e-01
: 2 : y : 5.230e-01
: --------------------------
: Elapsed time for training with 1998 events: 4.77e-06 sec
<HEADER> BDTG : [dataset] : Evaluation of BDTG on training sample (1998 events)
: Elapsed time for evaluation of 1998 events: 0.00668 sec
: Creating xml weight file: dataset/weights/TMVACrossValidation_BDTG.weights.xml
: Creating standalone class: dataset/weights/TMVACrossValidation_BDTG.class.C
<WARNING> <WARNING> : MakeClassSpecificHeader not implemented for CrossValidation
<WARNING> <WARNING> : MakeClassSpecific not implemented for CrossValidation
: Elapsed time for training with 1998 events: 4.05e-06 sec
<HEADER> Fisher : [dataset] : Evaluation of Fisher on training sample (1998 events)
: Elapsed time for evaluation of 1998 events: 0.000491 sec
: Creating xml weight file: dataset/weights/TMVACrossValidation_Fisher.weights.xml
: Creating standalone class: dataset/weights/TMVACrossValidation_Fisher.class.C
<WARNING> <WARNING> : MakeClassSpecificHeader not implemented for CrossValidation
<WARNING> <WARNING> : MakeClassSpecific not implemented for CrossValidation
<HEADER> Factory : Test all methods
<HEADER> Factory : Test method: BDTG for Classification performance
:
<HEADER> BDTG : [dataset] : Evaluation of BDTG on testing sample (1998 events)
: Elapsed time for evaluation of 1998 events: 0.00662 sec
<HEADER> Factory : Test method: Fisher for Classification performance
:
<HEADER> Fisher : [dataset] : Evaluation of Fisher on testing sample (1998 events)
: Elapsed time for evaluation of 1998 events: 0.000473 sec
<HEADER> Factory : Evaluate all methods
<HEADER> Factory : Evaluate classifier: BDTG
:
<HEADER> BDTG : [dataset] : Loop over test events and fill histograms with classifier response...
:
<HEADER> TFHandler_BDTG : Variable Mean RMS [ Min Max ]
: -----------------------------------------------------------
: x: -0.014284 1.4061 [ -4.1075 4.0969 ]
: y: -0.0066370 1.4204 [ -4.8520 4.0761 ]
: -----------------------------------------------------------
<HEADER> Factory : Evaluate classifier: Fisher
:
<HEADER> Fisher : [dataset] : Loop over test events and fill histograms with classifier response...
:
<HEADER> TFHandler_Fisher : Variable Mean RMS [ Min Max ]
: -----------------------------------------------------------
: x: -0.014284 1.4061 [ -4.1075 4.0969 ]
: y: -0.0066370 1.4204 [ -4.8520 4.0761 ]
: -----------------------------------------------------------
:
: Evaluation results ranked by best signal efficiency and purity (area)
: -------------------------------------------------------------------------------------------------------------------
: DataSet MVA
: Name: Method: ROC-integ
: dataset Fisher : 0.971
: dataset BDTG : 0.967
: -------------------------------------------------------------------------------------------------------------------
:
: Testing efficiency compared to training efficiency (overtraining check)
: -------------------------------------------------------------------------------------------------------------------
: DataSet MVA Signal efficiency: from test sample (from training sample)
: Name: Method: @B=0.01 @B=0.10 @B=0.30
: -------------------------------------------------------------------------------------------------------------------
: dataset Fisher : 0.654 (0.654) 0.923 (0.923) 0.980 (0.980)
: dataset BDTG : 0.630 (0.630) 0.920 (0.920) 0.976 (0.976)
: -------------------------------------------------------------------------------------------------------------------
:
<HEADER> Dataset:dataset : Created tree 'TestTree' with 1998 events
:
<HEADER> Dataset:dataset : Created tree 'TrainTree' with 1998 events
:
<HEADER> Factory : Thank you for using TMVA!
: For citation information, please visit: http://tmva.sf.net/citeTMVA.html
: Evaluation done.
Summary for method BDT
Fold 0: ROC int: 0.96956, BkgEff@SigEff=0.3: 0.982
Fold 1: ROC int: 0.966535, BkgEff@SigEff=0.3: 0.97
Summary for method Fisher
Fold 0: ROC int: 0.971244, BkgEff@SigEff=0.3: 0.981
Fold 1: ROC int: 0.970957, BkgEff@SigEff=0.3: 0.981
==> Wrote root file: TMVA.root
==> TMVACrossValidation is done!
(int) 0