# Clearing fStorage and fHistAlias (from Results class) from Factory Training/Testing

**URL:** <https://root-forum.cern.ch/t/clearing-fstorage-and-fhistalias-from-results-class-from-factory-training-testing/37059>\
**Category:** TMVA\
**Created:** [December 4, 2019, 7:36pm UTC](https://root-forum.cern.ch/t/clearing-fstorage-and-fhistalias-from-results-class-from-factory-training-testing/37059 "2019-12-04T19:36:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel-sunyou-li](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/daniel-sunyou-li/32/20400_2.png) [@daniel-sunyou-li](https://root-forum.cern.ch/u/daniel-sunyou-li)\
**Post date:** [December 4, 2019, 7:36pm UTC](https://root-forum.cern.ch/t/clearing-fstorage-and-fhistalias-from-results-class-from-factory-training-testing/37059/1 "2019-12-04T19:36:36Z")

</div>

I am using TMVA.Factory() to train/test/evaluate a DNN in Python. I was wondering how to clear the histograms stored in the associated Results object created by factory.

More specifically, I get issues when iterating over the TrainAllMethods(), TestAllMethods() and EvaluateAllMethods(). In the second iteration, when I try running EvaluateAllMethods(), I get the following error:

_FATAL: Alias MVA\_S already exists in results storage_

and when I try to run TMVA.Results.Delete(), I get the error:

_unbound method TMVA::Results::Delete must be called with a TMVA::Results instance as first argument_

but I am unable to find where the Results class is instantiated by Factory. I essentially want to use the function defined [here](http://root.cern.ch/doc/v608/Results_8cxx_source.html#l00153) for the results produced by Factory training/testing done in python.

---

<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:** [December 6, 2019, 5:25pm UTC](https://root-forum.cern.ch/t/clearing-fstorage-and-fhistalias-from-results-class-from-factory-training-testing/37059/2 "2019-12-06T17:25:44Z")

</div>

HI,

I am not sure I have understood the cause of your problem. Could you please post your macro or code reproducing this ?

Thank you

Lorenzo

---

<div class="post-metadata">

**Author:** ![mlouka](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@mlouka](https://root-forum.cern.ch/u/mlouka)\
**Post date:** [January 17, 2024, 3:24pm UTC](https://root-forum.cern.ch/t/clearing-fstorage-and-fhistalias-from-results-class-from-factory-training-testing/37059/3 "2024-01-17T15:24:46Z")

</div>

Hi @daniel-sunyou-li  
I’m facing the same problem  
did you manage to solve it please ?

Magdy

---

<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:** [January 18, 2024, 10:50am UTC](https://root-forum.cern.ch/t/clearing-fstorage-and-fhistalias-from-results-class-from-factory-training-testing/37059/4 "2024-01-18T10:50:00Z")

</div>

Hello.

I can reproduce this problem running again the Training/Test/Evaluation using the same method and same dataset. I will investigate it, but I would like to understand it better what is your use case to run again the training/testing workflow ?

Best regards

Lorenzo

---

<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:** [January 18, 2024, 2:36pm UTC](https://root-forum.cern.ch/t/clearing-fstorage-and-fhistalias-from-results-class-from-factory-training-testing/37059/5 "2024-01-18T14:36:04Z")

</div>

Hi,  
I have investigate this and the solution for having a second iteration of Train/Test/Evaluate is the following:

- you need to create a new TMVA::Factory instance, but you can use the previously existing data loader. This is needed to have a new ROOT output file for the new training/test results
- book again your TMVA method
- delete the existing Results() if you are re-using the DataLoader

For deleting the Results class you should do as following:

```auto
 auto data = dataloader->GetDataSetInfo().GetDataSet();
 data->DeleteAllResults(TMVA::Types::kTraining, TMVA::Types::kClassification);
 data->DeleteAllResults(TMVA::Types::kTesting, TMVA::Types::kClassification);

```

I hope it helps

Lorenzo
