Skip to content

Commit e16cde2

Browse files
Update Getting Started for PyMC v4.x (#2442) (#2444)
* Replaced outdated PyMC3 with PyMCV4.x workflow. * Using sigma instead of sd to prevent DeprecationWarning. * Removed az.from_pymc3() and integrated prior, posterior, and posterior predictive sampling directly using pm.sample() and .extend(). Signed-off-by: PiyushPanwarFST <[email protected]>
1 parent 5b1c4ab commit e16cde2

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

doc/source/getting_started/CreatingInferenceData.ipynb

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4138,12 +4138,12 @@
41384138
"cell_type": "markdown",
41394139
"metadata": {},
41404140
"source": [
4141-
"## From PyMC3"
4141+
"## From PyMC"
41424142
]
41434143
},
41444144
{
41454145
"cell_type": "code",
4146-
"execution_count": 2,
4146+
"execution_count": null,
41474147
"metadata": {
41484148
"ExecuteTime": {
41494149
"end_time": "2020-06-19T06:23:42.715900Z",
@@ -4152,7 +4152,7 @@
41524152
},
41534153
"outputs": [],
41544154
"source": [
4155-
"import pymc3 as pm\n",
4155+
"import pymc as pm\n",
41564156
"\n",
41574157
"draws = 500\n",
41584158
"chains = 2\n",
@@ -4166,7 +4166,7 @@
41664166
},
41674167
{
41684168
"cell_type": "code",
4169-
"execution_count": 7,
4169+
"execution_count": null,
41704170
"metadata": {
41714171
"ExecuteTime": {
41724172
"end_time": "2020-06-05T06:47:16.996019Z",
@@ -10202,24 +10202,19 @@
1020210202
],
1020310203
"source": [
1020410204
"with pm.Model() as model:\n",
10205-
" mu = pm.Normal(\"mu\", mu=0, sd=5)\n",
10205+
" mu = pm.Normal(\"mu\", mu=0, sigma=5)\n",
1020610206
" tau = pm.HalfCauchy(\"tau\", beta=5)\n",
10207-
" theta_tilde = pm.Normal(\"theta_tilde\", mu=0, sd=1, shape=eight_school_data[\"J\"])\n",
10207+
" theta_tilde = pm.Normal(\"theta_tilde\", mu=0, sigma=1, shape=eight_school_data[\"J\"])\n",
10208+
" \n",
1020810209
" theta = pm.Deterministic(\"theta\", mu + tau * theta_tilde)\n",
10209-
" pm.Normal(\"obs\", mu=theta, sd=eight_school_data[\"sigma\"], observed=eight_school_data[\"y\"])\n",
10210+
" \n",
10211+
" pm.Normal(\"obs\", mu=theta, sigma=eight_school_data[\"sigma\"], observed=eight_school_data[\"y\"])\n",
1021010212
"\n",
10211-
" trace = pm.sample(draws, chains=chains)\n",
10212-
" prior = pm.sample_prior_predictive()\n",
10213-
" posterior_predictive = pm.sample_posterior_predictive(trace)\n",
10213+
" idata = pm.sample(draws=draws, chains=chains)\n",
10214+
" idata.extend(pm.sample_prior_predictive())\n",
10215+
" idata.extend(pm.sample_posterior_predictive(idata))\n",
1021410216
"\n",
10215-
" pm_data = az.from_pymc3(\n",
10216-
" trace=trace,\n",
10217-
" prior=prior,\n",
10218-
" posterior_predictive=posterior_predictive,\n",
10219-
" coords={\"school\": np.arange(eight_school_data[\"J\"])},\n",
10220-
" dims={\"theta\": [\"school\"], \"theta_tilde\": [\"school\"]},\n",
10221-
" )\n",
10222-
"pm_data"
10217+
"idata"
1022310218
]
1022410219
},
1022510220
{

0 commit comments

Comments
 (0)