0

I am studying the book Bayessian analysis with python and trying to implement all codes in python, for this purpose I use google colab, but when I am running following code from book

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})

it gives such errors :

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`

before I tried to implement those libraries

!pip install pymc3>=3.8
!pip install arviz

but still no success. How do I fix this error?

merv
  • 67,214
  • 13
  • 180
  • 245
  • 1
    Does this answer your question? [colaboratory will not acknowledge arviz after installation and import](https://stackoverflow.com/questions/57733115/colaboratory-will-not-acknowledge-arviz-after-installation-and-import) – merv Jul 06 '20 at 07:28

1 Answers1

0

Have you tried to restart your session? Once you upgrade using !pip install pymc3>=3.8, you will have to restart the session and then do import pymc3 as pm otherwise it will still consider the previously installed version.

Tirth Patel
  • 1,855
  • 3
  • 13
  • 22