python – Got `AttributeError` from `from_pymc3` of ArviZ

I am learning Bayesian inference by the book Bayesian Analysis with Python. However, when using plot_ppc, I got AttributeError and the warning

/usr/local/Caskroom/miniconda/base/envs/kaggle/lib/python3.9/site-packages/pymc3/sampling.py:1689: UserWarning: samples parameter is smaller than nchains times ndraws, some draws and/or chains may not be represented in the returned posterior predictive sample
warnings.warn(

The model is

shift = pd.read_csv('../data/chemical_shifts.csv')

with pm.Model() as model_g:
    μ = pm.Uniform('μ', lower=40, upper=70)
    σ = pm.HalfNormal('σ', sd=10)
    y = pm.Normal('y', mu=μ, sd=σ, observed=shift)
    trace_g = pm.sample(1000, return_inferencedata=True)

If I used the following codes

with model_g:
    y_pred_g = pm.sample_posterior_predictive(trace_g, 100, random_seed=123)
    data_ppc = az.from_pymc3(trace_g.posterior, posterior_predictive=y_pred_g) # 'Dataset' object has no attribute 'report'

I got ‘Dataset’ object has no attribute ‘report’.

If I used the following codes

with model_g:
    y_pred_g = pm.sample_posterior_predictive(trace_g, 100, random_seed=123)
    data_ppc = az.from_pymc3(trace_g, posterior_predictive=y_pred_g) # AttributeError: 'InferenceData' object has no attribute 'report'

I got AttributeError: ‘InferenceData’ object has no attribute ‘report’.

ArviZ version: 0.11.2
PyMC3 Version: 3.11.2
Aesara/Theano Version: 1.1.2
Python Version: 3.9.6
Operating system: MacOS Big Sur
How did you install PyMC3: conda

Read more here: Source link