Skip to content

Commit c9422ab

Browse files
committed
update with stylistic issues fixed
1 parent 1e9b770 commit c9422ab

11 files changed

Lines changed: 51 additions & 99 deletions

notebooks/03-instructor-two-group-iq.ipynb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9-
"from IPython.display import HTML, Image\n",
109
"import pandas as pd\n",
1110
"import numpy as np\n",
1211
"import matplotlib.pyplot as plt\n",
1312
"import pymc3 as pm\n",
1413
"import seaborn as sns\n",
15-
"from utils import ECDF, despine_traceplot\n",
14+
"from utils import ECDF\n",
1615
"from data import load_kruschke\n",
1716
"\n",
1817
"%load_ext autoreload\n",
@@ -351,8 +350,7 @@
351350
"ax2.plot(x, y, label='data')\n",
352351
"ax2.legend()\n",
353352
"ax2.set_title('placebo')\n",
354-
"ax2.set_xlabel('IQ')\n",
355-
"sns.despine()"
353+
"ax2.set_xlabel('IQ')"
356354
]
357355
},
358356
{
@@ -488,8 +486,7 @@
488486
"metadata": {},
489487
"outputs": [],
490488
"source": [
491-
"traces = pm.traceplot(trace_alt)\n",
492-
"despine_traceplot(traces)"
489+
"traces = pm.traceplot(trace_alt)"
493490
]
494491
},
495492
{

notebooks/03-student-two-group-iq.ipynb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9-
"from IPython.display import HTML, Image\n",
109
"import pandas as pd\n",
1110
"import numpy as np\n",
1211
"import matplotlib.pyplot as plt\n",
1312
"import pymc3 as pm\n",
1413
"import seaborn as sns\n",
15-
"from utils import ECDF, despine_traceplot\n",
14+
"from utils import ECDF\n",
1615
"from data import load_kruschke\n",
1716
"\n",
1817
"%load_ext autoreload\n",
@@ -352,8 +351,7 @@
352351
"ax2.plot(x, y, label='data')\n",
353352
"ax2.legend()\n",
354353
"ax2.set_title('placebo')\n",
355-
"ax2.set_xlabel('IQ')\n",
356-
"sns.despine()"
354+
"ax2.set_xlabel('IQ')"
357355
]
358356
},
359357
{
@@ -490,8 +488,7 @@
490488
"metadata": {},
491489
"outputs": [],
492490
"source": [
493-
"traces = pm.traceplot(trace_alt)\n",
494-
"despine_traceplots(traces)"
491+
"traces = pm.traceplot(trace_alt)"
495492
]
496493
},
497494
{

notebooks/04-instructor-multi-group-comparsion-sterilization.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@
251251
"**Discussion:** Find a neighbour who is working on the same notebook, and discuss this together.\n",
252252
"\n",
253253
"- Which method of sterilization is the most effective? \n",
254-
"- Given the data, is there any uncertainty surrounding this? Could we still be wrong about the uncertainty?"
254+
"- Observe the posterior distribution. Is there any uncertainty surrounding this method's effectiveness? Could we still be wrong about the uncertainty?"
255255
]
256256
},
257257
{

notebooks/04-student-multi-group-comparsion-sterilization.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
"**Discussion:** Find a neighbour who is working on the same notebook, and discuss this together.\n",
250250
"\n",
251251
"- Which method of sterilization is the most effective? \n",
252-
"- Given the data, is there any uncertainty surrounding this? Could we still be wrong about the uncertainty?"
252+
"- Observe the posterior distribution. Is there any uncertainty surrounding this method's effectiveness? Could we still be wrong about the uncertainty?"
253253
]
254254
},
255255
{

notebooks/05-instructor-two-group-comparison-finches.ipynb

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"import matplotlib.pyplot as plt\n",
1313
"import seaborn as sns\n",
1414
"import numpy as np\n",
15-
"from utils import ECDF, despine_traceplot\n",
15+
"from utils import ECDF\n",
1616
"\n",
1717
"%load_ext autoreload\n",
1818
"%autoreload 2\n",
@@ -55,9 +55,7 @@
5555
"cell_type": "markdown",
5656
"metadata": {},
5757
"source": [
58-
"### Exercise\n",
59-
"\n",
60-
"View a random sample of the data to get a feel for the structure of the dataset."
58+
"**Exercise:** View a random sample of the data to get a feel for the structure of the dataset."
6159
]
6260
},
6361
{
@@ -94,9 +92,7 @@
9492
"cell_type": "markdown",
9593
"metadata": {},
9694
"source": [
97-
"### Exercise\n",
98-
"\n",
99-
"Recreate the estimation model for finch beak depths. A few things to note:\n",
95+
"**Exercise:** Recreate the estimation model for finch beak depths. A few things to note:\n",
10096
"\n",
10197
"- Practice using numpy-like fancy indexing.\n",
10298
"- Difference of means & effect size are optional.\n",
@@ -139,9 +135,7 @@
139135
"cell_type": "markdown",
140136
"metadata": {},
141137
"source": [
142-
"### Exercise\n",
143-
"\n",
144-
"Perform MCMC sampling to estimate the posterior distribution of each parameter."
138+
"**Exercise:** Perform MCMC sampling to estimate the posterior distribution of each parameter."
145139
]
146140
},
147141
{
@@ -158,9 +152,7 @@
158152
"cell_type": "markdown",
159153
"metadata": {},
160154
"source": [
161-
"### Exercise\n",
162-
"\n",
163-
"Diagnose whether the sampling has converged or not using trace plots."
155+
"**Exercise:** Diagnose whether the sampling has converged or not using trace plots."
164156
]
165157
},
166158
{
@@ -169,17 +161,14 @@
169161
"metadata": {},
170162
"outputs": [],
171163
"source": [
172-
"traces = pm.traceplot(trace)\n",
173-
"despine_traceplot(traces)"
164+
"traces = pm.traceplot(trace)"
174165
]
175166
},
176167
{
177168
"cell_type": "markdown",
178169
"metadata": {},
179170
"source": [
180-
"### Exercise\n",
181-
"\n",
182-
"Visualize the posterior distribution over the parameters using the forest plot."
171+
"**Exercise:** Visualize the posterior distribution over the parameters using the forest plot."
183172
]
184173
},
185174
{
@@ -195,9 +184,7 @@
195184
"cell_type": "markdown",
196185
"metadata": {},
197186
"source": [
198-
"### Exercise\n",
199-
"\n",
200-
"Visualize the posterior distribution of the means using `plot_posterior`."
187+
"**Exercise:** Visualize the posterior distribution of the means using `plot_posterior`."
201188
]
202189
},
203190
{
@@ -216,18 +203,15 @@
216203
"cell_type": "markdown",
217204
"metadata": {},
218205
"source": [
219-
"### Discuss\n",
220-
"\n",
206+
"**Discuss:**\n",
221207
"- Is the posterior distribution of beaks for the unknown species reasonable?"
222208
]
223209
},
224210
{
225211
"cell_type": "markdown",
226212
"metadata": {},
227213
"source": [
228-
"### Exericse\n",
229-
"\n",
230-
"Perform a posterior predictive check to visually diagnose whether the model describes the data generating process well or not."
214+
"**Exercise:** Perform a posterior predictive check to visually diagnose whether the model describes the data generating process well or not."
231215
]
232216
},
233217
{
@@ -287,7 +271,6 @@
287271
"ax_scandens.set_title('scandens')\n",
288272
"ax_scandens.set_xlabel('beak length')\n",
289273
"\n",
290-
"sns.despine()\n",
291274
"plt.tight_layout()"
292275
]
293276
},

notebooks/05-student-two-group-comparison-finches.ipynb

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@
5555
"cell_type": "markdown",
5656
"metadata": {},
5757
"source": [
58-
"### Exercise\n",
59-
"\n",
60-
"View a random sample of the data to get a feel for the structure of the dataset."
58+
"**Exercise:** View a random sample of the data to get a feel for the structure of the dataset."
6159
]
6260
},
6361
{
@@ -94,12 +92,11 @@
9492
"cell_type": "markdown",
9593
"metadata": {},
9694
"source": [
97-
"### Exercise\n",
98-
"\n",
99-
"Recreate the estimation model for finch beak depths. A few things to note:\n",
95+
"**Exercise:** Recreate the estimation model for finch beak depths. A few things to note:\n",
10096
"\n",
10197
"- Practice using numpy-like fancy indexing.\n",
102-
"- Difference of means & effect size are optional."
98+
"- Difference of means & effect size are optional.\n",
99+
"- Feel free to play around with other priors."
103100
]
104101
},
105102
{
@@ -126,9 +123,7 @@
126123
"cell_type": "markdown",
127124
"metadata": {},
128125
"source": [
129-
"### Exercise\n",
130-
"\n",
131-
"Perform MCMC sampling to estimate the posterior distribution of each parameter."
126+
"**Exercise:** Perform MCMC sampling to estimate the posterior distribution of each parameter."
132127
]
133128
},
134129
{
@@ -144,9 +139,7 @@
144139
"cell_type": "markdown",
145140
"metadata": {},
146141
"source": [
147-
"### Exercise\n",
148-
"\n",
149-
"Diagnose whether the sampling has converged or not using trace plots."
142+
"**Exercise:** Diagnose whether the sampling has converged or not using trace plots."
150143
]
151144
},
152145
{
@@ -162,9 +155,7 @@
162155
"cell_type": "markdown",
163156
"metadata": {},
164157
"source": [
165-
"### Exercise\n",
166-
"\n",
167-
"Visualize the posterior distribution over the parameters using the forest plot."
158+
"**Exercise:** Visualize the posterior distribution over the parameters using the forest plot."
168159
]
169160
},
170161
{
@@ -180,9 +171,7 @@
180171
"cell_type": "markdown",
181172
"metadata": {},
182173
"source": [
183-
"### Exercise\n",
184-
"\n",
185-
"Visualize the posterior distribution of the means using `plot_posterior`."
174+
"**Exercise:** Visualize the posterior distribution over the parameters using the forest plot."
186175
]
187176
},
188177
{
@@ -198,18 +187,15 @@
198187
"cell_type": "markdown",
199188
"metadata": {},
200189
"source": [
201-
"### Discuss\n",
202-
"\n",
190+
"**Discuss:**\n",
203191
"- Is the posterior distribution of beaks for the unknown species reasonable?"
204192
]
205193
},
206194
{
207195
"cell_type": "markdown",
208196
"metadata": {},
209197
"source": [
210-
"### Exericse\n",
211-
"\n",
212-
"Perform a posterior predictive check to visually diagnose whether the model describes the data generating process well or not."
198+
"**Exercise:** Perform a posterior predictive check to visually diagnose whether the model describes the data generating process well or not."
213199
]
214200
},
215201
{
@@ -269,7 +255,6 @@
269255
"ax_scandens.set_title('scandens')\n",
270256
"ax_scandens.set_xlabel('beak length')\n",
271257
"\n",
272-
"sns.despine()\n",
273258
"plt.tight_layout()"
274259
]
275260
},

