# Is it possible to save TMVA data after training (dataset folder) not in the current dir?

**URL:** <https://root-forum.cern.ch/t/is-it-possible-to-save-tmva-data-after-training-dataset-folder-not-in-the-current-dir/26943>\
**Category:** TMVA\
**Created:** [November 19, 2017, 7:02am UTC](https://root-forum.cern.ch/t/is-it-possible-to-save-tmva-data-after-training-dataset-folder-not-in-the-current-dir/26943 "2017-11-19T07:02:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![p73](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/p73/32/14141_2.png) [@p73](https://root-forum.cern.ch/u/p73)\
**Post date:** [November 19, 2017, 7:02am UTC](https://root-forum.cern.ch/t/is-it-possible-to-save-tmva-data-after-training-dataset-folder-not-in-the-current-dir/26943/1 "2017-11-19T07:02:48Z")

</div>

I am using TMVA methods for classification.  
If I write

```auto
    TMVA::DataLoader* dataloader = new TMVA::DataLoader( "../Data/1400/TMVA/Training/dataset" );

```

I see then after all processes that there is folder `dataset` with weights etc. inside. BUT. At the end of my macro I launch GUI:

```auto
    if ( !gROOT->IsBatch() )
    {
        TMVA::TMVAGui( "../Data/1400/TMVA/ClassificationOut.root" );
    }

```

It appears but when I try to use it pushing the buttons I get messages like

> — Found 0 classifier types  
> ups … no methods found in to plot ROC curve for … give up

But if I wrote instead of the above:

```auto
 TMVA::DataLoader* dataloader = new TMVA::DataLoader( "dataset" );

```

it would work perfectly. What is going on?  
By the way even visually the start pages of GUIs are different:  
 ![1](https://root-forum.cern.ch/uploads/default/original/2X/8/874479b749bb4eff7edd28c21ea0e6a252baefc9.png) ![2](https://root-forum.cern.ch/uploads/default/original/2X/1/1478b4395d2ab96ea44578e77282f65f633a7d5a.png)

---

<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:** [November 19, 2017, 10:59pm UTC](https://root-forum.cern.ch/t/is-it-possible-to-save-tmva-data-after-training-dataset-folder-not-in-the-current-dir/26943/2 "2017-11-19T22:59:44Z")

</div>

Hi,

The name of the dataset should be an identifier, not a path. Because of how the name is treated internally it will mess up the GUI code if there are non-filename characters in it.

TMVA assumes that the output should be written to the current directory. You can always move the generated folders via scripts as a workaround.

I usually run the scripts “the other way around” when I want output at a specific location e.g.

```auto
cd ./path/for/output
root -l ../../path/to/scripts

```

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![p73](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/p73/32/14141_2.png) [@p73](https://root-forum.cern.ch/u/p73)\
**Post date:** [November 20, 2017, 5:56am UTC](https://root-forum.cern.ch/t/is-it-possible-to-save-tmva-data-after-training-dataset-folder-not-in-the-current-dir/26943/3 "2017-11-20T05:56:48Z")

</div>

What if I have some process (say `MainProcess.C`) that includes TMVA training and application processes and I need loop this process over some data array which assumes the creation (or recreation if exists) new folder for each data entry. So I want “dataset” to be in a corresponding folder. I do not want to run `MainProcess.C` every time from new dir (at least not by hand). What am I suppose to do in this case.

Thanks in advance.

---

<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:** [November 20, 2017, 4:21pm UTC](https://root-forum.cern.ch/t/is-it-possible-to-save-tmva-data-after-training-dataset-folder-not-in-the-current-dir/26943/4 "2017-11-20T16:21:40Z")

</div>

What I did last time was to create a Python wrapper that runs the training script in a scratch area and then moves the result to the desired final location.

Sketch of the python script below. Missing error handling, command line arguments and possibly more.

```auto
import argparse
import subprocess
import os

script_path = 'path/to/training/script'
job_name = 'job_name'
final_dir = 'some/path'

scratch_dir = 'path/to/working/dir'

os.chdir(scratch_dir)
subprocess.call('root -l {}'.format(script_path))

os.rename('{}'.format(scratch_dir), '{}/{}'.format(final_dir, job_name))

```

With the `argparse` module it is quite easy to make a script that will loop over a set of training/application scripts. `os.makedirs` could also be useful.

If you end up doing something else, please outline the approach so others can learn 🙂

Cheers,  
Kim
