Skip to content

Commit ba0cc3a

Browse files
committed
Ending code cells with a semicolon.
1 parent 273262f commit ba0cc3a

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

Chapter5_LossFunctions/LossFunctions.ipynb

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
" label=\"Trip price guess\")\n",
216216
"plt.autoscale(tight=True)\n",
217217
"p3 = plt.Rectangle((0, 0), 1, 1, fc=sp3.get_facecolor()[0])\n",
218-
"plt.legend([p3], [sp3.get_label()])\n"
218+
"plt.legend([p3], [sp3.get_label()]);"
219219
],
220220
"language": "python",
221221
"metadata": {},
@@ -260,7 +260,7 @@
260260
"mcmc = pm.MCMC([true_price, prize_1, prize_2, price_estimate, error])\n",
261261
"mcmc.sample(50000, 10000)\n",
262262
"\n",
263-
"price_trace = mcmc.trace(\"true_price\")[:]\n"
263+
"price_trace = mcmc.trace(\"true_price\")[:];"
264264
],
265265
"language": "python",
266266
"metadata": {},
@@ -300,7 +300,7 @@
300300
"plt.vlines(mu_prior, 0, 1.1 * np.max(_hist[0]), label=\"prior's mean\",\n",
301301
" linestyles=\"--\")\n",
302302
"plt.vlines(price_trace.mean(), 0, 1.1 * np.max(_hist[0]), label=\"posterior's mean\", linestyles=\"-.\")\n",
303-
"plt.legend(loc=\"upper left\")\n"
303+
"plt.legend(loc=\"upper left\");"
304304
],
305305
"language": "python",
306306
"metadata": {},
@@ -381,7 +381,7 @@
381381
"plt.legend(loc=\"upper left\", title=\"Risk parameter\")\n",
382382
"plt.xlabel(\"price bid\")\n",
383383
"plt.ylabel(\"expected loss\")\n",
384-
"plt.xlim(5000, 30000)\n"
384+
"plt.xlim(5000, 30000);"
385385
],
386386
"language": "python",
387387
"metadata": {},
@@ -434,7 +434,7 @@
434434
"plt.xlabel(\"price guess\")\n",
435435
"plt.ylabel(\"expected loss\")\n",
436436
"plt.xlim(7000, 30000)\n",
437-
"plt.ylim(-1000, 80000)\n"
437+
"plt.ylim(-1000, 80000);"
438438
],
439439
"language": "python",
440440
"metadata": {},
@@ -594,7 +594,7 @@
594594
"true_value = -.02\n",
595595
"plt.plot(pred, [stock_loss(true_value, _p) for _p in pred], alpha=0.6, label=\"Loss associated with\\n prediction if true value=-0.02\", lw=3)\n",
596596
"plt.legend()\n",
597-
"plt.title(\"Stock returns loss if true value=0.05, -0.02\")\n"
597+
"plt.title(\"Stock returns loss if true value=0.05, -0.02\");"
598598
],
599599
"language": "python",
600600
"metadata": {},
@@ -642,7 +642,7 @@
642642
"plt.plot(X, ls_coef_ * X + ls_intercept, label=\"Least-squares line\")\n",
643643
"plt.xlim(X.min(), X.max())\n",
644644
"plt.ylim(Y.min(), Y.max())\n",
645-
"plt.legend(loc=\"upper left\")\n"
645+
"plt.legend(loc=\"upper left\");"
646646
],
647647
"language": "python",
648648
"metadata": {},
@@ -695,7 +695,7 @@
695695
"mcmc = pm.MCMC([obs, beta, alpha, std, prec])\n",
696696
"\n",
697697
"mcmc.sample(100000, 80000)\n",
698-
"mcplot(mcmc)\n"
698+
"mcplot(mcmc);"
699699
],
700700
"language": "python",
701701
"metadata": {},
@@ -783,6 +783,7 @@
783783
"figsize(12.5, 6)\n",
784784
"from scipy.optimize import fmin\n",
785785
"\n",
786+
"\n",
786787
"def stock_loss(price, pred, coef=500):\n",
787788
" \"\"\"vectorized for numpy\"\"\"\n",
788789
" sol = np.zeros_like(price)\n",
@@ -816,7 +817,7 @@
816817
"plt.plot(X, ls_coef_ * X + ls_intercept, label=\"Least-squares prediction\")\n",
817818
"plt.xlim(X.min(), X.max())\n",
818819
"plt.plot(trading_signals, opt_predictions, label=\"Bayes action prediction\")\n",
819-
"plt.legend(loc=\"upper left\")\n"
820+
"plt.legend(loc=\"upper left\");"
820821
],
821822
"language": "python",
822823
"metadata": {},
@@ -905,7 +906,7 @@
905906
"fig = draw_sky(data)\n",
906907
"plt.title(\"Galaxy positions and ellipcities of sky %d.\" % n_sky)\n",
907908
"plt.xlabel(\"x-position\")\n",
908-
"plt.ylabel(\"y-position\")\n"
909+
"plt.ylabel(\"y-position\");"
909910
],
910911
"language": "python",
911912
"metadata": {},
@@ -1012,7 +1013,7 @@
10121013
"\n",
10131014
"@pm.deterministic\n",
10141015
"def mean(mass=mass_large, h_pos=halo_position, glx_pos=data[:, :2]):\n",
1015-
" return mass / f_distance(glx_pos, h_pos, 240) * tangential_distance(glx_pos, h_pos)\n"
1016+
" return mass / f_distance(glx_pos, h_pos, 240) * tangential_distance(glx_pos, h_pos);"
10161017
],
10171018
"language": "python",
10181019
"metadata": {},
@@ -1028,7 +1029,7 @@
10281029
"mcmc = pm.MCMC([ellpty, mean, halo_position, mass_large])\n",
10291030
"map_ = pm.MAP([ellpty, mean, halo_position, mass_large])\n",
10301031
"map_.fit()\n",
1031-
"mcmc.sample(200000, 140000, 3)\n"
1032+
"mcmc.sample(200000, 140000, 3);"
10321033
],
10331034
"language": "python",
10341035
"metadata": {},
@@ -1070,7 +1071,7 @@
10701071
"plt.ylabel(\"y-position\")\n",
10711072
"scatter(t[:, 0], t[:, 1], alpha=0.015, c=\"r\")\n",
10721073
"plt.xlim(0, 4200)\n",
1073-
"plt.ylim(0, 4200)\n"
1074+
"plt.ylim(0, 4200);"
10741075
],
10751076
"language": "python",
10761077
"metadata": {},
@@ -1099,7 +1100,7 @@
10991100
" delimiter=\",\",\n",
11001101
" usecols=[1, 2, 3, 4, 5, 6, 7, 8, 9],\n",
11011102
" skip_header=1)\n",
1102-
"print halo_data[n_sky]\n"
1103+
"print halo_data[n_sky];"
11031104
],
11041105
"language": "python",
11051106
"metadata": {},
@@ -1139,7 +1140,7 @@
11391140
"plt.xlim(0, 4200)\n",
11401141
"plt.ylim(0, 4200)\n",
11411142
"\n",
1142-
"print \"True halo location:\", halo_data[n_sky][3], halo_data[n_sky][4]\n"
1143+
"print \"True halo location:\", halo_data[n_sky][3], halo_data[n_sky][4];"
11431144
],
11441145
"language": "python",
11451146
"metadata": {},
@@ -1170,7 +1171,7 @@
11701171
"collapsed": false,
11711172
"input": [
11721173
"mean_posterior = t.mean(axis=0).reshape(1, 2)\n",
1173-
"print mean_posterior\n"
1174+
"print mean_posterior;"
11741175
],
11751176
"language": "python",
11761177
"metadata": {},
@@ -1208,7 +1209,7 @@
12081209
"random_guess = np.random.randint(0, 4200, size=(1, 2))\n",
12091210
"print \"Using a random location:\", random_guess\n",
12101211
"main_score(nhalo_all, x_true_all, y_true_all, x_ref_all, y_ref_all, random_guess)\n",
1211-
"print\n"
1212+
"print;"
12121213
],
12131214
"language": "python",
12141215
"metadata": {},
@@ -1307,7 +1308,7 @@
13071308
"\n",
13081309
" mcmc = pm.MCMC([ellpty, mean, halo_positions, mass_large])\n",
13091310
" mcmc.sample(samples, burn_in, thin)\n",
1310-
" return mcmc.trace(\"halo_positions\")[:]\n"
1311+
" return mcmc.trace(\"halo_positions\")[:];"
13111312
],
13121313
"language": "python",
13131314
"metadata": {},
@@ -1323,7 +1324,7 @@
13231324
" dtype=None,\n",
13241325
" skip_header=1,\n",
13251326
" delimiter=\",\",\n",
1326-
" usecols=[1, 2, 3, 4])\n"
1327+
" usecols=[1, 2, 3, 4]);"
13271328
],
13281329
"language": "python",
13291330
"metadata": {},
@@ -1338,7 +1339,7 @@
13381339
"samples = 10.5e5\n",
13391340
"traces = halo_posteriors(3, data, samples=samples,\n",
13401341
" burn_in=9.5e5,\n",
1341-
" thin=10)\n"
1342+
" thin=10);"
13421343
],
13431344
"language": "python",
13441345
"metadata": {},
@@ -1383,7 +1384,7 @@
13831384
"\n",
13841385
"# plt.legend(scatterpoints=1)\n",
13851386
"plt.xlim(0, 4200)\n",
1386-
"plt.ylim(0, 4200)\n"
1387+
"plt.ylim(0, 4200);"
13871388
],
13881389
"language": "python",
13891390
"metadata": {},
@@ -1434,7 +1435,7 @@
14341435
"random_guess = np.random.randint(0, 4200, size=(1, 2))\n",
14351436
"print \"Using a random location:\", random_guess\n",
14361437
"main_score([1], x_true_all, y_true_all, x_ref_all, y_ref_all, random_guess)\n",
1437-
"print\n"
1438+
"print;"
14381439
],
14391440
"language": "python",
14401441
"metadata": {},
@@ -1514,7 +1515,7 @@
15141515
"def css_styling():\n",
15151516
" styles = open(\"../styles/custom.css\", \"r\").read()\n",
15161517
" return HTML(styles)\n",
1517-
"css_styling()\n"
1518+
"css_styling();"
15181519
],
15191520
"language": "python",
15201521
"metadata": {},

0 commit comments

Comments
 (0)