Skip to content

Commit aec96de

Browse files
committed
fixed negative sign
1 parent 3200af6 commit aec96de

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

notebooks/8-optimization.ipynb

+17-17
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"import numpy as np\n",
108108
"import matplotlib.pyplot as plt"
109109
],
110-
"execution_count": null,
110+
"execution_count": 18,
111111
"outputs": []
112112
},
113113
{
@@ -215,7 +215,7 @@
215215
"Let's use the contrived values again to show how MSE is calculated. As covered in [*Calculus II*](https://github.com/jonkrohn/ML-foundations/blob/master/notebooks/4-calculus-ii.ipynb), the individual-instance variant of MSE is *squared error* or *quadratic cost*, which -- as with absolute error -- dictates that the cost for each instance $i$ must be $\\geq 0$: \n",
216216
"\n",
217217
"* $(\\hat{y}_1 - y_1)^2 = (7 - 2)^2 = 5^2 = 25$\n",
218-
"* $(\\hat{y}_2 - y_2)^2 = (3 - 8)^2 = 5^2 = 25$\n",
218+
"* $(\\hat{y}_2 - y_2)^2 = (3 - 8)^2 = (-5)^2 = 25$\n",
219219
"\n",
220220
"As suggested by its name, MSE is the average: $$C = \\frac{1}{n} \\sum_{i=1}^n (\\hat{y_i}-y_i)^2 = \\frac{1}{2} (25 + 25) = \\frac{50}{2} = 25 $$\n",
221221
"\n",
@@ -233,7 +233,7 @@
233233
"source": [
234234
"delta_y = np.linspace(-5, 5, 1000)"
235235
],
236-
"execution_count": null,
236+
"execution_count": 19,
237237
"outputs": []
238238
},
239239
{
@@ -244,7 +244,7 @@
244244
"source": [
245245
"abs_error = np.abs(delta_y)"
246246
],
247-
"execution_count": null,
247+
"execution_count": 20,
248248
"outputs": []
249249
},
250250
{
@@ -255,7 +255,7 @@
255255
"source": [
256256
"sq_error = delta_y**2"
257257
],
258-
"execution_count": null,
258+
"execution_count": 21,
259259
"outputs": []
260260
},
261261
{
@@ -266,7 +266,7 @@
266266
"base_uri": "https://localhost:8080/",
267267
"height": 279
268268
},
269-
"outputId": "09fd0964-4718-4243-8966-45f47e8028c0"
269+
"outputId": "ca63427c-ca25-4fff-9445-a77d6e172e58"
270270
},
271271
"source": [
272272
"fig, ax = plt.subplots()\n",
@@ -282,7 +282,7 @@
282282
"ax.set_ylim(-1, 17)\n",
283283
"_ = ax.legend(['Absolute', 'Squared'])"
284284
],
285-
"execution_count": null,
285+
"execution_count": 22,
286286
"outputs": [
287287
{
288288
"output_type": "display_data",
@@ -361,7 +361,7 @@
361361
"source": [
362362
"x = np.linspace(-10, 10, 1000)"
363363
],
364-
"execution_count": null,
364+
"execution_count": 23,
365365
"outputs": []
366366
},
367367
{
@@ -381,7 +381,7 @@
381381
"source": [
382382
"y_min = x**2 + 3*x + 4"
383383
],
384-
"execution_count": null,
384+
"execution_count": 24,
385385
"outputs": []
386386
},
387387
{
@@ -411,7 +411,7 @@
411411
"base_uri": "https://localhost:8080/",
412412
"height": 265
413413
},
414-
"outputId": "9b8a6556-37e6-41f8-bac7-e010948a5b66"
414+
"outputId": "b5d76c63-d12c-4237-92b9-53509f1d9711"
415415
},
416416
"source": [
417417
"fig, ax = plt.subplots()\n",
@@ -427,7 +427,7 @@
427427
"\n",
428428
"_ = ax.plot(x, y_min)"
429429
],
430-
"execution_count": null,
430+
"execution_count": 25,
431431
"outputs": [
432432
{
433433
"output_type": "display_data",
@@ -470,7 +470,7 @@
470470
"source": [
471471
"y_max = -x**2 + 3*x + 4"
472472
],
473-
"execution_count": null,
473+
"execution_count": 26,
474474
"outputs": []
475475
},
476476
{
@@ -500,7 +500,7 @@
500500
"base_uri": "https://localhost:8080/",
501501
"height": 269
502502
},
503-
"outputId": "58e3dd67-6466-497f-a2b9-d1d8f4184146"
503+
"outputId": "5c77fa62-fa1d-4bfc-ac39-74eabc9781fa"
504504
},
505505
"source": [
506506
"fig, ax = plt.subplots()\n",
@@ -516,7 +516,7 @@
516516
"\n",
517517
"_ = ax.plot(x, y_max)"
518518
],
519-
"execution_count": null,
519+
"execution_count": 27,
520520
"outputs": [
521521
{
522522
"output_type": "display_data",
@@ -559,7 +559,7 @@
559559
"source": [
560560
"y_sp = x**3 + 6"
561561
],
562-
"execution_count": null,
562+
"execution_count": 28,
563563
"outputs": []
564564
},
565565
{
@@ -589,7 +589,7 @@
589589
"base_uri": "https://localhost:8080/",
590590
"height": 269
591591
},
592-
"outputId": "ace66e80-8afc-463e-c3bf-971f1e56dc33"
592+
"outputId": "7680e12d-4d8a-4f8b-a371-d285c6b2b704"
593593
},
594594
"source": [
595595
"fig, ax = plt.subplots()\n",
@@ -605,7 +605,7 @@
605605
"\n",
606606
"_ = ax.plot(x, y_sp)"
607607
],
608-
"execution_count": null,
608+
"execution_count": 29,
609609
"outputs": [
610610
{
611611
"output_type": "display_data",

0 commit comments

Comments
 (0)