Error using pyMVA exxample

Hello,

the RandomForest PyMVA method in this example is not found:

source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.20.06/x86_64-centos7-gcc48-opt/bin/thisroot.sh
root /afs/cern.ch/user/s/selvaggi/public/4Gerri/TMVAClassification.C

Thanks for your help
Michele

Hi Michele,

It looks like the tutorial in the AFS folder comes from another ROOT version. If you try

root $ROOTSYS/tutorials/tmva/TMVAClassification.C

it should work.

Cheers,
Jakob

Hi,

thanks for your reply.
I must be doing something wrong, but including:

#include “TMVA/MethodPyRandomForest.h”

and calling:

if (Use[“RandomForest”]) // Allow Using random forest
factory->BookMethod( dataloader, TMVA::Types::kPyRandomForest, “PyRandomForest”, “!V:NEstimators=100:Criterion=gini:MaxFeatures=auto:MaxDepth=6:MinSamplesLeaf=1:MinWeightFractionLeaf=0:Bootstrap=kTRUE” );

on the example you pointed gives the same error:

/afs/cern.ch/user/s/selvaggi/public/TMVAClassification.C

Michele

Hm, perhaps @moneta can help?

Hi,

If you have built wROOT with support for PyMVA, you need also to call at the beginning

TMVA::PyMethodBase::PyInitialize();

Lorenzo

Hi,

thanks, I get another error now:

source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.20.06/x86_64-centos7-gcc48-opt/bin/thisroot.sh
root /afs/cern.ch/user/s/selvaggi/public/Classification.C

ImportError: No module named sklearn.ensemble
: Failed to run python code

not sure if I should install and link something myself, but was assuming this was already done, since:

root-config --features

shows:

cxx11 asimage builtin_afterimage builtin_clang builtin_davix builtin_ftgl builtin_gl2ps builtin_glew builtin_llvm builtin_lz4 builtin_lzma builtin_pcre builtin_tbb builtin_unuran builtin_vdt builtin_veccore builtin_xrootd builtin_xxhash builtin_zlib clad dataframe davix exceptions fftw3 fitsio fortran gdml http imt mathmore mlp minuit2 mysql opengl pgsql pyroot roofit runtime_cxxmodules shadowpw shared soversion sqlite ssl tmva tmva-cpu tmva-pymva spectrum unuran vmc vdt veccore x11 xml xrootd

Thanks
Michele

Hi Michele,

You need also to have sklearn installed in your python environment.
So if you do:

python
>>> import sklearn

it should work. If not, you need to install it (e.g. by doing pip install sklearn)

Lorenzo

Thanks Lorenzo,

in case other people might need it, posting here a recipe that works for me on lxplus (despite inconsistency in architecture):

source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.20.06/x86_64-centos7-gcc48-opt/bin/thisroot.sh
source /cvmfs/sft.cern.ch/lcg/releases/LCG_88/scikitlearn/0.17.1/x86_64-slc6-gcc49-opt/scikitlearn-env.sh

It would be great to have access to RMVA bindings as well in the future!

Thanks
Michele

@omazapa might know more if the R packages needed for RMVA are available in cvmfs