# Boundary for target in regression not working

**URL:** <https://root-forum.cern.ch/t/boundary-for-target-in-regression-not-working/42988>\
**Category:** TMVA\
**Created:** [January 7, 2021, 9:41am UTC](https://root-forum.cern.ch/t/boundary-for-target-in-regression-not-working/42988 "2021-01-07T09:41:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![testa](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/958977/32.png) [@testa](https://root-forum.cern.ch/u/testa)\
**Post date:** [January 7, 2021, 9:41am UTC](https://root-forum.cern.ch/t/boundary-for-target-in-regression-not-working/42988/1 "2021-01-07T09:41:27Z")

</div>

Dear experts,  
I’m using a MLP multi-target regression.  
I’ve set a target variable with min and max values with:

```auto
dataloader->AddTarget(myvar,"","",xmin,xmax)

```

However when plotting `TestTree->Draw(MLP.myvar)` there are values beyond the boundaries.  
Best, Marianna.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 7, 2021, 9:54am UTC](https://root-forum.cern.ch/t/boundary-for-target-in-regression-not-working/42988/2 "2021-01-07T09:54:31Z")

</div>

I guess @moneta can help you.

---

<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 7, 2021, 10:50am UTC](https://root-forum.cern.ch/t/boundary-for-target-in-regression-not-working/42988/3 "2021-01-07T10:50:12Z")

</div>

Hi,  
The min and max values are not used as a contraint to the target. I think you can use as target a transformed variable like arcsin to the target that will avoid that the prediction will go out of the boundary.

Lorenzo

---

<div class="post-metadata">

**Author:** ![testa](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/958977/32.png) [@testa](https://root-forum.cern.ch/u/testa)\
**Post date:** [January 7, 2021, 12:35pm UTC](https://root-forum.cern.ch/t/boundary-for-target-in-regression-not-working/42988/4 "2021-01-07T12:35:59Z")

</div>

HI, I’ve tried to use as target cond := 80 + 50\*sin(f) to bound f between 30 and 130. In the TestTree cond is correctly bounded, but not the MLP.cond which shows (attached) [cond.pdf](https://root-forum.cern.ch/uploads/short-url/ny5wzj4UvcaKGNn3bIMDxbirto5.pdf) (14.2 KB) [MLPcond.pdf](https://root-forum.cern.ch/uploads/short-url/6riCHn5xDcCwFFUslnx7xpSGdA1.pdf) (13.8 KB) the distribution of f.  
Best, Marianna.

---

<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 8, 2021, 8:46am UTC](https://root-forum.cern.ch/t/boundary-for-target-in-regression-not-working/42988/5 "2021-01-08T08:46:05Z")

</div>

Hi,

It is not clear to me what the plots are exactly. cond.pdf is the input target transformed as  
`80+50*sin(f)` ?  
And MLPcond.pdf is the predicted target by MLP ?

Lorenzo

---

<div class="post-metadata">

**Author:** ![testa](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/958977/32.png) [@testa](https://root-forum.cern.ch/u/testa)\
**Post date:** [January 8, 2021, 9:42am UTC](https://root-forum.cern.ch/t/boundary-for-target-in-regression-not-working/42988/6 "2021-01-08T09:42:09Z")

</div>

Hi Lorenzo,  
yes.  
Marianna.

---

<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 8, 2021, 9:57am UTC](https://root-forum.cern.ch/t/boundary-for-target-in-regression-not-working/42988/7 "2021-01-08T09:57:37Z")

</div>

OK, but then I don’t understand why you have such distribution for the target cond peaked at 30 and 130.  
And what is the problem with the predicted variable ? That is too far off ?

---

<div class="post-metadata">

**Author:** ![testa](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/958977/32.png) [@testa](https://root-forum.cern.ch/u/testa)\
**Post date:** [January 8, 2021, 11:34am UTC](https://root-forum.cern.ch/t/boundary-for-target-in-regression-not-working/42988/8 "2021-01-08T11:34:38Z")

</div>

Hi, the input variable is expected to peak at 30 and 130, because of the sin function peaking at -+1. My question is why the predicted variable is not bounded between 30 and 130, as the input variable.  
Best, Marianna.

---

<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 27, 2021, 11:50am UTC](https://root-forum.cern.ch/t/boundary-for-target-in-regression-not-working/42988/9 "2021-01-27T11:50:23Z")

</div>

Sorry for the late reply. There is no constraints in the algorithm that make the prediction to be bound in a given region, so it is expected that the prediction can be outside the range.
