# Loaded saved Text Trace does not show any summary or traceplot

**URL:** <https://discourse.pymc.io/t/loaded-saved-text-trace-does-not-show-any-summary-or-traceplot/429>\
**Category:** Questions\
**Created:** [October 16, 2017, 1:49pm UTC](https://discourse.pymc.io/t/loaded-saved-text-trace-does-not-show-any-summary-or-traceplot/429 "2017-10-16T13:49:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![viiv](https://avatars.discourse-cdn.com/v4/letter/v/f9ae1b/32.png) [@viiv](https://discourse.pymc.io/u/viiv)\
**Post date:** [October 16, 2017, 1:49pm UTC](https://discourse.pymc.io/t/loaded-saved-text-trace-does-not-show-any-summary-or-traceplot/429/1 "2017-10-16T13:49:12Z")

</div>

Hello,

I have a chain saved using the Text backend:

```
db = pm.backends.Text('save1')
trace = pm.sample(3000,step=step,start=start,trace=db)

```

I used this to load it within the context of my model:

```
with pm.Model() as model:
    test=pm.backends.text.load('save1')

```

and it worked, since `test` is recognized as variable : `<MultiTrace: 1 chains, 3500 iterations, 0 variables>` (not sure why it says 0 variables, since they are listed in the .csv file, but anyway).

Nevertheless, when I do this: `pm.summary(test)`, nothing happens.  
And when I try this: `pm.traceplot(test)`, I get `IndexError: index out of range` in `gridspec.py`, a matplotlib function.

Any idea on how to get the summary and traceplot from there?

Thanks!

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [October 16, 2017, 2:01pm UTC](https://discourse.pymc.io/t/loaded-saved-text-trace-does-not-show-any-summary-or-traceplot/429/2 "2017-10-16T14:01:23Z")

</div>

This sounds like a bug, but since there are plans to deprecate text backend maybe you should just pickle the trace instead.

> [@Get nan or inf from model.logp (model.test point) is an attestation of incorrectly configured model?](https://discourse.pymc.io/t/get-nan-or-inf-from-model-logp-model-test-point-is-an-attestation-of-incorrectly-configured-model/111/22):
>
> Haven’t tried this, but it should work (give it a shot with very few samples first!): import cPickle as pickle # if python2 import pickle # if python3 ... trace = pm.sample(5e4, njobs=4, step=[pm.Metropolis(vars=[Y, Yp]), pm.NUTS()], tune=1000) with open('trace.pkl', 'wb') as buff: pickle.dump(trace, buff) You can then recover the trace with with open('trace.pkl', 'rb') as buff: trace = pickle.load(buff) This is great for local development on your computer. A few “gotchas” that p…

---

<div class="post-metadata">

**Author:** ![viiv](https://avatars.discourse-cdn.com/v4/letter/v/f9ae1b/32.png) [@viiv](https://discourse.pymc.io/u/viiv)\
**Post date:** [October 16, 2017, 2:05pm UTC](https://discourse.pymc.io/t/loaded-saved-text-trace-does-not-show-any-summary-or-traceplot/429/3 "2017-10-16T14:05:26Z")

</div>

I see, thanks.

I just read somewhere in the docs that Pickle should not be used for long-term project because the format itself changes often and gets deprecated faster, so I did not chose it.

But it’s definitely a better option? Because as for me, a CSV seems pretty simple yet robust…what will pickle bring instead?

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [October 16, 2017, 2:20pm UTC](https://discourse.pymc.io/t/loaded-saved-text-trace-does-not-show-any-summary-or-traceplot/429/4 "2017-10-16T14:20:07Z")

</div>

I would say only pickling the trace as an intermedia step, and functions operating on the trace should work as intended (e.g., traceplot, sample\_ppc etc). But you are right it is indeed better to save the trace as a CSV (for final report or paper), which you can do so by `pm.trace_to_dataframe(trace)`.

---

<div class="post-metadata">

**Author:** ![viiv](https://avatars.discourse-cdn.com/v4/letter/v/f9ae1b/32.png) [@viiv](https://discourse.pymc.io/u/viiv)\
**Post date:** [October 16, 2017, 2:25pm UTC](https://discourse.pymc.io/t/loaded-saved-text-trace-does-not-show-any-summary-or-traceplot/429/5 "2017-10-16T14:25:21Z")

</div>

Ah I didn’t know this option, thanks! I’ll try that from now on.

---

<div class="post-metadata">

**Author:** ![Helmut](https://avatars.discourse-cdn.com/v4/letter/h/cab0a1/32.png) [@Helmut](https://discourse.pymc.io/u/Helmut)\
**Post date:** [May 29, 2018, 7:19am UTC](https://discourse.pymc.io/t/loaded-saved-text-trace-does-not-show-any-summary-or-traceplot/429/6 "2018-05-29T07:19:39Z")

</div>

But if you use pm.trace\_to\_dataframe(trace), and then pickle the dataframe (say), how do you recover the trace from the dataframe in a form from which you can do a traceplot?

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [May 29, 2018, 8:00am UTC](https://discourse.pymc.io/t/loaded-saved-text-trace-does-not-show-any-summary-or-traceplot/429/7 "2018-05-29T08:00:45Z")

</div>

I think the best way is to use [https://github.com/arviz-devs/arviz](https://github.com/arviz-devs/arviz)  
We are currently separating the plotting and statistics module from PyMC3 into a general library, potentially for varies python Bayesian packages like pystan, pyro, edward etc (great work mostly done by @aloctavodia and @colcarroll). The aim is to have something similar to [bayesplot](https://cran.r-project.org/web/packages/bayesplot/index.html) or [coda](https://cran.r-project.org/web/packages/coda/index.html) in R
