I started reading "Bayesian Inference Experienced in Python". Make a note of what you got stuck in before moving it.
I put in pymc
, but now it is pymc4
.
If you check the book's github
,
https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers
The scripts for pymc2
and pymc3
are included, so when reading a book, install pymc3
and look at the scripts for pymc3
in git
.
The required libraries are pymc3
and the backend theano
.
pip install pymc3
I've done a lot, but without putting anything in it, first of all, it's all installed with just this pip
.
Basically, installing this pymc3
will install the required theano
.
theno
is the backend that runs behind pymc3
.
After that, put in the required jupyter notebook
.
pip install jupyter
With this, the first chapter works. It spits out a warning, but it works, so it's okay.
Next, I also added my favorite spyder
.
This is the case when running with spyder
.
In the cell in10 in Ch1_Introduction_PyMC3.ipynb
of jupyter
, if you move it with spyder
as it is, an error will occur here.
#When I run it with this, I get an error.
with model:
step = pm.Metropolis()
trace = pm.sample(10000, tune=5000,step=step)
The reason for the error is that the multi-core settings don't seem to work. This is fixed here.
with model:
step = pm.Metropolis()
trace = pm.sample(10000, tune=5000,step=step , cores = 1)
For the time being, cores = 1, and if you move it with a single core, it will work. If you enter 2 or 4 here, an error will occur, but if something works and you force termination, you will get a result. Set 1 to move normally.
It works with jupyter notebook
, but I don't know why I get an error with spyder
.
From now on, it seems that tensorflow
will be the backend in pymc4
, but in the case of this book, it is better to include pymc3
.
https://yukinagae.hatenablog.com/entry/2018/09/20/093137
Recommended Posts