# EvaluateMulticlass method not consistent with training output (repeating floating point values)

**URL:** <https://root-forum.cern.ch/t/evaluatemulticlass-method-not-consistent-with-training-output-repeating-floating-point-values/28468>\
**Category:** TMVA\
**Created:** [March 27, 2018, 3:51pm UTC](https://root-forum.cern.ch/t/evaluatemulticlass-method-not-consistent-with-training-output-repeating-floating-point-values/28468 "2018-03-27T15:51:15Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![swunsch](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@swunsch](https://root-forum.cern.ch/u/swunsch)\
**Post date:** [April 27, 2018, 1:33pm UTC](https://root-forum.cern.ch/t/evaluatemulticlass-method-not-consistent-with-training-output-repeating-floating-point-values/28468/22 "2018-04-27T13:33:15Z")

</div>

I just tried but a json file with a variable list is missing. Can you add this file?

---

<div class="post-metadata">

**Author:** ![jthomasw](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/7feea3/32.png) [@jthomasw](https://root-forum.cern.ch/u/jthomasw)\
**Post date:** [April 27, 2018, 1:37pm UTC](https://root-forum.cern.ch/t/evaluatemulticlass-method-not-consistent-with-training-output-repeating-floating-point-values/28468/23 "2018-04-27T13:37:47Z")

</div>

Sorry, must have run the code directing to my local file. Should be there now.

---

<div class="post-metadata">

**Author:** ![swunsch](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@swunsch](https://root-forum.cern.ch/u/swunsch)\
**Post date:** [April 27, 2018, 1:52pm UTC](https://root-forum.cern.ch/t/evaluatemulticlass-method-not-consistent-with-training-output-repeating-floating-point-values/28468/24 "2018-04-27T13:52:39Z")

</div>

A file is missing:

```auto
Error in <TFile::TFile>: file samples/DiLepTR_ttV_bInclude.root does not exist

```

I tried to replace it with `samples/DiLepSR_ttV_bInclude.root`, but this file is corrputed.

---

<div class="post-metadata">

**Author:** ![jthomasw](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/7feea3/32.png) [@jthomasw](https://root-forum.cern.ch/u/jthomasw)\
**Post date:** [April 27, 2018, 2:14pm UTC](https://root-forum.cern.ch/t/evaluatemulticlass-method-not-consistent-with-training-output-repeating-floating-point-values/28468/25 "2018-04-27T14:14:16Z")

</div>

Can you let me know if they are ok now? I’ve copied them over again as I suspect something went wrong during the copy.

---

<div class="post-metadata">

**Author:** ![swunsch](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@swunsch](https://root-forum.cern.ch/u/swunsch)\
**Post date:** [April 27, 2018, 3:23pm UTC](https://root-forum.cern.ch/t/evaluatemulticlass-method-not-consistent-with-training-output-repeating-floating-point-values/28468/26 "2018-04-27T15:23:14Z")

</div>

Besides the fact that your example script was not really runnable, here the main issue i’ve found:

You are booking the variables with this code:

```python
    branches = {}
    for key, value in new_variable_list:
        branches[key] = array('f', [-999])
        reader.AddVariable(str(key), branches[key])

```

The problem is that your branches are of the `D` (so `double`) but you are using a `f` (`float`) array. hence, the interpretation of the entry in, e.g., `branches["maxeta"][0]` are wrong. Compare to `tree.maxeta` in your eventloop!

You’ll encounter following problem. The TMVA reader does allow only integer or float values. Therefore, you have to convert the inputs somehow to float. Most easily you can do this by booking the reader with arrays of floats but the `tree.SetBranchAddress(...)` with arrays of doubles. Then, you can simply copy with `array_float[0]=array_double[0]`. Not the nicest solution, but I get reasonable shapes without spikes.

---

<div class="post-metadata">

**Author:** ![jthomasw](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/7feea3/32.png) [@jthomasw](https://root-forum.cern.ch/u/jthomasw)\
**Post date:** [April 30, 2018, 9:40am UTC](https://root-forum.cern.ch/t/evaluatemulticlass-method-not-consistent-with-training-output-repeating-floating-point-values/28468/27 "2018-04-30T09:40:35Z")

</div>

Ok strange, script seemed to work my end so sorry about that. Anyway, the suggested fix works so that’s excellent.

Thanks a lot Stefan

[Previous page](https://root-forum.cern.ch/t/evaluatemulticlass-method-not-consistent-with-training-output-repeating-floating-point-values/28468.md?page=1)
