# Problem w/ (Py)TMVA std output in ROOT v6.14.04

**URL:** <https://root-forum.cern.ch/t/problem-w-py-tmva-std-output-in-root-v6-14-04/31281>\
**Category:** TMVA\
**Created:** [October 25, 2018, 4:37am UTC](https://root-forum.cern.ch/t/problem-w-py-tmva-std-output-in-root-v6-14-04/31281 "2018-10-25T04:37:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmilesi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@mmilesi](https://root-forum.cern.ch/u/mmilesi)\
**Post date:** [October 25, 2018, 4:37am UTC](https://root-forum.cern.ch/t/problem-w-py-tmva-std-output-in-root-v6-14-04/31281/1 "2018-10-25T04:37:29Z")

</div>

Hello,

I am developing a Python (3) package to manage inputs and booking of different MVA suites and methods etc.

I am seeing a problem with the TMVA stdout, namely it doesn’t get printed out to screen even if the proper options of the TMVA factory and method objects seem to be set correctly.

This is a bit unfortunate, as I don’t know of another way of getting important info such as variable ranking other than looking at the std out (if there are, please tell me!).

Here’s a link to my package, with instructions on how to install it locally (NB: requires Python3.6+ and ROOT v6.14.04) and try to run TMVA on two sample files, also included. Look at README.rst

(approx size 120 MB)  
[https://cernbox.cern.ch/index.php/s/ZAwKdiVy4NaMteI](https://cernbox.cern.ch/index.php/s/ZAwKdiVy4NaMteI)

Many thanks for the help.

Cheers,  
Marco

---

<div class="post-metadata">

**Author:** ![kialbert](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kialbert/32/16537_2.png) [@kialbert](https://root-forum.cern.ch/u/kialbert)\
**Post date:** [October 25, 2018, 10:22am UTC](https://root-forum.cern.ch/t/problem-w-py-tmva-std-output-in-root-v6-14-04/31281/2 "2018-10-25T10:22:43Z")

</div>

Hi Marco,

One thing I can see that could possibly interfere is that you silence all logging up to warning. A lot of TMVA information is printed at the info level and could be suppressed by this.

Otherwise, the TMVA output _should_ end up in the stdout output stream.

Another thing, I would love to hear about your experience with the tmva cross validation interface.

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![mmilesi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@mmilesi](https://root-forum.cern.ch/u/mmilesi)\
**Post date:** [October 26, 2018, 12:08am UTC](https://root-forum.cern.ch/t/problem-w-py-tmva-std-output-in-root-v6-14-04/31281/3 "2018-10-26T00:08:58Z")

</div>

Hi Kim,

I tried to comment out the ROOT msg suppression calls, but the problem is still there.

I have found a hack to force the output to be produced though: I noticed that w/ my code configuration, the only TMVA output messages that get printed are the ones in [https://github.com/root-project/root/blob/v6-14-04/tmva/tmva/src/Factory.cxx#L2018](https://github.com/root-project/root/blob/v6-14-04/tmva/tmva/src/Factory.cxx#L2018)

So, I have added the following two calls before the training routine of the factory is invoked:

```auto
def train(self):

   self.factory.Log().EnableOutput()
   ROOT.TMVA.gConfig().SetSilent(False)

   self.factory.TrainAllMethods()

```

et voila’, the output is there! Now the question is: why was it necessary? I am very puzzled…

On a different note, are the calls to:

```auto
TMVA.Tools.Instance()
TMVA.PyMethodBase.PyInitialize()

```

needed at all? I found them in the tutorial for Keras classification: [https://github.com/root-project/root/blob/v6-14-04/tutorials/tmva/keras/ClassificationKeras.py#L12](https://github.com/root-project/root/blob/v6-14-04/tutorials/tmva/keras/ClassificationKeras.py#L12)

---

<div class="post-metadata">

**Author:** ![kialbert](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kialbert/32/16537_2.png) [@kialbert](https://root-forum.cern.ch/u/kialbert)\
**Post date:** [October 26, 2018, 11:12am UTC](https://root-forum.cern.ch/t/problem-w-py-tmva-std-output-in-root-v6-14-04/31281/4 "2018-10-26T11:12:30Z")

</div>

Hi,

Glad you found a solution. That _should_ not be neccessary. My suspicion is that there is some call somewhere that suppresses the output and the solution you present forces a re-enable.

On the different note: I think the calls can be removed. The `PyInitialize` should be called automatically when needed as a method from PyMVA is created. Likewise for the tools singleton object, it should also be created as needed.

Maybe @swunsch can give some more insight in the `PyInitialize` situation.

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![swunsch](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@swunsch](https://root-forum.cern.ch/u/swunsch)\
**Post date:** [October 26, 2018, 11:28am UTC](https://root-forum.cern.ch/t/problem-w-py-tmva-std-output-in-root-v6-14-04/31281/5 "2018-10-26T11:28:46Z")

</div>

Hi Marco, hi Kim,

Up to now, the call `TMVA.PyMethodBase.PyInitialize()` is needed because the PyMVA library is loaded just on demand. If you don’t invoke this first, the PyMVA methods won’t be found by the factory, e.g., the PyKeras method is not “in the list of methods”.

Best  
Stefan
