You are here

TMVA Quick start

Getting TMVA

TMVA is built upon ROOT (, so that for TMVA to run ROOT must be installed. Since ROOT version 5.11/06, TMVA is distributed as an integral part of ROOT and can be used from the ROOT prompt without further preparation.

The latest version of ROOT can be found at The advanced user, should she require it, can build ROOT and TMVA from the source distribution. Instructions are found at

Using TMVA

TMVA comes with example jobs for the training phase (this phase actually includes training, testing and evaluation) using the TMVA Factory, as well as the application of the training results in a classification or regression analysis using the TMVA Reader. The training examples are TMVAClassification.C, TMVAMulticlass.C and TMVARegression.C, and the application examples are TMVAClassificationApplication.C, TMVAMulticlassApplication.C and TMVARegressionApplication.C. The above macros (extension .C) are located in the directory $ROOTSYS/tutorials/tmva where $ROOTSYS is the path to your ROOT installation.

Additionally TMVACrossValidation.C shows how cross validation is performed, and examples in $ROOTSYS/tutorials/tmva/keras shows how to use TMVA with keras.

Using the python interface

A number of examples of how to use the TMVA in python is available through SWAN (a web platform for analysis) and can be found at

How to run the code as ROOT macro:

cd $ROOTSYS/tutorials/tmva
# --- For classification:
# run all standard classifiers (takes a while)
$ root -l TMVAClassification.C
# run LD and Likelihood classifiers
$ root -l 'TMVAClassification.C("LD,Likelihood")'
# --- For regression:
# run all regression algorithms n(takes a while)
$ root -l TMVARegression.C
# run LD and k-NN regression algorithms
$ root -l 'TMVARegression.C("LD,KNN")'

At the end of the jobs, a GUI will pop up: try to click through all the buttons; some of the lower buttons are method-specific, and will only work when the corresponding classifiers/regression algorithms have been trained/ tested before (unless they are greyed out)

How to run the code as an executable

# Compile using clang or gcc and run all standard classifiers
$ clang++ \`root-config --cflags --libs\` -lTMVA TMVAClassification.C -o TMVAClassification
$ ./TMVAClassification
# Run only LD and Likelihood classifiers 
$ ./TMVAClassification LD Likelihood
# ... and similarly for regression
# start the GUI
$ root -l -e 'TMVA::TMVAGui()'

How to apply the TMVA methods

cd $ROOTSYS/tutorials/tmva
#--- For classification:
$ root -l TMVAClassificationApplication.C                
$ root -l 'TMVAClassificationApplication.C("LD,Likelihood")'
#... and similar for regression.
#... and similar for executables.