Pymc3: pm.forestplot throws error for complicated models and traces

Created on 28 Mar 2018  路  3Comments  路  Source: pymc-devs/pymc3

Description of your problem

I've sampled data points using NUTS for a nested model that includes a cholesky decomposition and covariance matrices. One part of the model uses continuous variables while another one uses binomial logistic regression. I modeled different subjects and runs so I get a lot of variables. When I run pm.forestplot(trace_model) I get a forestplot and the following error:

ValueError                                Traceback (most recent call last)
<ipython-input-38-104bdf2c5589> in <module>()
----> 1 pm.forestplot(trace_m1_fa);

/data/p_nmc002/anaconda3-4.4.0/lib/python3.6/site-packages/pymc3/plots/forestplot.py in forestplot(trace_obj, varnames, transform, alpha, quartiles, rhat, main, xtitle, xlim, ylabels, chain_spacing, vline, gs, plot_transformed, plot_kwargs)
    325     if plot_rhat:
    326         _make_rhat_plot(trace_obj, plt.subplot(gs[1]), "R-hat", labels,
--> 327                         varnames, plot_transformed)
    328 
    329     return gs

/data/p_nmc002/anaconda3-4.4.0/lib/python3.6/site-packages/pymc3/plots/forestplot.py in _make_rhat_plot(trace, ax, title, labels, varnames, include_transformed)
     65 
     66         if k > 1:
---> 67             ax.plot([min(r, 2) for r in R[varname]],
     68                     [-(j + i) for j in range(k)], 'bo', markersize=4)
     69         else:

/data/p_nmc002/anaconda3-4.4.0/lib/python3.6/site-packages/pymc3/plots/forestplot.py in <listcomp>(.0)
     65 
     66         if k > 1:
---> 67             ax.plot([min(r, 2) for r in R[varname]],
     68                     [-(j + i) for j in range(k)], 'bo', markersize=4)
     69         else:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

A minimum working example would be difficult. Instead you can access an ipython notebook here (I didn't upload it to github as the pickled traces are over 100 MB:
https://owncloud.gwdg.de/index.php/s/tG1UQxteWb46B28

Versions and main components

  • PyMC3 Version: 3.2
  • Theano Version: 1.0.1
  • Python Version: 3.6.1 |Anaconda custom (64-bit)|
  • Operating system: 4.13.0-32-generic #35~16.04.1-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux
  • How did you install PyMC3: conda

Most helpful comment

I can confirm this is a problem in PyMC3 3.2, but it has been solved in PyMC3 3.3. @gladomat let us know if you still have this problem after upgrading.

All 3 comments

Thanks for reporting. @aloctavodia I assigned this to you if you dont mind.

I can confirm this is a problem in PyMC3 3.2, but it has been solved in PyMC3 3.3. @gladomat let us know if you still have this problem after upgrading.

Works like a charm. Thanks!

Was this page helpful?
0 / 5 - 0 ratings