# Plotting loss/accuracy vs. epoch with PyKeras

**URL:** <https://root-forum.cern.ch/t/plotting-loss-accuracy-vs-epoch-with-pykeras/48476>\
**Category:** Newbie\
**Tags:** python, tmva\
**Created:** [January 20, 2022, 6:58pm UTC](https://root-forum.cern.ch/t/plotting-loss-accuracy-vs-epoch-with-pykeras/48476 "2022-01-20T18:58:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eblazek](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/b2d939/32.png) [@eblazek](https://root-forum.cern.ch/u/eblazek)\
**Post date:** [January 20, 2022, 6:58pm UTC](https://root-forum.cern.ch/t/plotting-loss-accuracy-vs-epoch-with-pykeras/48476/1 "2022-01-20T18:58:52Z")

</div>

Dear experts,

I am working on building a neural net with the PyKeras method of TMVA. I would love to be able to make a plot of the accuracy and loss over the course of all the epochs something like this:

![image](https://root-forum.cern.ch/uploads/default/original/3X/8/5/858be4680c3dbca313460883ce79aea771227599.png)

But I can’t figure out how, if it’s even possible. Is there a way to call the accuracy and loss values of each epoch so I can plot them?

_ROOT Version:_ 6.18.00

---

<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 21, 2022, 8:07am UTC](https://root-forum.cern.ch/t/plotting-loss-accuracy-vs-epoch-with-pykeras/48476/2 "2022-01-21T08:07:19Z")

</div>

I guess you looked at the [TMVA tutorials](https://root.cern/doc/master/group __tutorial__ tmva.html) and to the [TMVA manual](https://github.com/root-project/root/blob/master/documentation/tmva/UsersGuide/TMVAUsersGuide.pdf) and did not find an answer.  
@moneta can help I am sure.

---

<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 21, 2022, 12:09pm UTC](https://root-forum.cern.ch/t/plotting-loss-accuracy-vs-epoch-with-pykeras/48476/3 "2022-01-21T12:09:52Z")

</div>

Hi,

It should be visible in the `TMVAGUI` as item (8) , TrainingHistory.  
You can start the TMVA GUI by doing from the ROOT prompt:

```auto
TMVA::TMVAGui("TMVA_Output.root");

```

where `TMVA_Output.root` is your output file of the training defined when you create the TMVA::Factory object.

Cheers

Lorenzo

---

<div class="post-metadata">

**Author:** ![eblazek](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/b2d939/32.png) [@eblazek](https://root-forum.cern.ch/u/eblazek)\
**Post date:** [January 21, 2022, 4:22pm UTC](https://root-forum.cern.ch/t/plotting-loss-accuracy-vs-epoch-with-pykeras/48476/4 "2022-01-21T16:22:40Z")

</div>

Thanks Lorenzo,

Unfortunately my GUI looks like this, with no TrainingHistory button. Is there some option I need to have enabled, or maybe an updated version of ROOT?

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/f/3/f30fa5cf11dbb5a0518537d38b18447b8b04e0d7.png)

---

<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 21, 2022, 4:46pm UTC](https://root-forum.cern.ch/t/plotting-loss-accuracy-vs-epoch-with-pykeras/48476/5 "2022-01-21T16:46:09Z")

</div>

Hi,  
Which ROOT version are you using it ? Maybe it is too old and this was not yet implemented

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 21, 2022, 4:48pm UTC](https://root-forum.cern.ch/t/plotting-loss-accuracy-vs-epoch-with-pykeras/48476/6 "2022-01-21T16:48:59Z")

</div>

Yes , the TrainingHistory in the GUI has been introduced 2 years ago, from the ROOT version 6.20 and you are using 6.18, seeing from your first post.  
If you can upgrade version, then you will have it

Cheers

Lorenzo
