Path: blob/master/notebooks/book2/03/schools8_blackjax.ipynb
1192 views
Kernel: Python [conda env:py3713]
8-School Problem: Hierarchical Bayesian model
author: @anandShegde, @karm-patel
In this notebook, we fit a hierarchical Bayesian model to the "8 schools" dataset. based on: https://github.com/probml/pyprobml/blob/master/notebooks/book2/03/schools8_pymc3.ipynb
In [1]:
In [2]:
In [3]:
Data
In [4]:
Out[4]:
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:25: UserWarning: LATEXIFY environment variable not set, not latexifying
warnings.warn("LATEXIFY environment variable not set, not latexifying")
In [5]:
Out[5]:
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:84: UserWarning: set FIG_DIR environment variable to save figures
warnings.warn("set FIG_DIR environment variable to save figures")
Centered model
In [6]:
In [7]:
In [8]:
In [9]:
In [10]:
In [11]:
Out[11]:
CPU times: user 19.5 s, sys: 256 ms, total: 19.8 s
Wall time: 19.6 s
In [12]:
Out[12]:
DeviceArray([ 1314, 2165, 10000, 10000], dtype=int32)
In [13]:
Out[13]:
/home/patel_karm/anaconda3/envs/py3713/lib/python3.7/site-packages/arviz/stats/density_utils.py:491: UserWarning: Your data appears to have a single value or no finite values
warnings.warn("Your data appears to have a single value or no finite values")
/home/patel_karm/anaconda3/envs/py3713/lib/python3.7/site-packages/arviz/stats/density_utils.py:491: UserWarning: Your data appears to have a single value or no finite values
warnings.warn("Your data appears to have a single value or no finite values")
/home/patel_karm/anaconda3/envs/py3713/lib/python3.7/site-packages/arviz/stats/density_utils.py:491: UserWarning: Your data appears to have a single value or no finite values
warnings.warn("Your data appears to have a single value or no finite values")
In [14]:
Out[14]:
In [15]:
Out[15]:
Number of Divergent Chains: 23479
Percentage of Divergent Chains: 58.7
Non-centered
In [16]:
In [17]:
In [18]:
Out[18]:
CPU times: user 16.1 s, sys: 193 ms, total: 16.3 s
Wall time: 16.1 s
In [19]:
In [20]:
In [21]:
Out[21]:
DeviceArray([0, 0, 0, 0], dtype=int32)
In [22]:
In [23]:
Out[23]:
In [24]:
Out[24]:
In [25]:
Out[25]:
In [26]:
Out[26]:
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:25: UserWarning: LATEXIFY environment variable not set, not latexifying
warnings.warn("LATEXIFY environment variable not set, not latexifying")
In [27]:
Out[27]:
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:84: UserWarning: set FIG_DIR environment variable to save figures
warnings.warn("set FIG_DIR environment variable to save figures")
In [28]:
Out[28]:
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:25: UserWarning: LATEXIFY environment variable not set, not latexifying
warnings.warn("LATEXIFY environment variable not set, not latexifying")
In [29]:
Out[29]:
<matplotlib.lines.Line2D at 0x7fe74837e150>
In [30]:
Out[30]:
Funnel of hell
In [31]:
Out[31]:
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:25: UserWarning: LATEXIFY environment variable not set, not latexifying
warnings.warn("LATEXIFY environment variable not set, not latexifying")
In [32]:
Out[32]:
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:84: UserWarning: set FIG_DIR environment variable to save figures
warnings.warn("set FIG_DIR environment variable to save figures")
In [33]:
In [34]:
Out[34]:
/home/patel_karm/anaconda3/envs/py3713/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
FutureWarning
/home/patel_karm/anaconda3/envs/py3713/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
FutureWarning
In [35]:
Out[35]:
In [ ]:
In [ ]: