0
votes

When I try to use PyMC3 Plotting, I have the following error:

AttributeError: module 'pymc3.glm.utils' has no attribute 'get_default_varnames'

This is the code I am trying to plot:

pm.plot_posterior(trace[3000:],
                  varnames=['CA_Armed_Assault_Mean', 'RUSSIAN_Armed_Assault_Mean', 'CA_Armed_Assault_STD', 'RUSSIAN_Armed_Assault_STD'],
                  color='#87ceeb')

I am using the 3.7 version and this is the full stack trace:

-------------------------------------------------------------------------

AttributeError Traceback (most recent call last)
<ipython-input-31-fbec6ccc2c42> in <module>
      1 pm.plot_posterior(trace[3000:],
      2                   varnames=['CA_Armed_Assault_Mean', 'RUSSIAN_Armed_Assault_Mean', 'CA_Armed_Assault_STD', 'RUSSIAN_Armed_Assault_STD'],
----> 3                   color='#87ceeb')

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/arviz/data/io_pymc3.py in posterior_to_xarray(self)
     58     def posterior_to_xarray(self):
     59         """Convert the posterior to an xarray dataset."""
---> 60         var_names = self.pymc3.utils.get_default_varnames(  # pylint: disable=no-member
     61             self.trace.varnames,
     62             include_transformed=False)

AttributeError: module 'pymc3.glm.utils' has no attribute 'get_default_varnames'

1
Could you provide the full stack trace, and what version of pymc3 you are using, using print(pm.__version__)?colcarroll
Yes I just did it. Thanks!Aliai Eusebi

1 Answers

0
votes

I ran into this after upgrading from pymc3 3.6 to 3.7. It seems to me the source is the change from plotting in pymc3/plots/traceplot in 3.6 to arviz/plots/traceplot in 3.7. pymc3/plots imported get_default_varnames from ../util via ./utils whereas arviz/plots now imports its own varname funcion from ..utils import _var_names

This is definitely not the solution at the large scale (I am not an expert but I guess we'll have to look where that remainder import is hiding), but as a short-term workaround in order to be able to look at your plots, you can add from ..util import get_default_varnames to your pythonX.X/site-packages/pymc3/glm/utils to back plotting functionality, it worked for me.