# TMVA regression target limits

**URL:** <https://root-forum.cern.ch/t/tmva-regression-target-limits/49973>\
**Category:** TMVA\
**Created:** [May 13, 2022, 5:32pm UTC](https://root-forum.cern.ch/t/tmva-regression-target-limits/49973 "2022-05-13T17:32:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lilina](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lilina/32/28468_2.png) [@lilina](https://root-forum.cern.ch/u/lilina)\
**Post date:** [May 13, 2022, 5:32pm UTC](https://root-forum.cern.ch/t/tmva-regression-target-limits/49973/1 "2022-05-13T17:32:49Z")

</div>

Hi,  
I am new to TMVA and I am performing a multi-regression with DNN-GPU following the TMVARegression.C and the TMVARegressionApplication.C from the tutorial.

I have to constrain one of the targets to be greater than zero, in a way that the created model for this target is always positive for any values of the variables used later on the TMVARegressionApplication.C. So, I need to constrain the predicted value for the target obtained with TMVARegressionApplication.C, to be positive for any value of the input variables.

I have tried setting a minimum with:

```auto
void TMVA::DataLoader::AddTarget ( const TString & expression,
		const TString & title = "",
		const TString & unit = "",
		Double_t min = 0,
		Double_t max = 0 
	) 	

```

But, I still get negative values of the target when getting a prediction after running the TMVARegresionApplication.C

Also when running the TMVARegression.C with more than one target, the canvas that shows the average deviation between the regression value and the true value on the launched TMVA GUI does not open.

Many thanks for your suggestions!

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [May 15, 2022, 6:35pm UTC](https://root-forum.cern.ch/t/tmva-regression-target-limits/49973/2 "2022-05-15T18:35:08Z")

</div>

Hi @lilina; I am sure @moneta can help you with this.

Cheers,  
J.

---

<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:** [May 16, 2022, 7:38am UTC](https://root-forum.cern.ch/t/tmva-regression-target-limits/49973/3 "2022-05-16T07:38:03Z")

</div>

Hi,

There is no support for this natively in TMVA. One thing you could do is trying to regress on the log(Y) and then do an exponentiation afterwards to get the target values.  
Or you can maybe use a modified loss function which penalises the negative values.  
The `min` and `max` value above will refer to the input target values not the output ones.

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![lilina](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lilina/32/28468_2.png) [@lilina](https://root-forum.cern.ch/u/lilina)\
**Post date:** [May 20, 2022, 4:42pm UTC](https://root-forum.cern.ch/t/tmva-regression-target-limits/49973/4 "2022-05-20T16:42:07Z")

</div>

Thank you so much for clarifying this. I am working with your suggestions. I appreciate your help very much!