notebooks/06-instructor-hierarchical-baseball.ipynb

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131
"\n",
3232
"Baseball players have many metrics measured for them. Let's say we are on a baseball team, and would like to quantify player performance, one metric being their batting average (defined by how many times a batter hit a pitched ball, divided by the number of times they were up for batting (\"at bat\")). How would you go about this task?\n",
3333
"\n",
34-
"## Discussion\n",
35-
"\n",
36-
"Discuss with your neighbors the following questions.\n",
37-
"\n",
34+
"**Discuss**: \n",
3835
"1. What data would we need?\n",
3936
"1. What metric would you rank by? \n",
4037
"1. Would your metric be reasonable for rookie players?\n",
@@ -61,6 +58,10 @@
6158
"- Binomail distribution: a probability distribution modelling the number of successes in `n` trials. Parameterized by both `n` and `p`.\n",
6259
"- Beta distributions: a probability distribution bounded over the interval $(0, 1)$. Models distribution of probability values, usually the `p` in a Bernoulli or Binomial. Parameterized by $\\alpha$ and $\\beta$, which can be thought of as \"number of successes\" and \"number of failures\" respectively.\n",
6360
"\n",
61+
"Every distribution has its \"story\". If you're curious, check out [Justin Bois' probability stories][probstory] page.\n",
62+
"\n",
63+
"[probstory]: http://bebi103.caltech.edu.s3-website-us-east-1.amazonaws.com/2017/tutorials/t3b_probability_stories.html#Beta-distribution\n",
64+
"\n",
6465
"### Focus on beta\n",
6566
"\n",
6667
"Let's say we wanted to model a probability distribution centered approximately on 0.2. Depending on our parameterization of the Beta distribution, we can express different levels of confidence (as measured by the spread of the distribution) as to how sure we are a distribution takes on that value.\n",
@@ -111,9 +112,7 @@
111112
"cell_type": "markdown",
112113
"metadata": {},
113114
"source": [
114-
"### Exercise\n",
115-
"\n",
116-
"Write a naive estimation model for the players above.\n",
115+
"**Exercise:** Write a naive estimation model for the players above.\n",
117116
"\n",
118117
"Hint, a possible model you could specify is as follows:\n",
119118
"\n",
@@ -186,9 +185,7 @@
186185
"cell_type": "markdown",
187186
"metadata": {},
188187
"source": [
189-
"## Discussion\n",
190-
"\n",
191-
"Are the estimates reasonable, particularly for players that have had only one at bat (AB)?"
188+
"**Discuss:** Are the estimates reasonable, particularly for players that have had only one at bat (AB)?"
192189
]
193190
},
194191
{
@@ -197,8 +194,7 @@
197194
"source": [
198195
"# Hierarchical Modelling\n",
199196
"\n",
200-
"## Discussion\n",
201-
"\n",
197+
"**Discuss:** \n",
202198
"- How do we deal with the fact that some players have only had 1 at bat (AB = 1), and zero hits (H = 0)? \n",
203199
"- Would it be reasonable, fair, and in line with prior knowledge that the player's true batting average was zero? \n",
204200
"\n",
@@ -337,7 +333,7 @@
337333
" ax.plot(r)\n",
338334
" \n",
339335
"ax.set_xticks([0, 1, 2])\n",
340-
"ax.set_xticklabels(['no pooling (MAP)', 'partial pooling (Bayesian)', 'complete pooling (Population Average)'])\n",
336+
"ax.set_xticklabels(['no pooling', 'partial pooling', 'complete pooling'])\n",
341337
"ax.set_ylim(0, 1)\n",
342338
"despine(ax)"
343339
]

0 commit comments

Comments
 (0)