# Full path to state file PyGTBModel\_GTB.PyData is not propagated to the xml file with training weights

**URL:** <https://root-forum.cern.ch/t/full-path-to-state-file-pygtbmodel-gtb-pydata-is-not-propagated-to-the-xml-file-with-training-weights/39013>\
**Category:** TMVA\
**Tags:** python\
**Created:** [April 21, 2020, 1:01pm UTC](https://root-forum.cern.ch/t/full-path-to-state-file-pygtbmodel-gtb-pydata-is-not-propagated-to-the-xml-file-with-training-weights/39013 "2020-04-21T13:01:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![okarache](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/okarache/32/21675_2.png) [@okarache](https://root-forum.cern.ch/u/okarache)\
**Post date:** [April 21, 2020, 1:01pm UTC](https://root-forum.cern.ch/t/full-path-to-state-file-pygtbmodel-gtb-pydata-is-not-propagated-to-the-xml-file-with-training-weights/39013/1 "2020-04-21T13:01:34Z")

</div>

Hello, could you help us to figure out how to force full path to the state file PyGTBModel\_GTB.PyData, please?

We are using ROOT.TMVA.Types.kPyGTB for the training ant testing.  
data loader is called dataset\_pymva: TMVA.DataLoader(‘dataset\_pymva’). When running the training I see the message  
**Saving state file:** dataset\_pymva/weights/PyGTBModel\_GTB.PyData

weights folder was created automatically.

I also see these files created  
: Creating xml weight file: dataset\_pymva/weights/TMVAOutput\_WPhi\_2L1T\_newPyPlotter2\_d\_GTB.weights.xml  
: Creating standalone class: dataset\_pymva/weights/TMVAOutput\_WPhi\_2L1T\_newPyPlotter2\_d\_GTB.class.C

In the standalone code which has nothing to do with this training we need to apply the training to the data set. We only use dataset\_pymva/weights/TMVAOutput\_WPhi\_2L1T\_newPyPlotter2\_d\_GTB.weights.xml for this.  
But here is the problem, in the .xml file there is a path to the .PyData file and path is not full, so the application of the training parameters crashes.  
dataset\_pymva/weights/PyGTBModel\_GTB.PyData

If we modify the path to the .PyData file manually to give full path to the file, then throning is applied ok. How can I force the training to write full path to .PyData training, so that can optimize the application?

I tried to give full path in the data loader as TMVA.DataLoader(‘full\_path/dataset\_pymva’), but this crashed even before saving the .PyData file step with an error:

Error in TFile::GetObjectChecked: The provided key name is invalid.

\*\*\* Break \*\*\* segmentation violation

Many thanks in advance for your help,  
Olena

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [April 22, 2020, 10:07am UTC](https://root-forum.cern.ch/t/full-path-to-state-file-pygtbmodel-gtb-pydata-is-not-propagated-to-the-xml-file-with-training-weights/39013/2 "2020-04-22T10:07:26Z")

</div>

Hi,

You have two options for setting the name of the output training model data.  
The first one you can use the option `FilenameClassifier` when booking the PyGTB model, for example do:

```auto
factory->BookMethod(dataloader, TMVA::Types::kPyGTB, "PyGTB","!V:VarTransform=N:NEstimators=850:Loss=deviance:LearningRate=0.1:Subsample=1:MaxDepth\
=3:MaxFeatures='auto':FilenameClassifier=/tmp/tmva/model_pygtb.data" );

```

The second possibility is to set a different directory for all the outpu model weights (i.e. xml file).  
This you can do (only when using 6.22, because there was a bug before), by setting this configuration option:

```auto
TMVA::gConfig().fIONames.fWeightFileDirPrefix="/tmp/";

```

This will result in having the weights and by default also the model output in the directory  
`/tmp/dataset_pymva/weights`

Best regards

Lorenzo

---

<div class="post-metadata">

**Author:** ![okarache](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/okarache/32/21675_2.png) [@okarache](https://root-forum.cern.ch/u/okarache)\
**Post date:** [April 22, 2020, 2:15pm UTC](https://root-forum.cern.ch/t/full-path-to-state-file-pygtbmodel-gtb-pydata-is-not-propagated-to-the-xml-file-with-training-weights/39013/3 "2020-04-22T14:15:07Z")

</div>

Thank you so much, Lorenzo! Perfect, we will choose of the paths proposed.

With best wishes,  
Olena
