# Understanding TMVA output for regression using keras with theano backend

**URL:** <https://root-forum.cern.ch/t/understanding-tmva-output-for-regression-using-keras-with-theano-backend/34420>\
**Category:** TMVA\
**Created:** [June 4, 2019, 3:43pm UTC](https://root-forum.cern.ch/t/understanding-tmva-output-for-regression-using-keras-with-theano-backend/34420 "2019-06-04T15:43:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Devin](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/278dde/32.png) [@Devin](https://root-forum.cern.ch/u/Devin)\
**Post date:** [June 4, 2019, 3:43pm UTC](https://root-forum.cern.ch/t/understanding-tmva-output-for-regression-using-keras-with-theano-backend/34420/1 "2019-06-04T15:43:34Z")

</div>

I’m using keras with a theano backend on lxplus, and I’m having trouble understanding the output histograms from a regression problem or even if it’s working properly. I’ve attached my python script and a plot I discuss later.

Basically, I feed it 12 input variables, pass it through one hidden layer with 8 nodes (with relu activation), and read out one output node (linear activation) to predict a 13th variable. This 13th variable—time, in my case— is approximately normally distributed around 0.

I’m able to run without errors on my dataset, and it gives me some evaluation results showing an RMS for the test sample, which I believe should be the RMS for difference between the regression value and the true value. This RMS is significantly lower than the input RMS, so it seems like it’s doing its job.

However, when I try to look through the output plots, they’re a bit hard to decipher, and the documentation doesn’t have much on regression (mostly classification and regression is a side note).

The most confusing one is the plot showing the correlation between (regression - true) vs. true. If the regression is working, shouldn’t this relationship be flat? With my data, it’s a tight distribution with a slope of -1 (see attached plot). The RMS is the same as that quoted in the output on the command line.

Why am I getting such a distribution? Is it set up properly?

[timingRegressionKeras.py](https://root-forum.cern.ch/uploads/default/original/3X/2/3/2354f15faef7280e414642aafaea3a0a232f739b.py) (1.9 KB)  
[Screen Shot 2019-06-04 at 5.19.25 PM.pdf](https://root-forum.cern.ch/uploads/default/original/3X/c/f/cf0d2fc06a962be6230a19cc566e04133eafabb2.pdf) (141.3 KB)

---

<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:** [June 5, 2019, 7:06am UTC](https://root-forum.cern.ch/t/understanding-tmva-output-for-regression-using-keras-with-theano-backend/34420/2 "2019-06-05T07:06:35Z")

</div>

I think @moneta can help you.

---

<div class="post-metadata">

**Author:** ![Devin](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/278dde/32.png) [@Devin](https://root-forum.cern.ch/u/Devin)\
**Post date:** [June 11, 2019, 12:51pm UTC](https://root-forum.cern.ch/t/understanding-tmva-output-for-regression-using-keras-with-theano-backend/34420/3 "2019-06-11T12:51:24Z")

</div>

Anyone have any thoughts? I’m still confused about how to interpret these results. @moneta maybe?

---

<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:** [June 14, 2019, 10:37am UTC](https://root-forum.cern.ch/t/understanding-tmva-output-for-regression-using-keras-with-theano-backend/34420/4 "2019-06-14T10:37:58Z")

</div>

Hi,

Indeed as you say the correlation plot output-truth vs truth should be flat if the regression is working. A tight slope of -1 is consistent with the output being always 0… Maybe posting the output log will give some more insight of what is going on?

Also maybe @swunsch can enlighten us?

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![Devin](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/278dde/32.png) [@Devin](https://root-forum.cern.ch/u/Devin)\
**Post date:** [June 14, 2019, 10:58am UTC](https://root-forum.cern.ch/t/understanding-tmva-output-for-regression-using-keras-with-theano-backend/34420/5 "2019-06-14T10:58:13Z")

</div>

Hi Kim,

If the output were always 0, wouldn’t the slope be exactly -1? Here, there’s apparently some spread, so it seems like it’s doing something…

I’ve attached an output log (note: this might have slightly different settings, but the results are qualitatively the same).

Best,  
Devin

[TMVAOutput.txt](https://root-forum.cern.ch/uploads/default/original/3X/e/7/e7577cd10acd1f6507595f23847349d19769b464.txt) (39.0 KB)

---

<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:** [June 14, 2019, 11:23am UTC](https://root-forum.cern.ch/t/understanding-tmva-output-for-regression-using-keras-with-theano-backend/34420/6 "2019-06-14T11:23:02Z")

</div>

Hi,

> [@Devin](#):
>
> If the output were always 0, wouldn’t the slope be exactly -1? Here, there’s apparently some spread, so it seems like it’s doing something…

Sure! I only meant the flatter the better 🙂

I’ll try taking a look at the log ”soon”…

Cheers,  
Kim

---

<div class="post-metadata">

**Author:** ![Chinmay](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@Chinmay](https://root-forum.cern.ch/u/Chinmay)\
**Post date:** [February 10, 2023, 9:48am UTC](https://root-forum.cern.ch/t/understanding-tmva-output-for-regression-using-keras-with-theano-backend/34420/7 "2023-02-10T09:48:00Z")

</div>

Hi, If I have more than one variable that is added by using Addvariable, then how many target variable I have to add and how?
