Skip to content

Commit 6da91f8

Browse files
committed
cosmetic changes
1 parent 20c1cb1 commit 6da91f8

File tree

3 files changed

+314
-123
lines changed

3 files changed

+314
-123
lines changed

10 - Bagging/Bagging.ipynb

Lines changed: 20 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"\n",
9090
"References:<br>\n",
9191
"**An Introduction to the Bootstrap.**<br>\n",
92-
"B. Efron and R. Tibshirani, *Chapman & Hall/CRC, (1993).\n",
92+
"B. Efron and R. Tibshirani, Chapman & Hall/CRC, (1993).\n",
9393
"\n",
9494
"**[What Teachers Should Know About the Bootstrap: Resampling in the Undergraduate Statistics Curriculum](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4784504/)**<br>\n",
9595
"T. C. Hesterberg, *The American Statistician*, 69(4), 371–386, (2015).<br>\n",
@@ -106,12 +106,7 @@
106106
{
107107
"cell_type": "code",
108108
"execution_count": null,
109-
"metadata": {
110-
"ExecuteTime": {
111-
"end_time": "2018-11-27T07:53:54.139086Z",
112-
"start_time": "2018-11-27T07:53:53.019320Z"
113-
}
114-
},
109+
"metadata": {},
115110
"outputs": [],
116111
"source": [
117112
"import numpy as np\n",
@@ -130,10 +125,6 @@
130125
"cell_type": "code",
131126
"execution_count": null,
132127
"metadata": {
133-
"ExecuteTime": {
134-
"end_time": "2018-11-27T07:54:26.080833Z",
135-
"start_time": "2018-11-27T07:54:24.422776Z"
136-
},
137128
"scrolled": true
138129
},
139130
"outputs": [],
@@ -152,7 +143,9 @@
152143
"cell_type": "markdown",
153144
"metadata": {},
154145
"source": [
155-
"<div class=\"alert alert-warning\">**Exercice:**<br>\n",
146+
"<div class=\"alert alert-warning\">\n",
147+
"\n",
148+
"**Exercice:**<br>\n",
156149
"Implement a Bootstrap algorithm to estimate the distribution of the empirical average and empirical median estimators on this data.<br>\n",
157150
"Plot the histogram of these distributions (use [`plt.hist`](https://matplotlib.org/api/_as_gen/matplotlib.pyplot.hist.html)).<br>\n",
158151
"Estimate the estimator's empirical average from the bootstrap samples and the mean of its distribution.\n",
@@ -162,12 +155,7 @@
162155
{
163156
"cell_type": "code",
164157
"execution_count": null,
165-
"metadata": {
166-
"ExecuteTime": {
167-
"end_time": "2018-11-27T08:05:50.870129Z",
168-
"start_time": "2018-11-27T08:05:45.840992Z"
169-
}
170-
},
158+
"metadata": {},
171159
"outputs": [],
172160
"source": [
173161
"# %load solutions/code1.py\n",
@@ -239,7 +227,9 @@
239227
"\n",
240228
"In practice, we never get $\\varphi_A$.\n",
241229
"\n",
242-
"<div class=\"alert alert-success\">**Key results:**<br>\n",
230+
"<div class=\"alert alert-success\">\n",
231+
"\n",
232+
"**Key results:**<br>\n",
243233
"*1st result:* $\\varphi_A$ is always at least as good as $\\varphi$; $e_A \\leq e$<br>\n",
244234
"<br>\n",
245235
"*2nd result:* The highest the variance of $\\varphi$ across training sets $\\mathcal{T}$, the more improvement $\\varphi_A$ produces.<br>\n",
@@ -277,10 +267,6 @@
277267
"cell_type": "code",
278268
"execution_count": null,
279269
"metadata": {
280-
"ExecuteTime": {
281-
"end_time": "2018-11-27T08:30:50.285839Z",
282-
"start_time": "2018-11-27T08:30:47.046918Z"
283-
},
284270
"scrolled": true
285271
},
286272
"outputs": [],
@@ -307,9 +293,9 @@
307293
"\n",
308294
"Xblue = X[y==-1]\n",
309295
"Xred = X[y==1]\n",
310-
"plt.figure()\n",
296+
"fig=plt.figure(figsize=(8, 8), dpi= 80, facecolor='w', edgecolor='k')\n",
311297
"plt.scatter(Xblue[:,0],Xblue[:,1],c='b')\n",
312-
"_=plt.scatter(Xred[:,0],Xred[:,1],c='r')"
298+
"plt.scatter(Xred[:,0],Xred[:,1],c='r');"
313299
]
314300
},
315301
{
@@ -325,12 +311,7 @@
325311
{
326312
"cell_type": "code",
327313
"execution_count": null,
328-
"metadata": {
329-
"ExecuteTime": {
330-
"end_time": "2018-11-27T08:31:51.917021Z",
331-
"start_time": "2018-11-27T08:31:51.427330Z"
332-
}
333-
},
314+
"metadata": {},
334315
"outputs": [],
335316
"source": [
336317
"from sklearn import tree\n",
@@ -378,12 +359,7 @@
378359
{
379360
"cell_type": "code",
380361
"execution_count": null,
381-
"metadata": {
382-
"ExecuteTime": {
383-
"end_time": "2018-11-27T08:31:54.298461Z",
384-
"start_time": "2018-11-27T08:31:54.127632Z"
385-
}
386-
},
362+
"metadata": {},
387363
"outputs": [],
388364
"source": [
389365
"### Generate data\n",
@@ -402,7 +378,9 @@
402378
"cell_type": "markdown",
403379
"metadata": {},
404380
"source": [
405-
"<div class=\"alert alert-warning\">**Exercice:**<br>\n",
381+
"<div class=\"alert alert-warning\">\n",
382+
"\n",
383+
"**Exercice:**<br>\n",
406384
"Implement a Bagging procedure that builds a forest of 101 trees.<br>\n",
407385
"Monitor the training and generalization error of individual trees and of the forest, along the forest growth.<br>\n",
408386
"Display and comment.\n",
@@ -412,12 +390,7 @@
412390
{
413391
"cell_type": "code",
414392
"execution_count": null,
415-
"metadata": {
416-
"ExecuteTime": {
417-
"end_time": "2018-11-27T08:42:35.501698Z",
418-
"start_time": "2018-11-27T08:42:35.495866Z"
419-
}
420-
},
393+
"metadata": {},
421394
"outputs": [],
422395
"source": [
423396
"from sklearn import tree\n",
@@ -435,12 +408,7 @@
435408
{
436409
"cell_type": "code",
437410
"execution_count": null,
438-
"metadata": {
439-
"ExecuteTime": {
440-
"end_time": "2018-11-27T08:42:36.951140Z",
441-
"start_time": "2018-11-27T08:42:36.091230Z"
442-
}
443-
},
411+
"metadata": {},
444412
"outputs": [],
445413
"source": [
446414
"# %load solutions/code2.py\n",
@@ -451,12 +419,7 @@
451419
{
452420
"cell_type": "code",
453421
"execution_count": null,
454-
"metadata": {
455-
"ExecuteTime": {
456-
"end_time": "2018-11-27T08:42:43.119557Z",
457-
"start_time": "2018-11-27T08:42:40.526180Z"
458-
}
459-
},
422+
"metadata": {},
460423
"outputs": [],
461424
"source": [
462425
"### Display\n",
@@ -498,7 +461,7 @@
498461
"name": "python",
499462
"nbconvert_exporter": "python",
500463
"pygments_lexer": "ipython3",
501-
"version": "3.6.4"
464+
"version": "3.6.9"
502465
},
503466
"toc": {
504467
"base_numbering": 1,

0 commit comments

Comments
 (0)