Attribute Error while using Arviz posterior plot

I’m trying to predict the passenger flow in a bus route using particle filter.So while doing the bayesian part using pymc3, I tried to compute the posterior predictive plot.This is snippet of my code.

with pm.Model() as model_particle:
θ = pm.Gamma(‘θ’, 65, 19)
y = pm.Poisson(‘y’, θ, observed=data)
trace = pm.sample(2500,tune=5000)

y_pred = pm.sample_posterior_predictive(trace, 100, model_particle)

data_pred = az.from_pymc3(trace=trace, posterior_predictive=y_pred)
ax = az.plot_ppc(data_pred, figsize=(12, 6), mean=False)

While running this code, its showing
“AttributeError: ‘int’ object has no attribute ‘astype’”

Please help.Thanks in advance

1 Like

Hi, what ArviZ, PyMC and numpy versions are you using?

As a first step I’d suggest updating all these libraries to their latest version.

1 Like

Please post a backtrace, so we can see where the error is. Is it in az.plot_ppc or earlier?

Also, please reformat the code in your post using the preformatted layout operation – we can’t see what parts of the code are inside the with pm.Model() as model_particle: and which are outside, because the indentation has been lost.

I’m suspicious that this might be an old version of the library, because an up-to-date version would complain if particle_model wasn’t visible to az.from_pymc3.


Thanks a lot. It worked. I upgraded to the latest version

1 Like


Thanks for your valuable time.When I updated both arviz and pymc3 to the latest version,it worked