我正在研究这本书贝叶斯分析与python并尝试在python中实现所有代码,为此我使用google colab,但是当我运行书中的以下代码时
import arviz
import pymc3 as pm
import numpy as np
from scipy import stats
np.random.seed(123)
n_experiments=4
theta_real =0.35
data =stats.bernoulli.rvs(p=theta_real,size=n_experiments)
with pm.Model() as our_first_model:
theta =pm.Beta('theta',alpha=1,beta=1)
y =pm.Bernoulli('y',p=theta,observed=data)
start =pm.find_MAP()
step =pm.Metropolis()
trace =pm.sample(1000,step=step,start=start)
burnin=100
chain =trace[burnin:]
pm.traceplot(chain,lines={'theta':theta_real})
它给出了这样的错误:
AttributeError: Installed version of ArviZ requires PyMC3>=3.8. Please upgrade with `pip install pymc3>=3.8` or `conda install -c conda-forge pymc3>=3.8`
在我尝试实现这些库之前
!pip install pymc3>=3.8
!pip install arviz
但仍然没有成功。如何修复此错误?