This commit is contained in:
Morten Hjorth-Jensen
2023-11-21 06:16:54 +01:00
parent a854a3e9c0
commit 06b09eb681
173 changed files with 13894 additions and 3718 deletions
+5 -5
View File
@@ -10,7 +10,7 @@ edge [fontname="helvetica"] ;
2 -> 3 ;
4 [label="gini = 0.0\nsamples = 239\nvalue = [[239, 0]\n[0, 239]]", fillcolor="#e58139"] ;
3 -> 4 ;
5 [label="mean perimeter <= 78.51\ngini = 0.444\nsamples = 3\nvalue = [[2, 1]\n[1, 2]]", fillcolor="#fdf6f0"] ;
5 [label="worst compactness <= 0.085\ngini = 0.444\nsamples = 3\nvalue = [[2, 1]\n[1, 2]]", fillcolor="#fdf6f0"] ;
3 -> 5 ;
6 [label="gini = 0.0\nsamples = 1\nvalue = [[0, 1]\n[1, 0]]", fillcolor="#e58139"] ;
5 -> 6 ;
@@ -30,11 +30,11 @@ edge [fontname="helvetica"] ;
11 -> 13 ;
14 [label="worst texture <= 20.645\ngini = 0.202\nsamples = 167\nvalue = [[19, 148]\n[148, 19]]", fillcolor="#f0b68c"] ;
0 -> 14 [labeldistance=2.5, labelangle=-45, headlabel="False"] ;
15 [label="worst perimeter <= 116.8\ngini = 0.375\nsamples = 16\nvalue = [[12, 4]\n[4, 12]]", fillcolor="#f9e3d4"] ;
15 [label="worst concavity <= 0.318\ngini = 0.375\nsamples = 16\nvalue = [[12, 4]\n[4, 12]]", fillcolor="#f9e3d4"] ;
14 -> 15 ;
16 [label="gini = 0.0\nsamples = 11\nvalue = [[11, 0]\n[0, 11]]", fillcolor="#e58139"] ;
15 -> 16 ;
17 [label="smoothness error <= 0.005\ngini = 0.32\nsamples = 5\nvalue = [[1, 4]\n[4, 1]]", fillcolor="#f6d5bd"] ;
17 [label="area error <= 23.16\ngini = 0.32\nsamples = 5\nvalue = [[1, 4]\n[4, 1]]", fillcolor="#f6d5bd"] ;
15 -> 17 ;
18 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139"] ;
17 -> 18 ;
@@ -42,13 +42,13 @@ edge [fontname="helvetica"] ;
17 -> 19 ;
20 [label="mean concave points <= 0.049\ngini = 0.088\nsamples = 151\nvalue = [[7, 144]\n[144, 7]]", fillcolor="#ea985d"] ;
14 -> 20 ;
21 [label="concave points error <= 0.01\ngini = 0.48\nsamples = 15\nvalue = [[6, 9]\n[9, 6]]", fillcolor="#ffffff"] ;
21 [label="compactness error <= 0.016\ngini = 0.48\nsamples = 15\nvalue = [[6, 9]\n[9, 6]]", fillcolor="#ffffff"] ;
20 -> 21 ;
22 [label="gini = 0.0\nsamples = 9\nvalue = [[0, 9]\n[9, 0]]", fillcolor="#e58139"] ;
21 -> 22 ;
23 [label="gini = 0.0\nsamples = 6\nvalue = [[6, 0]\n[0, 6]]", fillcolor="#e58139"] ;
21 -> 23 ;
24 [label="mean smoothness <= 0.079\ngini = 0.015\nsamples = 136\nvalue = [[1, 135]\n[135, 1]]", fillcolor="#e6853f"] ;
24 [label="worst smoothness <= 0.096\ngini = 0.015\nsamples = 136\nvalue = [[1, 135]\n[135, 1]]", fillcolor="#e6853f"] ;
20 -> 24 ;
25 [label="gini = 0.0\nsamples = 1\nvalue = [[1, 0]\n[0, 1]]", fillcolor="#e58139"] ;
24 -> 25 ;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 KiB

After

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -357,6 +357,11 @@ const thebe_selector_output = ".output, .cell_output"
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

File diff suppressed because it is too large Load Diff
+22 -7
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -1086,13 +1101,13 @@ example of the functionality of <strong>Scikit-Learn</strong>.</p>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>The intercept alpha:
[1.79503422]
[2.07575375]
Coefficient beta :
[[5.33918941]]
Mean squared error: 0.21
Variance score: 0.92
[[4.80180325]]
Mean squared error: 0.28
Variance score: 0.88
Mean squared log error: 0.01
Mean absolute error: 0.37
Mean absolute error: 0.40
</pre></div>
</div>
<img alt="_images/chapter1_19_1.png" src="_images/chapter1_19_1.png" />
@@ -1192,7 +1207,7 @@ a linear <span class="math notranslate nohighlight">\(x\)</span>-dependence we s
</div>
<div class="cell_output docutils container">
<img alt="_images/chapter1_33_0.png" src="_images/chapter1_33_0.png" />
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.005
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.005000000000000002
</pre></div>
</div>
</div>
+41 -655
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -1403,7 +1418,7 @@ the <em>Hadamard product</em>, meaning element-wise multiplication.</p>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Old accuracy on training data: 0.1440501043841336
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15302/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
</pre></div>
</div>
@@ -1677,305 +1692,30 @@ Lambda = 0.0001
Accuracy score on test set: 0.85
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.001
Lambda = 0.001
Accuracy score on test set: 0.875
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.001
Lambda = 0.01
Accuracy score on test set: 0.8666666666666667
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.001
Lambda = 0.1
Accuracy score on test set: 0.8638888888888889
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.001
Lambda = 1.0
Accuracy score on test set: 0.9555555555555556
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.001
Lambda = 10.0
Accuracy score on test set: 0.925
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 1e-05
Accuracy score on test set: 0.9472222222222222
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 0.0001
Accuracy score on test set: 0.9277777777777778
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 0.001
Accuracy score on test set: 0.9472222222222222
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 0.01
Accuracy score on test set: 0.9305555555555556
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 0.1
Accuracy score on test set: 0.9555555555555556
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 1.0
Accuracy score on test set: 0.7694444444444445
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 10.0
Accuracy score on test set: 0.19166666666666668
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.1
Lambda = 1e-05
Accuracy score on test set: 0.10555555555555556
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.1
Lambda = 0.0001
Accuracy score on test set: 0.08611111111111111
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.1
Lambda = 0.001
Accuracy score on test set: 0.10555555555555556
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.1
Lambda = 0.01
Accuracy score on test set: 0.08888888888888889
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.1
Lambda = 0.1
Accuracy score on test set: 0.08611111111111111
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.1
Lambda = 1.0
Accuracy score on test set: 0.08888888888888889
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.1
Lambda = 10.0
Accuracy score on test set: 0.09166666666666666
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1.0
Lambda = 1e-05
Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1.0
Lambda = 0.0001
Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1.0
Lambda = 0.001
Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1.0
Lambda = 0.01
Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1.0
Lambda = 0.1
Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1.0
Lambda = 1.0
Accuracy score on test set: 0.10555555555555556
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1.0
Lambda = 10.0
Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 10.0
Lambda = 1e-05
Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 10.0
Lambda = 0.0001
Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 10.0
Lambda = 0.001
Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 10.0
Lambda = 0.01
Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 10.0
Lambda = 0.1
Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 10.0
Lambda = 1.0
Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:43: RuntimeWarning: overflow encountered in exp
exp_term = np.exp(self.z_o)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/1630775253.py:44: RuntimeWarning: invalid value encountered in true_divide
self.probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 10.0
Lambda = 10.0
Accuracy score on test set: 0.07777777777777778
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span><span class="gt">---------------------------------------------------------------------------</span>
<span class="ne">KeyboardInterrupt</span><span class="g g-Whitespace"> </span>Traceback (most recent call last)
<span class="nn">Input In [8],</span> in <span class="ni">&lt;cell line: 7&gt;</span><span class="nt">()</span>
<span class="g g-Whitespace"> </span><span class="mi">8</span> <span class="k">for</span> <span class="n">j</span><span class="p">,</span> <span class="n">lmbd</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lmbd_vals</span><span class="p">):</span>
<span class="g g-Whitespace"> </span><span class="mi">9</span> <span class="n">dnn</span> <span class="o">=</span> <span class="n">NeuralNetwork</span><span class="p">(</span><span class="n">X_train</span><span class="p">,</span> <span class="n">Y_train_onehot</span><span class="p">,</span> <span class="n">eta</span><span class="o">=</span><span class="n">eta</span><span class="p">,</span> <span class="n">lmbd</span><span class="o">=</span><span class="n">lmbd</span><span class="p">,</span> <span class="n">epochs</span><span class="o">=</span><span class="n">epochs</span><span class="p">,</span> <span class="n">batch_size</span><span class="o">=</span><span class="n">batch_size</span><span class="p">,</span>
<span class="g g-Whitespace"> </span><span class="mi">10</span> <span class="n">n_hidden_neurons</span><span class="o">=</span><span class="n">n_hidden_neurons</span><span class="p">,</span> <span class="n">n_categories</span><span class="o">=</span><span class="n">n_categories</span><span class="p">)</span>
<span class="ne">---&gt; </span><span class="mi">11</span> <span class="n">dnn</span><span class="o">.</span><span class="n">train</span><span class="p">()</span>
<span class="g g-Whitespace"> </span><span class="mi">13</span> <span class="n">DNN_numpy</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">dnn</span>
<span class="g g-Whitespace"> </span><span class="mi">15</span> <span class="n">test_predict</span> <span class="o">=</span> <span class="n">dnn</span><span class="o">.</span><span class="n">predict</span><span class="p">(</span><span class="n">X_test</span><span class="p">)</span>
<span class="nn">Input In [6],</span> in <span class="ni">NeuralNetwork.train</span><span class="nt">(self)</span>
<span class="g g-Whitespace"> </span><span class="mi">95</span> <span class="bp">self</span><span class="o">.</span><span class="n">X_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X_data_full</span><span class="p">[</span><span class="n">chosen_datapoints</span><span class="p">]</span>
<span class="g g-Whitespace"> </span><span class="mi">96</span> <span class="bp">self</span><span class="o">.</span><span class="n">Y_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Y_data_full</span><span class="p">[</span><span class="n">chosen_datapoints</span><span class="p">]</span>
<span class="ne">---&gt; </span><span class="mi">98</span> <span class="bp">self</span><span class="o">.</span><span class="n">feed_forward</span><span class="p">()</span>
<span class="g g-Whitespace"> </span><span class="mi">99</span> <span class="bp">self</span><span class="o">.</span><span class="n">backpropagation</span><span class="p">()</span>
<span class="nn">Input In [6],</span> in <span class="ni">NeuralNetwork.feed_forward</span><span class="nt">(self)</span>
<span class="g g-Whitespace"> </span><span class="mi">36</span> <span class="k">def</span> <span class="nf">feed_forward</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="g g-Whitespace"> </span><span class="mi">37</span> <span class="c1"># feed-forward for training</span>
<span class="ne">---&gt; </span><span class="mi">38</span> <span class="bp">self</span><span class="o">.</span><span class="n">z_h</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">matmul</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">X_data</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">hidden_weights</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">hidden_bias</span>
<span class="g g-Whitespace"> </span><span class="mi">39</span> <span class="bp">self</span><span class="o">.</span><span class="n">a_h</span> <span class="o">=</span> <span class="n">sigmoid</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">z_h</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">41</span> <span class="bp">self</span><span class="o">.</span><span class="n">z_o</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">matmul</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">a_h</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">output_weights</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">output_bias</span>
<span class="ne">KeyboardInterrupt</span>:
</pre></div>
</div>
</div>
@@ -2021,22 +1761,6 @@ Accuracy score on test set: 0.07777777777777778
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8624/953065564.py:4: RuntimeWarning: overflow encountered in exp
return 1/(1 + np.exp(-x))
</pre></div>
</div>
<img alt="_images/chapter10_59_1.png" src="_images/chapter10_59_1.png" />
<img alt="_images/chapter10_59_2.png" src="_images/chapter10_59_2.png" />
</div>
</div>
</div>
<div class="section" id="scikit-learn-implementation">
@@ -2072,332 +1796,6 @@ performance overall.</p>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1e-05
Lambda = 1e-05
Accuracy score on test set: 0.18333333333333332
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1e-05
Lambda = 0.0001
Accuracy score on test set: 0.18611111111111112
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1e-05
Lambda = 0.001
Accuracy score on test set: 0.13055555555555556
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1e-05
Lambda = 0.01
Accuracy score on test set: 0.24444444444444444
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1e-05
Lambda = 0.1
Accuracy score on test set: 0.23333333333333334
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1e-05
Lambda = 1.0
Accuracy score on test set: 0.12777777777777777
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1e-05
Lambda = 10.0
Accuracy score on test set: 0.1527777777777778
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.0001
Lambda = 1e-05
Accuracy score on test set: 0.9111111111111111
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.0001
Lambda = 0.0001
Accuracy score on test set: 0.8888888888888888
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.0001
Lambda = 0.001
Accuracy score on test set: 0.8722222222222222
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.0001
Lambda = 0.01
Accuracy score on test set: 0.8305555555555556
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.0001
Lambda = 0.1
Accuracy score on test set: 0.8888888888888888
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.0001
Lambda = 1.0
Accuracy score on test set: 0.8805555555555555
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.0001
Lambda = 10.0
Accuracy score on test set: 0.8944444444444445
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.001
Lambda = 1e-05
Accuracy score on test set: 0.975
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.001
Lambda = 0.0001
Accuracy score on test set: 0.9777777777777777
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.001
Lambda = 0.001
Accuracy score on test set: 0.9805555555555555
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.001
Lambda = 0.01
Accuracy score on test set: 0.9861111111111112
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.001
Lambda = 0.1
Accuracy score on test set: 0.9805555555555555
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.001
Lambda = 1.0
Accuracy score on test set: 0.9777777777777777
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.001
Lambda = 10.0
Accuracy score on test set: 0.9444444444444444
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/neural_network/_multilayer_perceptron.py:692: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn&#39;t converged yet.
warnings.warn(
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 1e-05
Accuracy score on test set: 0.9861111111111112
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 0.0001
Accuracy score on test set: 0.9888888888888889
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 0.001
Accuracy score on test set: 0.9888888888888889
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 0.01
Accuracy score on test set: 0.9861111111111112
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 0.1
Accuracy score on test set: 0.9888888888888889
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 1.0
Accuracy score on test set: 0.9722222222222222
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.01
Lambda = 10.0
Accuracy score on test set: 0.9527777777777777
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.1
Lambda = 1e-05
Accuracy score on test set: 0.9027777777777778
Learning rate = 0.1
Lambda = 0.0001
Accuracy score on test set: 0.8583333333333333
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.1
Lambda = 0.001
Accuracy score on test set: 0.8722222222222222
Learning rate = 0.1
Lambda = 0.01
Accuracy score on test set: 0.9055555555555556
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.1
Lambda = 0.1
Accuracy score on test set: 0.8805555555555555
Learning rate = 0.1
Lambda = 1.0
Accuracy score on test set: 0.8722222222222222
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.1
Lambda = 10.0
Accuracy score on test set: 0.8666666666666667
Learning rate = 1.0
Lambda = 1e-05
Accuracy score on test set: 0.08611111111111111
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1.0
Lambda = 0.0001
Accuracy score on test set: 0.10555555555555556
Learning rate = 1.0
Lambda = 0.001
Accuracy score on test set: 0.10555555555555556
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1.0
Lambda = 0.01
Accuracy score on test set: 0.17777777777777778
Learning rate = 1.0
Lambda = 0.1
Accuracy score on test set: 0.08333333333333333
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1.0
Lambda = 1.0
Accuracy score on test set: 0.08888888888888889
Learning rate = 1.0
Lambda = 10.0
Accuracy score on test set: 0.09444444444444444
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 10.0
Lambda = 1e-05
Accuracy score on test set: 0.17222222222222222
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 10.0
Lambda = 0.0001
Accuracy score on test set: 0.11666666666666667
Learning rate = 10.0
Lambda = 0.001
Accuracy score on test set: 0.10555555555555556
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 10.0
Lambda = 0.01
Accuracy score on test set: 0.1388888888888889
Learning rate = 10.0
Lambda = 0.1
Accuracy score on test set: 0.11388888888888889
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 10.0
Lambda = 1.0
Accuracy score on test set: 0.10555555555555556
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 10.0
Lambda = 10.0
Accuracy score on test set: 0.09444444444444444
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="id1">
@@ -2441,10 +1839,6 @@ Accuracy score on test set: 0.09444444444444444
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/chapter10_63_0.png" src="_images/chapter10_63_0.png" />
<img alt="_images/chapter10_63_1.png" src="_images/chapter10_63_1.png" />
</div>
</div>
</div>
<div class="section" id="building-neural-networks-in-tensorflow-and-keras">
@@ -2483,14 +1877,6 @@ and/or if you use <strong>anaconda</strong>, just write (or install from the gra
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span> <span class="n">Input</span> <span class="n">In</span> <span class="p">[</span><span class="mi">12</span><span class="p">]</span>
<span class="n">conda</span> <span class="n">create</span> <span class="o">-</span><span class="n">n</span> <span class="n">tf</span> <span class="n">tensorflow</span>
<span class="o">^</span>
<span class="ne">SyntaxError</span>: invalid syntax
</pre></div>
</div>
</div>
</div>
<p>To install the current release of GPU TensorFlow</p>
<div class="cell docutils container">
+28 -133
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -2657,140 +2672,20 @@ Using TensorFlow results in a much better execution time. Try it!</p>
<span class="g g-Whitespace"> </span><span class="mi">19</span> <span class="n">x</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">argnum</span><span class="p">)</span>
<span class="ne">---&gt; </span><span class="mi">20</span> <span class="k">return</span> <span class="n">unary_operator</span><span class="p">(</span><span class="n">unary_f</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">nary_op_args</span><span class="p">,</span> <span class="o">**</span><span class="n">nary_op_kwargs</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/differential_operators.py:25,</span> in <span class="ni">grad</span><span class="nt">(fun, x)</span>
<span class="g g-Whitespace"> </span><span class="mi">18</span> <span class="nd">@unary_to_nary</span>
<span class="g g-Whitespace"> </span><span class="mi">19</span> <span class="k">def</span> <span class="nf">grad</span><span class="p">(</span><span class="n">fun</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
<span class="g g-Whitespace"> </span><span class="mi">20</span><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="g g-Whitespace"> </span><span class="mi">21</span><span class="sd"> Returns a function which computes the gradient of `fun` with respect to</span>
<span class="g g-Whitespace"> </span><span class="mi">22</span><span class="sd"> positional argument number `argnum`. The returned function takes the same</span>
<span class="g g-Whitespace"> </span><span class="mi">23</span><span class="sd"> arguments as `fun`, but returns the gradient instead. The function `fun`</span>
<span class="g g-Whitespace"> </span><span class="mi">24</span><span class="sd"> should be scalar-valued. The gradient has the same type as the argument.&quot;&quot;&quot;</span>
<span class="ne">---&gt; </span><span class="mi">25</span> <span class="n">vjp</span><span class="p">,</span> <span class="n">ans</span> <span class="o">=</span> <span class="n">_make_vjp</span><span class="p">(</span><span class="n">fun</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">26</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">vspace</span><span class="p">(</span><span class="n">ans</span><span class="p">)</span><span class="o">.</span><span class="n">size</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">27</span> <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">&quot;Grad only applies to real scalar-output functions. &quot;</span>
<span class="g g-Whitespace"> </span><span class="mi">28</span> <span class="s2">&quot;Try jacobian, elementwise_grad or holomorphic_grad.&quot;</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/differential_operators.py:29,</span> in <span class="ni">grad</span><span class="nt">(fun, x)</span>
<span class="g g-Whitespace"> </span><span class="mi">26</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">vspace</span><span class="p">(</span><span class="n">ans</span><span class="p">)</span><span class="o">.</span><span class="n">size</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">27</span> <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">&quot;Grad only applies to real scalar-output functions. &quot;</span>
<span class="g g-Whitespace"> </span><span class="mi">28</span> <span class="s2">&quot;Try jacobian, elementwise_grad or holomorphic_grad.&quot;</span><span class="p">)</span>
<span class="ne">---&gt; </span><span class="mi">29</span> <span class="k">return</span> <span class="n">vjp</span><span class="p">(</span><span class="n">vspace</span><span class="p">(</span><span class="n">ans</span><span class="p">)</span><span class="o">.</span><span class="n">ones</span><span class="p">())</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/core.py:10,</span> in <span class="ni">make_vjp</span><span class="nt">(fun, x)</span>
<span class="g g-Whitespace"> </span><span class="mi">8</span> <span class="k">def</span> <span class="nf">make_vjp</span><span class="p">(</span><span class="n">fun</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
<span class="g g-Whitespace"> </span><span class="mi">9</span> <span class="n">start_node</span> <span class="o">=</span> <span class="n">VJPNode</span><span class="o">.</span><span class="n">new_root</span><span class="p">()</span>
<span class="ne">---&gt; </span><span class="mi">10</span> <span class="n">end_value</span><span class="p">,</span> <span class="n">end_node</span> <span class="o">=</span> <span class="n">trace</span><span class="p">(</span><span class="n">start_node</span><span class="p">,</span> <span class="n">fun</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">11</span> <span class="k">if</span> <span class="n">end_node</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">12</span> <span class="k">def</span> <span class="nf">vjp</span><span class="p">(</span><span class="n">g</span><span class="p">):</span> <span class="k">return</span> <span class="n">vspace</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">zeros</span><span class="p">()</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/core.py:14,</span> in <span class="ni">make_vjp.&lt;locals&gt;.vjp</span><span class="nt">(g)</span>
<span class="ne">---&gt; </span><span class="mi">14</span> <span class="k">def</span> <span class="nf">vjp</span><span class="p">(</span><span class="n">g</span><span class="p">):</span> <span class="k">return</span> <span class="n">backward_pass</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">end_node</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/tracer.py:10,</span> in <span class="ni">trace</span><span class="nt">(start_node, fun, x)</span>
<span class="g g-Whitespace"> </span><span class="mi">8</span> <span class="k">with</span> <span class="n">trace_stack</span><span class="o">.</span><span class="n">new_trace</span><span class="p">()</span> <span class="k">as</span> <span class="n">t</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">9</span> <span class="n">start_box</span> <span class="o">=</span> <span class="n">new_box</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">start_node</span><span class="p">)</span>
<span class="ne">---&gt; </span><span class="mi">10</span> <span class="n">end_box</span> <span class="o">=</span> <span class="n">fun</span><span class="p">(</span><span class="n">start_box</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">11</span> <span class="k">if</span> <span class="n">isbox</span><span class="p">(</span><span class="n">end_box</span><span class="p">)</span> <span class="ow">and</span> <span class="n">end_box</span><span class="o">.</span><span class="n">_trace</span> <span class="o">==</span> <span class="n">start_box</span><span class="o">.</span><span class="n">_trace</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">12</span> <span class="k">return</span> <span class="n">end_box</span><span class="o">.</span><span class="n">_value</span><span class="p">,</span> <span class="n">end_box</span><span class="o">.</span><span class="n">_node</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/wrap_util.py:15,</span> in <span class="ni">unary_to_nary.&lt;locals&gt;.nary_operator.&lt;locals&gt;.nary_f.&lt;locals&gt;.unary_f</span><span class="nt">(x)</span>
<span class="g g-Whitespace"> </span><span class="mi">13</span> <span class="k">else</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">14</span> <span class="n">subargs</span> <span class="o">=</span> <span class="n">subvals</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="nb">zip</span><span class="p">(</span><span class="n">argnum</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="ne">---&gt; </span><span class="mi">15</span> <span class="k">return</span> <span class="n">fun</span><span class="p">(</span><span class="o">*</span><span class="n">subargs</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="nn">Input In [9],</span> in <span class="ni">cost_function</span><span class="nt">(P, x, t)</span>
<span class="g g-Whitespace"> </span><span class="mi">78</span> <span class="n">g_t</span> <span class="o">=</span> <span class="n">g_trial</span><span class="p">(</span><span class="n">point</span><span class="p">,</span><span class="n">P</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">79</span> <span class="n">g_t_jacobian</span> <span class="o">=</span> <span class="n">g_t_jacobian_func</span><span class="p">(</span><span class="n">point</span><span class="p">,</span><span class="n">P</span><span class="p">)</span>
<span class="ne">---&gt; </span><span class="mi">80</span> <span class="n">g_t_hessian</span> <span class="o">=</span> <span class="n">g_t_hessian_func</span><span class="p">(</span><span class="n">point</span><span class="p">,</span><span class="n">P</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">82</span> <span class="n">g_t_dt</span> <span class="o">=</span> <span class="n">g_t_jacobian</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="g g-Whitespace"> </span><span class="mi">83</span> <span class="n">g_t_d2x</span> <span class="o">=</span> <span class="n">g_t_hessian</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/wrap_util.py:20,</span> in <span class="ni">unary_to_nary.&lt;locals&gt;.nary_operator.&lt;locals&gt;.nary_f</span><span class="nt">(*args, **kwargs)</span>
<span class="g g-Whitespace"> </span><span class="mi">18</span> <span class="k">else</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">19</span> <span class="n">x</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">argnum</span><span class="p">)</span>
<span class="ne">---&gt; </span><span class="mi">20</span> <span class="k">return</span> <span class="n">unary_operator</span><span class="p">(</span><span class="n">unary_f</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">nary_op_args</span><span class="p">,</span> <span class="o">**</span><span class="n">nary_op_kwargs</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/differential_operators.py:78,</span> in <span class="ni">hessian</span><span class="nt">(fun, x)</span>
<span class="g g-Whitespace"> </span><span class="mi">75</span> <span class="nd">@unary_to_nary</span>
<span class="g g-Whitespace"> </span><span class="mi">76</span> <span class="k">def</span> <span class="nf">hessian</span><span class="p">(</span><span class="n">fun</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
<span class="g g-Whitespace"> </span><span class="mi">77</span> <span class="s2">&quot;Returns a function that computes the exact Hessian.&quot;</span>
<span class="ne">---&gt; </span><span class="mi">78</span> <span class="k">return</span> <span class="n">jacobian</span><span class="p">(</span><span class="n">jacobian</span><span class="p">(</span><span class="n">fun</span><span class="p">))(</span><span class="n">x</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/wrap_util.py:20,</span> in <span class="ni">unary_to_nary.&lt;locals&gt;.nary_operator.&lt;locals&gt;.nary_f</span><span class="nt">(*args, **kwargs)</span>
<span class="g g-Whitespace"> </span><span class="mi">18</span> <span class="k">else</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">19</span> <span class="n">x</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">argnum</span><span class="p">)</span>
<span class="ne">---&gt; </span><span class="mi">20</span> <span class="k">return</span> <span class="n">unary_operator</span><span class="p">(</span><span class="n">unary_f</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">nary_op_args</span><span class="p">,</span> <span class="o">**</span><span class="n">nary_op_kwargs</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/differential_operators.py:57,</span> in <span class="ni">jacobian</span><span class="nt">(fun, x)</span>
<span class="g g-Whitespace"> </span><span class="mi">47</span> <span class="nd">@unary_to_nary</span>
<span class="g g-Whitespace"> </span><span class="mi">48</span> <span class="k">def</span> <span class="nf">jacobian</span><span class="p">(</span><span class="n">fun</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
<span class="g g-Whitespace"> </span><span class="mi">49</span><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="g g-Whitespace"> </span><span class="mi">50</span><span class="sd"> Returns a function which computes the Jacobian of `fun` with respect to</span>
<span class="g g-Whitespace"> </span><span class="mi">51</span><span class="sd"> positional argument number `argnum`, which must be a scalar or array. Unlike</span>
<span class="sd"> (...)</span>
<span class="g g-Whitespace"> </span><span class="mi">55</span><span class="sd"> (out1, out2, ...) then the Jacobian has shape (out1, out2, ..., in1, in2, ...).</span>
<span class="g g-Whitespace"> </span><span class="mi">56</span><span class="sd"> &quot;&quot;&quot;</span>
<span class="ne">---&gt; </span><span class="mi">57</span> <span class="n">vjp</span><span class="p">,</span> <span class="n">ans</span> <span class="o">=</span> <span class="n">_make_vjp</span><span class="p">(</span><span class="n">fun</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">58</span> <span class="n">ans_vspace</span> <span class="o">=</span> <span class="n">vspace</span><span class="p">(</span><span class="n">ans</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">59</span> <span class="n">jacobian_shape</span> <span class="o">=</span> <span class="n">ans_vspace</span><span class="o">.</span><span class="n">shape</span> <span class="o">+</span> <span class="n">vspace</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">shape</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/core.py:10,</span> in <span class="ni">make_vjp</span><span class="nt">(fun, x)</span>
<span class="g g-Whitespace"> </span><span class="mi">8</span> <span class="k">def</span> <span class="nf">make_vjp</span><span class="p">(</span><span class="n">fun</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
<span class="g g-Whitespace"> </span><span class="mi">9</span> <span class="n">start_node</span> <span class="o">=</span> <span class="n">VJPNode</span><span class="o">.</span><span class="n">new_root</span><span class="p">()</span>
<span class="ne">---&gt; </span><span class="mi">10</span> <span class="n">end_value</span><span class="p">,</span> <span class="n">end_node</span> <span class="o">=</span> <span class="n">trace</span><span class="p">(</span><span class="n">start_node</span><span class="p">,</span> <span class="n">fun</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">11</span> <span class="k">if</span> <span class="n">end_node</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">12</span> <span class="k">def</span> <span class="nf">vjp</span><span class="p">(</span><span class="n">g</span><span class="p">):</span> <span class="k">return</span> <span class="n">vspace</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">zeros</span><span class="p">()</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/tracer.py:10,</span> in <span class="ni">trace</span><span class="nt">(start_node, fun, x)</span>
<span class="g g-Whitespace"> </span><span class="mi">8</span> <span class="k">with</span> <span class="n">trace_stack</span><span class="o">.</span><span class="n">new_trace</span><span class="p">()</span> <span class="k">as</span> <span class="n">t</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">9</span> <span class="n">start_box</span> <span class="o">=</span> <span class="n">new_box</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">start_node</span><span class="p">)</span>
<span class="ne">---&gt; </span><span class="mi">10</span> <span class="n">end_box</span> <span class="o">=</span> <span class="n">fun</span><span class="p">(</span><span class="n">start_box</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">11</span> <span class="k">if</span> <span class="n">isbox</span><span class="p">(</span><span class="n">end_box</span><span class="p">)</span> <span class="ow">and</span> <span class="n">end_box</span><span class="o">.</span><span class="n">_trace</span> <span class="o">==</span> <span class="n">start_box</span><span class="o">.</span><span class="n">_trace</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">12</span> <span class="k">return</span> <span class="n">end_box</span><span class="o">.</span><span class="n">_value</span><span class="p">,</span> <span class="n">end_box</span><span class="o">.</span><span class="n">_node</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/wrap_util.py:15,</span> in <span class="ni">unary_to_nary.&lt;locals&gt;.nary_operator.&lt;locals&gt;.nary_f.&lt;locals&gt;.unary_f</span><span class="nt">(x)</span>
<span class="g g-Whitespace"> </span><span class="mi">13</span> <span class="k">else</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">14</span> <span class="n">subargs</span> <span class="o">=</span> <span class="n">subvals</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="nb">zip</span><span class="p">(</span><span class="n">argnum</span><span class="p">,</span> <span class="n">x</span><span class="p">))</span>
<span class="ne">---&gt; </span><span class="mi">15</span> <span class="k">return</span> <span class="n">fun</span><span class="p">(</span><span class="o">*</span><span class="n">subargs</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/wrap_util.py:20,</span> in <span class="ni">unary_to_nary.&lt;locals&gt;.nary_operator.&lt;locals&gt;.nary_f</span><span class="nt">(*args, **kwargs)</span>
<span class="g g-Whitespace"> </span><span class="mi">18</span> <span class="k">else</span><span class="p">:</span>
<span class="g g-Whitespace"> </span><span class="mi">19</span> <span class="n">x</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">argnum</span><span class="p">)</span>
<span class="ne">---&gt; </span><span class="mi">20</span> <span class="k">return</span> <span class="n">unary_operator</span><span class="p">(</span><span class="n">unary_f</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">nary_op_args</span><span class="p">,</span> <span class="o">**</span><span class="n">nary_op_kwargs</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/differential_operators.py:61,</span> in <span class="ni">jacobian</span><span class="nt">(fun, x)</span>
<span class="g g-Whitespace"> </span><span class="mi">59</span> <span class="n">jacobian_shape</span> <span class="o">=</span> <span class="n">ans_vspace</span><span class="o">.</span><span class="n">shape</span> <span class="o">+</span> <span class="n">vspace</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">.</span><span class="n">shape</span>
<span class="g g-Whitespace"> </span><span class="mi">60</span> <span class="n">grads</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="n">vjp</span><span class="p">,</span> <span class="n">ans_vspace</span><span class="o">.</span><span class="n">standard_basis</span><span class="p">())</span>
<span class="ne">---&gt; </span><span class="mi">61</span> <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">stack</span><span class="p">(</span><span class="n">grads</span><span class="p">),</span> <span class="n">jacobian_shape</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/numpy/numpy_wrapper.py:103,</span> in <span class="ni">stack</span><span class="nt">(arrays, axis)</span>
<span class="g g-Whitespace"> </span><span class="mi">100</span> <span class="n">axis</span> <span class="o">+=</span> <span class="n">result_ndim</span>
<span class="g g-Whitespace"> </span><span class="mi">102</span> <span class="n">sl</span> <span class="o">=</span> <span class="p">(</span><span class="nb">slice</span><span class="p">(</span><span class="kc">None</span><span class="p">),)</span> <span class="o">*</span> <span class="n">axis</span> <span class="o">+</span> <span class="p">(</span><span class="kc">None</span><span class="p">,)</span>
<span class="ne">--&gt; </span><span class="mi">103</span> <span class="k">return</span> <span class="n">concatenate</span><span class="p">([</span><span class="n">arr</span><span class="p">[</span><span class="n">sl</span><span class="p">]</span> <span class="k">for</span> <span class="n">arr</span> <span class="ow">in</span> <span class="n">arrays</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="n">axis</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/numpy/numpy_wrapper.py:103,</span> in <span class="ni">&lt;listcomp&gt;</span><span class="nt">(.0)</span>
<span class="g g-Whitespace"> </span><span class="mi">100</span> <span class="n">axis</span> <span class="o">+=</span> <span class="n">result_ndim</span>
<span class="g g-Whitespace"> </span><span class="mi">102</span> <span class="n">sl</span> <span class="o">=</span> <span class="p">(</span><span class="nb">slice</span><span class="p">(</span><span class="kc">None</span><span class="p">),)</span> <span class="o">*</span> <span class="n">axis</span> <span class="o">+</span> <span class="p">(</span><span class="kc">None</span><span class="p">,)</span>
<span class="ne">--&gt; </span><span class="mi">103</span> <span class="k">return</span> <span class="n">concatenate</span><span class="p">([</span><span class="n">arr</span><span class="p">[</span><span class="n">sl</span><span class="p">]</span> <span class="k">for</span> <span class="n">arr</span> <span class="ow">in</span> <span class="n">arrays</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="n">axis</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/tracer.py:44,</span> in <span class="ni">primitive.&lt;locals&gt;.f_wrapped</span><span class="nt">(*args, **kwargs)</span>
<span class="g g-Whitespace"> </span><span class="mi">42</span> <span class="n">parents</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">box</span><span class="o">.</span><span class="n">_node</span> <span class="k">for</span> <span class="n">_</span> <span class="p">,</span> <span class="n">box</span> <span class="ow">in</span> <span class="n">boxed_args</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">43</span> <span class="n">argnums</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">argnum</span> <span class="k">for</span> <span class="n">argnum</span><span class="p">,</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">boxed_args</span><span class="p">)</span>
<span class="ne">---&gt; </span><span class="mi">44</span> <span class="n">ans</span> <span class="o">=</span> <span class="n">f_wrapped</span><span class="p">(</span><span class="o">*</span><span class="n">argvals</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">45</span> <span class="n">node</span> <span class="o">=</span> <span class="n">node_constructor</span><span class="p">(</span><span class="n">ans</span><span class="p">,</span> <span class="n">f_wrapped</span><span class="p">,</span> <span class="n">argvals</span><span class="p">,</span> <span class="n">kwargs</span><span class="p">,</span> <span class="n">argnums</span><span class="p">,</span> <span class="n">parents</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">46</span> <span class="k">return</span> <span class="n">new_box</span><span class="p">(</span><span class="n">ans</span><span class="p">,</span> <span class="n">trace</span><span class="p">,</span> <span class="n">node</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/tracer.py:45,</span> in <span class="ni">primitive.&lt;locals&gt;.f_wrapped</span><span class="nt">(*args, **kwargs)</span>
<span class="g g-Whitespace"> </span><span class="mi">43</span> <span class="n">argnums</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">argnum</span> <span class="k">for</span> <span class="n">argnum</span><span class="p">,</span> <span class="n">_</span> <span class="ow">in</span> <span class="n">boxed_args</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">44</span> <span class="n">ans</span> <span class="o">=</span> <span class="n">f_wrapped</span><span class="p">(</span><span class="o">*</span><span class="n">argvals</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="ne">---&gt; </span><span class="mi">45</span> <span class="n">node</span> <span class="o">=</span> <span class="n">node_constructor</span><span class="p">(</span><span class="n">ans</span><span class="p">,</span> <span class="n">f_wrapped</span><span class="p">,</span> <span class="n">argvals</span><span class="p">,</span> <span class="n">kwargs</span><span class="p">,</span> <span class="n">argnums</span><span class="p">,</span> <span class="n">parents</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">46</span> <span class="k">return</span> <span class="n">new_box</span><span class="p">(</span><span class="n">ans</span><span class="p">,</span> <span class="n">trace</span><span class="p">,</span> <span class="n">node</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">47</span> <span class="k">else</span><span class="p">:</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/core.py:36,</span> in <span class="ni">VJPNode.__init__</span><span class="nt">(self, value, fun, args, kwargs, parent_argnums, parents)</span>
<span class="g g-Whitespace"> </span><span class="mi">33</span> <span class="n">fun_name</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">fun</span><span class="p">,</span> <span class="s1">&#39;__name__&#39;</span><span class="p">,</span> <span class="n">fun</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">34</span> <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">&quot;VJP of </span><span class="si">{}</span><span class="s2"> wrt argnums </span><span class="si">{}</span><span class="s2"> not defined&quot;</span>
<span class="g g-Whitespace"> </span><span class="mi">35</span> <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">fun_name</span><span class="p">,</span> <span class="n">parent_argnums</span><span class="p">))</span>
<span class="ne">---&gt; </span><span class="mi">36</span> <span class="bp">self</span><span class="o">.</span><span class="n">vjp</span> <span class="o">=</span> <span class="n">vjpmaker</span><span class="p">(</span><span class="n">parent_argnums</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span><span class="p">)</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/core.py:56,</span> in <span class="ni">defvjp.&lt;locals&gt;.vjp_argnums</span><span class="nt">(argnums, ans, args, kwargs)</span>
<span class="g g-Whitespace"> </span><span class="mi">53</span> <span class="n">argnums</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;argnums&#39;</span><span class="p">,</span> <span class="n">count</span><span class="p">())</span>
<span class="g g-Whitespace"> </span><span class="mi">54</span> <span class="n">vjps_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">argnum</span> <span class="p">:</span> <span class="n">translate_vjp</span><span class="p">(</span><span class="n">vjpmaker</span><span class="p">,</span> <span class="n">fun</span><span class="p">,</span> <span class="n">argnum</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">55</span> <span class="k">for</span> <span class="n">argnum</span><span class="p">,</span> <span class="n">vjpmaker</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">argnums</span><span class="p">,</span> <span class="n">vjpmakers</span><span class="p">)}</span>
<span class="ne">---&gt; </span><span class="mi">56</span> <span class="k">def</span> <span class="nf">vjp_argnums</span><span class="p">(</span><span class="n">argnums</span><span class="p">,</span> <span class="n">ans</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span><span class="p">):</span>
<span class="g g-Whitespace"> </span><span class="mi">57</span> <span class="n">L</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">argnums</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">58</span> <span class="c1"># These first two cases are just optimizations</span>
<span class="nn">File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/core.py:23,</span> in <span class="ni">backward_pass</span><span class="nt">(g, end_node)</span>
<span class="g g-Whitespace"> </span><span class="mi">21</span> <span class="n">ingrads</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">vjp</span><span class="p">(</span><span class="n">outgrad</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="g g-Whitespace"> </span><span class="mi">22</span> <span class="k">for</span> <span class="n">parent</span><span class="p">,</span> <span class="n">ingrad</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">parents</span><span class="p">,</span> <span class="n">ingrads</span><span class="p">):</span>
<span class="ne">---&gt; </span><span class="mi">23</span> <span class="n">outgrads</span><span class="p">[</span><span class="n">parent</span><span class="p">]</span> <span class="o">=</span> <span class="n">add_outgrads</span><span class="p">(</span><span class="n">outgrads</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">parent</span><span class="p">),</span> <span class="n">ingrad</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">24</span> <span class="k">return</span> <span class="n">outgrad</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="ne">KeyboardInterrupt</span>:
</pre></div>
+37 -2
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -1317,7 +1332,27 @@ labels = (n_inputs) = (1797,)
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/keras/optimizer_v2/gradient_descent.py:102: UserWarning: The `lr` argument is deprecated, use `learning_rate` instead.
super(SGD, self).__init__(name, **kwargs)
2023-11-08 15:24:42.293245: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
2023-11-21 06:09:14.627153: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 1/12 [=&gt;............................] - ETA: 1s - loss: 2.5762 - accuracy: 0.2188
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>
7/12 [================&gt;.............] - ETA: 0s - loss: 2.7312 - accuracy: 0.2277
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>
12/12 [==============================] - ETA: 0s - loss: 2.7089 - accuracy: 0.2389
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>
12/12 [==============================] - 1s 35ms/step - loss: 2.7089 - accuracy: 0.2389
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 1e-05
Lambda = 1e-05
Test accuracy: 0.239
</pre></div>
</div>
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span><span class="gt">---------------------------------------------------------------------------</span>
+93 -54
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -720,321 +735,345 @@ systems such as automatic translation and speech-to-text.</p>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 1/100
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2023-11-08 15:25:18.982829: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2023-11-21 06:09:51.383315: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 3s - loss: 1.7073 - 3s/epoch - 65ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 2s - loss: 0.6262 - 2s/epoch - 43ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 2/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.5091 - 450ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4148 - 440ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 3/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4349 - 447ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4134 - 485ms/epoch - 10ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 4/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4192 - 447ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 1s - loss: 0.4111 - 507ms/epoch - 10ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 5/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4095 - 448ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4099 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 6/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4056 - 450ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4051 - 449ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 7/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4055 - 451ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4082 - 448ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 8/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4025 - 449ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4052 - 447ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 9/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3975 - 452ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4032 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 10/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3994 - 451ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4053 - 439ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 11/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3976 - 449ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4007 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 12/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3973 - 455ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4036 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 13/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3951 - 452ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4008 - 449ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 14/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3957 - 454ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3978 - 447ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 15/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3953 - 472ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.4018 - 449ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 16/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3940 - 479ms/epoch - 10ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3984 - 448ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 17/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3939 - 455ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3975 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 18/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3897 - 483ms/epoch - 10ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3954 - 447ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 19/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3936 - 467ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3995 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 20/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3929 - 455ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3987 - 449ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 21/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3913 - 455ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3961 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 22/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3900 - 463ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3948 - 444ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 23/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 1s - loss: 0.3921 - 516ms/epoch - 10ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3968 - 447ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 24/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3903 - 485ms/epoch - 10ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3970 - 447ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 25/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3902 - 471ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3929 - 444ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 26/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3887 - 472ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3971 - 445ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 27/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 1s - loss: 0.3895 - 519ms/epoch - 10ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3960 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 28/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3873 - 477ms/epoch - 10ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3915 - 447ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 29/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3879 - 500ms/epoch - 10ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3942 - 449ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 30/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3876 - 485ms/epoch - 10ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3937 - 445ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 31/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3865 - 472ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3944 - 445ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 32/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3856 - 459ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3912 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 33/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 1s - loss: 0.3856 - 502ms/epoch - 10ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3939 - 445ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 34/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3839 - 479ms/epoch - 10ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3932 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 35/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3853 - 459ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3863 - 445ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 36/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3827 - 457ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3880 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 37/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3824 - 453ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3888 - 447ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 38/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3824 - 455ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3893 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 39/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3812 - 455ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3895 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 40/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3823 - 469ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3904 - 448ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 41/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 1s - loss: 0.3814 - 527ms/epoch - 11ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3877 - 448ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 42/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3814 - 464ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3852 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 43/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3812 - 453ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3902 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 44/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3779 - 456ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3856 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 45/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3797 - 457ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3876 - 447ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 46/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3808 - 460ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3880 - 444ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 47/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3788 - 460ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3873 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 48/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3792 - 455ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3848 - 448ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 49/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3765 - 457ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3852 - 447ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 50/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3775 - 454ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3877 - 447ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 51/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3777 - 458ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3852 - 447ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 52/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3770 - 458ms/epoch - 9ms/step
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3840 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 53/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3834 - 444ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 54/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3851 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 55/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3864 - 446ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 56/100
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>50/50 - 0s - loss: 0.3812 - 447ms/epoch - 9ms/step
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Epoch 57/100
</pre></div>
</div>
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span><span class="gt">---------------------------------------------------------------------------</span>
<span class="ne">KeyboardInterrupt</span><span class="g g-Whitespace"> </span>Traceback (most recent call last)
<span class="nn">Input In [1],</span> in <span class="ni">&lt;cell line: 58&gt;</span><span class="nt">()</span>
+77 -59
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -1335,10 +1350,10 @@ covariance matrix through the <strong>np.linalg.eig()</strong> function.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.07752620206774397
4.3068687590657415
[[1.01031184 2.85759522]
[2.85759522 9.0542566 ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.031405320178937886
3.7508636683863235
[[ 1.07728714 3.41235715]
[ 3.41235715 11.76274779]]
</pre></div>
</div>
</div>
@@ -1375,10 +1390,10 @@ a more brute force way. Here we scale the mean values for each column of the des
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.07472152457534222
1.4560786541572335
[[1. 0.61219726]
[0.61219726 1. ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.08460107110703337
1.9541100061668464
[[1. 0.73391309]
[0.73391309 1. ]]
</pre></div>
</div>
</div>
@@ -1408,30 +1423,30 @@ this matrix we easily see that it is a positive definite matrix.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[-0.59265811 -0.57943748]
[ 0.08641073 0.06656566]
[-0.68596176 -2.59060904]
[ 0.47558206 1.64482901]
[ 0.21597684 -0.67723533]
[ 1.22935165 5.02293408]
[-0.51249881 -3.38478181]
[ 0.29220202 1.35149796]
[ 0.10955639 0.86177342]
[-0.61796102 -1.71553646]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[-0.80226723 -3.04272582]
[ 0.43201921 2.14816084]
[ 1.57309147 3.36212275]
[-1.88172029 -7.76015446]
[ 1.07203435 4.92153252]
[ 0.60376519 3.40447029]
[-0.63613568 -1.37836163]
[-1.93626155 -5.91514067]
[ 1.59593425 4.28910504]
[-0.02045972 -0.02900886]]
0 1
0 -0.592658 -0.579437
1 0.086411 0.066566
2 -0.685962 -2.590609
3 0.475582 1.644829
4 0.215977 -0.677235
5 1.229352 5.022934
6 -0.512499 -3.384782
7 0.292202 1.351498
8 0.109556 0.861773
9 -0.617961 -1.715536
0 -0.802267 -3.042726
1 0.432019 2.148161
2 1.573091 3.362123
3 -1.881720 -7.760154
4 1.072034 4.921533
5 0.603765 3.404470
6 -0.636136 -1.378362
7 -1.936262 -5.915141
8 1.595934 4.289105
9 -0.020460 -0.029009
0 1
0 1.000000 0.921567
1 0.921567 1.000000
0 1.000000 0.965295
1 0.965295 1.000000
</pre></div>
</div>
</div>
@@ -1488,37 +1503,40 @@ this matrix we easily see that it is a positive definite matrix.</p>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 0 1 2 3 4 5 6 7 \
0 0.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.0 0.079330 0.084471 0.080541 0.081753 0.082306 0.073011 0.072990
2 0.0 0.084471 0.092487 0.087280 0.089513 0.090777 0.079391 0.079777
3 0.0 0.080541 0.087280 0.087211 0.088900 0.089752 0.082231 0.082329
4 0.0 0.081753 0.089513 0.088900 0.091023 0.092206 0.083848 0.084164
5 0.0 0.082306 0.090777 0.089752 0.092206 0.093657 0.084672 0.085172
6 0.0 0.073011 0.079391 0.082231 0.083848 0.084672 0.079611 0.079715
7 0.0 0.072990 0.079777 0.082329 0.084164 0.085172 0.079715 0.079958
8 0.0 0.072802 0.079892 0.082196 0.084212 0.085382 0.079597 0.079964
9 0.0 0.072527 0.079854 0.081937 0.084110 0.085425 0.079353 0.079836
10 0.0 0.064985 0.070571 0.075171 0.076586 0.077304 0.074181 0.074265
11 0.0 0.064627 0.070400 0.074809 0.076355 0.077194 0.073842 0.074026
12 0.0 0.064245 0.070170 0.074403 0.076066 0.077017 0.073458 0.073736
13 0.0 0.063864 0.069919 0.073987 0.075758 0.076814 0.073063 0.073431
14 0.0 0.063500 0.069672 0.073582 0.075454 0.076612 0.072676 0.073131
1 0.0 0.090537 0.085374 0.090091 0.089893 0.089356 0.080696 0.081199
2 0.0 0.085374 0.081563 0.083636 0.083982 0.084114 0.074319 0.075079
3 0.0 0.090091 0.083636 0.094993 0.094026 0.092598 0.088156 0.088323
4 0.0 0.089893 0.083982 0.094026 0.093386 0.092327 0.086892 0.087259
5 0.0 0.089356 0.084114 0.092598 0.092327 0.091697 0.085163 0.085746
6 0.0 0.080696 0.074319 0.088156 0.086892 0.085163 0.083797 0.083762
7 0.0 0.081199 0.075079 0.088323 0.087259 0.085746 0.083762 0.083873
8 0.0 0.081680 0.075858 0.088410 0.087566 0.086291 0.083628 0.083894
9 0.0 0.082105 0.076636 0.088369 0.087768 0.086762 0.083348 0.083777
10 0.0 0.071274 0.065396 0.079741 0.078433 0.076697 0.077121 0.077004
11 0.0 0.071854 0.066119 0.080197 0.079026 0.077431 0.077466 0.077460
12 0.0 0.072470 0.066891 0.080665 0.079640 0.078196 0.077810 0.077920
13 0.0 0.073113 0.067709 0.081133 0.080262 0.078981 0.078139 0.078370
14 0.0 0.073773 0.068568 0.081581 0.080878 0.079775 0.078433 0.078791
8 9 10 11 12 13 14
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.072802 0.072527 0.064985 0.064627 0.064245 0.063864 0.063500
2 0.079892 0.079854 0.070571 0.070400 0.070170 0.069919 0.069672
3 0.082196 0.081937 0.075171 0.074809 0.074403 0.073987 0.073582
4 0.084212 0.084110 0.076586 0.076355 0.076066 0.075758 0.075454
5 0.085382 0.085425 0.077304 0.077194 0.077017 0.076814 0.076612
6 0.079597 0.079353 0.074181 0.073842 0.073458 0.073063 0.072676
7 0.079964 0.079836 0.074265 0.074026 0.073736 0.073431 0.073131
8 0.080086 0.080069 0.074152 0.074008 0.073810 0.073592 0.073378
9 0.080069 0.080157 0.073929 0.073876 0.073766 0.073635 0.073504
10 0.074152 0.073929 0.070129 0.069821 0.069475 0.069119 0.068771
11 0.074008 0.073876 0.069821 0.069595 0.069327 0.069048 0.068774
12 0.073810 0.073766 0.069475 0.069327 0.069136 0.068931 0.068731
13 0.073592 0.073635 0.069119 0.069048 0.068931 0.068800 0.068671
14 0.073378 0.073504 0.068771 0.068774 0.068731 0.068671 0.068612
1 0.081680 0.082105 0.071274 0.071854 0.072470 0.073113 0.073773
2 0.075858 0.076636 0.065396 0.066119 0.066891 0.067709 0.068568
3 0.088410 0.088369 0.079741 0.080197 0.080665 0.081133 0.081581
4 0.087566 0.087768 0.078433 0.079026 0.079640 0.080262 0.080878
5 0.086291 0.086762 0.076697 0.077431 0.078196 0.078981 0.079775
6 0.083628 0.083348 0.077121 0.077466 0.077810 0.078139 0.078433
7 0.083894 0.083777 0.077004 0.077460 0.077920 0.078370 0.078791
8 0.084078 0.084137 0.076786 0.077358 0.077938 0.078514 0.079067
9 0.084137 0.084387 0.076427 0.077117 0.077822 0.078529 0.079223
10 0.076786 0.076427 0.071915 0.072200 0.072478 0.072735 0.072954
11 0.077358 0.077117 0.072200 0.072576 0.072948 0.073302 0.073621
12 0.077938 0.077822 0.072478 0.072948 0.073417 0.073871 0.074292
13 0.078514 0.078529 0.072735 0.073302 0.073871 0.074428 0.074956
14 0.079067 0.079223 0.072954 0.073621 0.074292 0.074956 0.075597
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>
</pre></div>
</div>
</div>
+52 -37
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -889,10 +904,10 @@ number <span class="math notranslate nohighlight">\(i\)</span> is left out. Usin
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Runtime: 0.155664 sec
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Runtime: 0.155073 sec
Jackknife Statistics :
original bias std. error
99.9688 99.9588 0.15043
100.27 100.26 0.150592
</pre></div>
</div>
</div>
@@ -1111,7 +1126,7 @@ theorem.</p>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Bootstrap Statistics :
original bias std. error
100.132 14.8115 100.132 0.147896
100.186 14.9807 100.189 0.148711
</pre></div>
</div>
</div>
@@ -1660,15 +1675,15 @@ Mean squared error on test data: 1371.99051150
Degree of polynomial: 20
Mean squared error on training data: 0.00137818
Mean squared error on test data: 1887.86252988
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 21
Degree of polynomial: 21
Mean squared error on training data: 0.00118508
Mean squared error on test data: 14859.69908626
Degree of polynomial: 22
Mean squared error on training data: 0.00092647
Mean squared error on test data: 876.51191552
Degree of polynomial: 23
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 23
Mean squared error on training data: 0.00085889
Mean squared error on test data: 5594.60815105
Degree of polynomial: 24
@@ -1683,19 +1698,19 @@ Mean squared error on test data: 19003.94822514
Degree of polynomial: 27
Mean squared error on training data: 0.00068946
Mean squared error on test data: 2379.66219404
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 28
Degree of polynomial: 28
Mean squared error on training data: 0.00062595
Mean squared error on test data: 4082.19983530
Degree of polynomial: 29
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 29
Mean squared error on training data: 0.00060705
Mean squared error on test data: 3250.17647619
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/626635268.py:73: RuntimeWarning: divide by zero encountered in log10
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/626635268.py:73: RuntimeWarning: divide by zero encountered in log10
plt.plot(polynomial, np.log10(trainingerror), label=&#39;Training Error&#39;)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/626635268.py:74: RuntimeWarning: divide by zero encountered in log10
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/626635268.py:74: RuntimeWarning: divide by zero encountered in log10
plt.plot(polynomial, np.log10(testerror), label=&#39;Test Error&#39;)
</pre></div>
</div>
@@ -1929,7 +1944,7 @@ cross-validation (LOOCV).</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/3817475779.py:63: RuntimeWarning: divide by zero encountered in log10
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/3817475779.py:63: RuntimeWarning: divide by zero encountered in log10
plt.plot(polynomial, np.log10(estimated_mse_sklearn), label=&#39;Test Error&#39;)
</pre></div>
</div>
@@ -2818,9 +2833,9 @@ linear system as an equation would reduce this down to
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/4162706317.py:6: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/4162706317.py:6: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
cb = fig.colorbar(im)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/4162706317.py:7: UserWarning: FixedFormatter should only be used together with FixedLocator
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/4162706317.py:7: UserWarning: FixedFormatter should only be used together with FixedLocator
cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)
</pre></div>
</div>
@@ -2964,9 +2979,9 @@ with the form utilized in linear regression, viz.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/3777801602.py:6: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/3777801602.py:6: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
cb = fig.colorbar(im)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/3777801602.py:7: UserWarning: FixedFormatter should only be used together with FixedLocator
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/3777801602.py:7: UserWarning: FixedFormatter should only be used together with FixedLocator
cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)
</pre></div>
</div>
@@ -3006,9 +3021,9 @@ cost function is given by</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/438060758.py:9: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/438060758.py:9: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
cb = fig.colorbar(im)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/438060758.py:10: UserWarning: FixedFormatter should only be used together with FixedLocator
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/438060758.py:10: UserWarning: FixedFormatter should only be used together with FixedLocator
cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)
</pre></div>
</div>
@@ -3043,9 +3058,9 @@ cost function is given by</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/3544313922.py:8: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/3544313922.py:8: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
cb = fig.colorbar(im)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/3544313922.py:9: UserWarning: FixedFormatter should only be used together with FixedLocator
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/3544313922.py:9: UserWarning: FixedFormatter should only be used together with FixedLocator
cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)
</pre></div>
</div>
@@ -3098,43 +3113,43 @@ constant as opposed to ridge and OLS. We get a sparse solution with
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 0%| | 0/10 [00:00&lt;?, ?it/s]
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 0%| | 0/10 [00:00&lt;?, ?it/s]
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/linear_model/_coordinate_descent.py:647: ConvergenceWarning: Objective did not converge. You might want to increase the number of iterations, check the scale of the features or consider increasing regularisation. Duality gap: 3.924e+00, tolerance: 1.797e+00
model = cd_fast.enet_coordinate_descent(
10%|███████████████▌ | 1/10 [00:01&lt;00:09, 1.04s/it]
10%|██████████████ | 1/10 [00:00&lt;00:08, 1.04it/s]
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 20%|███████████████████████████████ | 2/10 [00:02&lt;00:08, 1.03s/it]
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 20%|████████████████████████████ | 2/10 [00:01&lt;00:07, 1.01it/s]
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 30%|██████████████████████████████████████████████▌ | 3/10 [00:02&lt;00:06, 1.16it/s]
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 30%|██████████████████████████████████████████ | 3/10 [00:02&lt;00:05, 1.24it/s]
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 40%|██████████████████████████████████████████████████████████████ | 4/10 [00:03&lt;00:04, 1.28it/s]
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 40%|█████████████████████████████████████████████████████████ | 4/10 [00:03&lt;00:04, 1.39it/s]
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 50%|█████████████████████████████████████████████████████████████████████████████▌ | 5/10 [00:03&lt;00:03, 1.42it/s]
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 50%|███████████████████████████████████████████████████████████████████████ | 5/10 [00:03&lt;00:03, 1.53it/s]
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 60%|█████████████████████████████████████████████████████████████████████████████████████████████ | 6/10 [00:04&lt;00:02, 1.47it/s]
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 60%|█████████████████████████████████████████████████████████████████████████████████████ | 6/10 [00:04&lt;00:02, 1.61it/s]
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 70%|████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 7/10 [00:05&lt;00:01, 1.55it/s]
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 70%|████████████████████████████████████████████████████████████████████████████████████████████████████ | 7/10 [00:04&lt;00:01, 1.65it/s]
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 80%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 8/10 [00:05&lt;00:01, 1.58it/s]
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 80%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 8/10 [00:05&lt;00:01, 1.66it/s]
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 90%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 9/10 [00:06&lt;00:00, 1.69it/s]
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 90%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 9/10 [00:05&lt;00:00, 1.67it/s]
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:06&lt;00:00, 1.70it/s]
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:06&lt;00:00, 1.59it/s]
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:06&lt;00:00, 1.46it/s]
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:06&lt;00:00, 1.49it/s]
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>
@@ -3281,9 +3296,9 @@ which polynomial fits the data best.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/3980313467.py:9: MatplotlibDeprecationWarning: Calling gca() with keyword arguments was deprecated in Matplotlib 3.4. Starting two minor releases later, gca() will take no keyword arguments. The gca() function should only be used to get the current axes, or if no axes exist, create new axes with default keyword arguments. To create a new axes with non-default arguments, use plt.axes() or plt.subplot().
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/3980313467.py:9: MatplotlibDeprecationWarning: Calling gca() with keyword arguments was deprecated in Matplotlib 3.4. Starting two minor releases later, gca() will take no keyword arguments. The gca() function should only be used to get the current axes, or if no axes exist, create new axes with default keyword arguments. To create a new axes with non-default arguments, use plt.axes() or plt.subplot().
ax = fig.gca(projection=&#39;3d&#39;)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8674/3980313467.py:37: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15405/3980313467.py:37: MatplotlibDeprecationWarning: Auto-removal of grids by pcolor() and pcolormesh() is deprecated since 3.5 and will be removed two minor releases later; please call grid(False) first.
fig.colorbar(surf, shrink=0.5, aspect=5)
</pre></div>
</div>
+16 -1
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
+16 -1
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
+178 -14
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -817,9 +832,9 @@ predicting the target features of query instances is as follows:</p>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2nd degree coefficients:
zero power: 0.9887034589972739
first power: -0.10518426027535331
second power: 0.0005840075008020406
zero power: 2.7023746599300384
first power: 0.03407676546787885
second power: 9.208257931205295e-06
</pre></div>
</div>
<img alt="_images/chapter6_1_1.png" src="_images/chapter6_1_1.png" />
@@ -1417,16 +1432,61 @@ humidity and weak and strong for wind.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span><span class="gt">---------------------------------------------------------------------------</span>
<span class="ne">FileNotFoundError</span><span class="g g-Whitespace"> </span>Traceback (most recent call last)
<span class="nn">Input In [6],</span> in <span class="ni">&lt;cell line: 37&gt;</span><span class="nt">()</span>
<span class="g g-Whitespace"> </span><span class="mi">34</span> <span class="k">def</span> <span class="nf">save_fig</span><span class="p">(</span><span class="n">fig_id</span><span class="p">):</span>
<span class="g g-Whitespace"> </span><span class="mi">35</span> <span class="n">plt</span><span class="o">.</span><span class="n">savefig</span><span class="p">(</span><span class="n">image_path</span><span class="p">(</span><span class="n">fig_id</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;.png&quot;</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="s1">&#39;png&#39;</span><span class="p">)</span>
<span class="ne">---&gt; </span><span class="mi">37</span> <span class="n">infile</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">data_path</span><span class="p">(</span><span class="s2">&quot;rideclass.csv&quot;</span><span class="p">),</span><span class="s1">&#39;r&#39;</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">39</span> <span class="c1"># Read the experimental data with Pandas</span>
<span class="g g-Whitespace"> </span><span class="mi">40</span> <span class="kn">from</span> <span class="nn">IPython.display</span> <span class="kn">import</span> <span class="n">display</span>
<span class="ne">FileNotFoundError</span>: [Errno 2] No such file or directory: &#39;DataFiles/rideclass.csv&#39;
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> (0, 0) 1.0
(0, 7) 1.0
(0, 9) 1.0
(0, 13) 1.0
(1, 3) 1.0
(1, 5) 1.0
(1, 8) 1.0
(1, 12) 1.0
(2, 3) 1.0
(2, 5) 1.0
(2, 8) 1.0
(2, 11) 1.0
(3, 1) 1.0
(3, 5) 1.0
(3, 8) 1.0
(3, 12) 1.0
(4, 2) 1.0
(4, 6) 1.0
(4, 8) 1.0
(4, 12) 1.0
(5, 2) 1.0
(5, 4) 1.0
(5, 10) 1.0
(5, 12) 1.0
(6, 2) 1.0
: :
(8, 12) 1.0
(9, 3) 1.0
(9, 4) 1.0
(9, 10) 1.0
(9, 12) 1.0
(10, 2) 1.0
(10, 6) 1.0
(10, 10) 1.0
(10, 12) 1.0
(11, 3) 1.0
(11, 6) 1.0
(11, 10) 1.0
(11, 11) 1.0
(12, 1) 1.0
(12, 6) 1.0
(12, 8) 1.0
(12, 11) 1.0
(13, 1) 1.0
(13, 5) 1.0
(13, 10) 1.0
(13, 12) 1.0
(14, 2) 1.0
(14, 6) 1.0
(14, 8) 1.0
(14, 11) 1.0
Train set accuracy with Decision Tree: 0.73
</pre></div>
</div>
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0
</pre></div>
</div>
</div>
@@ -1501,6 +1561,67 @@ algorithm ID3.</p>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>X1 &lt; 0.000 Gini=0.408
X1 &lt; 0.000 Gini=0.408
X1 &lt; 1.000 Gini=0.394
X1 &lt; 2.000 Gini=0.394
X1 &lt; 2.000 Gini=0.394
X1 &lt; 2.000 Gini=0.394
X1 &lt; 1.000 Gini=0.394
X1 &lt; 0.000 Gini=0.408
X1 &lt; 0.000 Gini=0.408
X1 &lt; 2.000 Gini=0.394
X1 &lt; 0.000 Gini=0.408
X1 &lt; 1.000 Gini=0.394
X1 &lt; 1.000 Gini=0.394
X1 &lt; 2.000 Gini=0.394
X2 &lt; 0.000 Gini=0.408
X2 &lt; 0.000 Gini=0.408
X2 &lt; 0.000 Gini=0.408
X2 &lt; 1.000 Gini=0.407
X2 &lt; 2.000 Gini=0.407
X2 &lt; 2.000 Gini=0.407
X2 &lt; 2.000 Gini=0.407
X2 &lt; 1.000 Gini=0.407
X2 &lt; 2.000 Gini=0.407
X2 &lt; 1.000 Gini=0.407
X2 &lt; 1.000 Gini=0.407
X2 &lt; 1.000 Gini=0.407
X2 &lt; 0.000 Gini=0.408
X2 &lt; 1.000 Gini=0.407
X3 &lt; 0.000 Gini=0.408
X3 &lt; 0.000 Gini=0.408
X3 &lt; 0.000 Gini=0.408
X3 &lt; 0.000 Gini=0.408
X3 &lt; 1.000 Gini=0.367
X3 &lt; 1.000 Gini=0.367
X3 &lt; 1.000 Gini=0.367
X3 &lt; 0.000 Gini=0.408
X3 &lt; 1.000 Gini=0.367
X3 &lt; 1.000 Gini=0.367
X3 &lt; 1.000 Gini=0.367
X3 &lt; 0.000 Gini=0.408
X3 &lt; 1.000 Gini=0.367
X3 &lt; 0.000 Gini=0.408
X4 &lt; 0.000 Gini=0.408
X4 &lt; 1.000 Gini=0.405
X4 &lt; 0.000 Gini=0.408
X4 &lt; 0.000 Gini=0.408
X4 &lt; 0.000 Gini=0.408
X4 &lt; 1.000 Gini=0.405
X4 &lt; 1.000 Gini=0.405
X4 &lt; 0.000 Gini=0.408
X4 &lt; 0.000 Gini=0.408
X4 &lt; 0.000 Gini=0.408
X4 &lt; 1.000 Gini=0.405
X4 &lt; 1.000 Gini=0.405
X4 &lt; 0.000 Gini=0.408
X4 &lt; 1.000 Gini=0.405
Split: [X3 &lt; 1.000]
</pre></div>
</div>
</div>
</div>
</div>
</div>
@@ -1573,6 +1694,32 @@ attributes at each step while growing the tree.</p>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>(426, 30)
(143, 30)
Test set accuracy with Logistic Regression: 0.94
Test set accuracy with SVM: 0.63
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Test set accuracy with Decision Trees: 0.90
Test set accuracy Logistic Regression with scaled data: 0.96
Test set accuracy SVM with scaled data: 0.96
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Test set accuracy with Decision Trees and scaled data: 0.89
</pre></div>
</div>
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/linear_model/_logistic.py:814: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.
Increase the number of iterations (max_iter) or scale the data as shown in:
https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression
n_iter_i = _check_optimize_result(
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="another-example-the-moons-again">
@@ -1646,6 +1793,9 @@ attributes at each step while growing the tree.</p>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/chapter6_42_0.png" src="_images/chapter6_42_0.png" />
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
@@ -1672,6 +1822,9 @@ attributes at each step while growing the tree.</p>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/chapter6_43_0.png" src="_images/chapter6_43_0.png" />
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
@@ -1694,6 +1847,11 @@ attributes at each step while growing the tree.</p>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>DecisionTreeRegressor(max_depth=2, random_state=42)
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
@@ -1738,6 +1896,9 @@ attributes at each step while growing the tree.</p>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/chapter6_46_0.png" src="_images/chapter6_46_0.png" />
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
@@ -1772,6 +1933,9 @@ attributes at each step while growing the tree.</p>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/chapter6_47_0.png" src="_images/chapter6_47_0.png" />
</div>
</div>
</div>
</div>
+16 -1
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
+85 -70
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -771,10 +786,10 @@ covariance matrix through the <strong>np.linalg.eig()</strong> function.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.11743722141098414
3.5452708224046345
[[ 1.27880068 3.85600299]
[ 3.85600299 12.61955303]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.06776308367941637
4.128711548693024
[[0.73875685 2.21831419]
[2.21831419 7.61137175]]
</pre></div>
</div>
</div>
@@ -814,10 +829,10 @@ a more brute force way. Here we scale the mean values for each column of the des
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.07178264457746288
1.6714298027296224
[[1. 0.59987612]
[0.59987612 1. ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.07327275854723572
1.4831993814276723
[[1. 0.63304358]
[0.63304358 1. ]]
</pre></div>
</div>
</div>
@@ -846,30 +861,30 @@ this matrix we easily see that it is a positive definite matrix.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[-1.05589275 -2.32845846]
[-1.43650129 -5.0020496 ]
[ 0.30685269 -0.25002882]
[ 1.1511986 3.95940231]
[-0.84931504 -2.84538739]
[-0.63401971 -1.90876452]
[ 0.39256409 1.76775004]
[ 1.07828283 3.52988562]
[-0.18753987 0.14133772]
[ 1.23437046 2.9363131 ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[-0.85835723 -3.41774143]
[ 1.61213079 4.0877162 ]
[ 0.45424136 1.21829201]
[-1.21728232 -4.60356071]
[-0.22144968 1.11721416]
[-2.47068328 -7.69488259]
[ 0.99346318 3.77312796]
[-0.18802913 -0.87085636]
[ 2.10355817 6.71082182]
[-0.20759186 -0.32013106]]
0 1
0 -1.055893 -2.328458
1 -1.436501 -5.002050
2 0.306853 -0.250029
3 1.151199 3.959402
4 -0.849315 -2.845387
5 -0.634020 -1.908765
6 0.392564 1.767750
7 1.078283 3.529886
8 -0.187540 0.141338
9 1.234370 2.936313
0 -0.858357 -3.417741
1 1.612131 4.087716
2 0.454241 1.218292
3 -1.217282 -4.603561
4 -0.221450 1.117214
5 -2.470683 -7.694883
6 0.993463 3.773128
7 -0.188029 -0.870856
8 2.103558 6.710822
9 -0.207592 -0.320131
0 1
0 1.000000 0.972745
1 0.972745 1.000000
0 1.000000 0.982252
1 0.982252 1.000000
</pre></div>
</div>
</div>
@@ -926,37 +941,37 @@ this matrix we easily see that it is a positive definite matrix.</p>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 0 1 2 3 4 5 6 7 \
0 0.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.0 0.093993 0.092566 0.095420 0.093559 0.091714 0.087802 0.086054
2 0.0 0.092566 0.091571 0.094206 0.092560 0.090919 0.086830 0.085223
3 0.0 0.095420 0.094206 0.103273 0.101409 0.099552 0.098879 0.097049
4 0.0 0.093559 0.092560 0.101409 0.099701 0.097995 0.097238 0.095528
5 0.0 0.091714 0.090919 0.099552 0.097995 0.096434 0.095596 0.094001
6 0.0 0.087802 0.086830 0.098879 0.097238 0.095596 0.097294 0.095624
7 0.0 0.086054 0.085223 0.097049 0.095528 0.094001 0.095624 0.094050
8 0.0 0.084365 0.083669 0.095273 0.093866 0.092450 0.093996 0.092516
9 0.0 0.082734 0.082168 0.093551 0.092254 0.090945 0.092412 0.091021
10 0.0 0.079914 0.079165 0.092493 0.091090 0.089678 0.092852 0.091372
11 0.0 0.078377 0.077731 0.090832 0.089523 0.088202 0.091293 0.089893
12 0.0 0.076897 0.076349 0.089227 0.088007 0.086773 0.089781 0.088456
13 0.0 0.075471 0.075017 0.087674 0.086540 0.085390 0.088314 0.087062
14 0.0 0.074096 0.073734 0.086172 0.085121 0.084051 0.086891 0.085709
1 0.0 0.093096 0.078035 0.092051 0.085918 0.079156 0.082615 0.078445
2 0.0 0.078035 0.067042 0.077110 0.072585 0.067659 0.069711 0.066564
3 0.0 0.092051 0.077110 0.096788 0.090301 0.083242 0.090313 0.085815
4 0.0 0.085918 0.072585 0.090301 0.084631 0.078425 0.084457 0.080543
5 0.0 0.079156 0.067659 0.083242 0.078425 0.073141 0.078154 0.074826
6 0.0 0.082615 0.069711 0.090313 0.084457 0.078154 0.086511 0.082368
7 0.0 0.078445 0.066564 0.085815 0.080543 0.074826 0.082368 0.078667
8 0.0 0.074411 0.063533 0.081472 0.076756 0.071602 0.078379 0.075092
9 0.0 0.070370 0.060524 0.077146 0.072971 0.068378 0.074425 0.071535
10 0.0 0.073425 0.062485 0.082390 0.077304 0.071857 0.080383 0.076734
11 0.0 0.070072 0.059925 0.078744 0.074128 0.069148 0.076993 0.073706
12 0.0 0.066944 0.057537 0.075342 0.071160 0.066614 0.073828 0.070876
13 0.0 0.064000 0.055294 0.072140 0.068364 0.064224 0.070852 0.068211
14 0.0 0.061186 0.053157 0.069084 0.065690 0.061938 0.068017 0.065666
8 9 10 11 12 13 14
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.084365 0.082734 0.079914 0.078377 0.076897 0.075471 0.074096
2 0.083669 0.082168 0.079165 0.077731 0.076349 0.075017 0.073734
3 0.095273 0.093551 0.092493 0.090832 0.089227 0.087674 0.086172
4 0.093866 0.092254 0.091090 0.089523 0.088007 0.086540 0.085121
5 0.092450 0.090945 0.089678 0.088202 0.086773 0.085390 0.084051
6 0.093996 0.092412 0.092852 0.091293 0.089781 0.088314 0.086891
7 0.092516 0.091021 0.091372 0.089893 0.088456 0.087062 0.085709
8 0.091072 0.089664 0.089925 0.088521 0.087159 0.085835 0.084550
9 0.089664 0.088339 0.088510 0.087180 0.085888 0.084633 0.083414
10 0.089925 0.088510 0.089979 0.088563 0.087184 0.085842 0.084536
11 0.088521 0.087180 0.088563 0.087212 0.085898 0.084617 0.083371
12 0.087159 0.085888 0.087184 0.085898 0.084644 0.083423 0.082234
13 0.085835 0.084633 0.085842 0.084617 0.083423 0.082260 0.081126
14 0.084550 0.083414 0.084536 0.083371 0.082234 0.081126 0.080045
1 0.074411 0.070370 0.073425 0.070072 0.066944 0.064000 0.061186
2 0.063533 0.060524 0.062485 0.059925 0.057537 0.055294 0.053157
3 0.081472 0.077146 0.082390 0.078744 0.075342 0.072140 0.069084
4 0.076756 0.072971 0.077304 0.074128 0.071160 0.068364 0.065690
5 0.071602 0.068378 0.071857 0.069148 0.066614 0.064224 0.061938
6 0.078379 0.074425 0.080383 0.076993 0.073828 0.070852 0.068017
7 0.075092 0.071535 0.076734 0.073706 0.070876 0.068211 0.065666
8 0.071908 0.068726 0.073223 0.070535 0.068019 0.065645 0.063374
9 0.068726 0.065909 0.069753 0.067388 0.065171 0.063076 0.061068
10 0.073223 0.069753 0.075692 0.072679 0.069865 0.067220 0.064702
11 0.070535 0.067388 0.072679 0.069968 0.067433 0.065045 0.062768
12 0.068019 0.065171 0.069865 0.067433 0.065155 0.063006 0.060952
13 0.065645 0.063076 0.067220 0.065045 0.063006 0.061078 0.059232
14 0.063374 0.061068 0.064702 0.062768 0.060952 0.059232 0.057582
</pre></div>
</div>
</div>
@@ -1145,10 +1160,10 @@ We can write our own code or simply use either the functionaly of <strong>numpy<
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 0 1
0 4.068439 2.030371
1 2.030371 2.006046
[[4.06843936 2.03037095]
[2.03037095 2.00604596]]
0 3.959839 1.973209
1 1.973209 1.963889
[[3.95983949 1.97320866]
[1.97320866 1.96388867]]
</pre></div>
</div>
</div>
@@ -1175,8 +1190,8 @@ Our own code here is not very elegant and asks for obvious improvements. It is t
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Centered covariance using own code
[[4.06843936 2.03037095]
[2.03037095 2.00604596]]
[[3.95983949 1.97320866]
[1.97320866 1.96388867]]
</pre></div>
</div>
<img alt="_images/chapter8_65_1.png" src="_images/chapter8_65_1.png" />
@@ -1236,16 +1251,16 @@ questions.</p>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Eigenvalues of Covariance matrix
5.314471861842257
0.7600134536106469
5.173087120899479
0.7506410412799234
First eigenvector
[0.8522997 0.52305374]
[0.85185762 0.52377342]
Second eigenvector
[-0.52305374 0.8522997 ]
[-0.52377342 0.85185762]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Eigenvector of largest eigenvalue
[0.8522997 0.52305374]
[-0.85185762 -0.52377342]
</pre></div>
</div>
</div>
+16 -1
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -1067,11 +1082,11 @@ which equals</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8738/483257001.py:18: MatplotlibDeprecationWarning: Calling gca() with keyword arguments was deprecated in Matplotlib 3.4. Starting two minor releases later, gca() will take no keyword arguments. The gca() function should only be used to get the current axes, or if no axes exist, create new axes with default keyword arguments. To create a new axes with non-default arguments, use plt.axes() or plt.subplot().
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15458/483257001.py:18: MatplotlibDeprecationWarning: Calling gca() with keyword arguments was deprecated in Matplotlib 3.4. Starting two minor releases later, gca() will take no keyword arguments. The gca() function should only be used to get the current axes, or if no axes exist, create new axes with default keyword arguments. To create a new axes with non-default arguments, use plt.axes() or plt.subplot().
ax = fig.gca(projection=&quot;3d&quot;)
</pre></div>
</div>
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;mpl_toolkits.mplot3d.art3d.Poly3DCollection at 0x12b1c2700&gt;
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;mpl_toolkits.mplot3d.art3d.Poly3DCollection at 0x12463a760&gt;
</pre></div>
</div>
<img alt="_images/chapteroptimization_61_2.png" src="_images/chapteroptimization_61_2.png" />
@@ -1129,7 +1144,7 @@ which equals</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&lt;matplotlib.lines.Line2D at 0x12e9e6280&gt;]
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&lt;matplotlib.lines.Line2D at 0x127461970&gt;]
</pre></div>
</div>
<img alt="_images/chapteroptimization_69_1.png" src="_images/chapteroptimization_69_1.png" />
@@ -1386,11 +1401,11 @@ when <span class="math notranslate nohighlight">\(||\nabla_\beta C(\beta_k) || \
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[0.33015882 4.55906894]
[[4.11836068]
[2.85949635]]
[[4.11836068]
[2.85949635]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[0.27151245 4.21908927]
[[4.2144122 ]
[2.86528733]]
[[4.2144122 ]
[2.86528733]]
</pre></div>
</div>
<img alt="_images/chapteroptimization_123_1.png" src="_images/chapteroptimization_123_1.png" />
@@ -1419,9 +1434,9 @@ when <span class="math notranslate nohighlight">\(||\nabla_\beta C(\beta_k) || \
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[4.13451895]
[2.8383548 ]]
[4.19783086] [2.93535577]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[4.08838465]
[3.00383795]]
[4.10031273] [3.04626011]
</pre></div>
</div>
</div>
@@ -1492,10 +1507,10 @@ C_{\text{ridge}}(\beta) = \frac{1}{n}||X\beta -\mathbf{y}||^2 + \lambda ||\beta|
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[4.12575322]
[2.87918262]]
[[4.08876865]
[2.90510842]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[3.81243166]
[3.07844345]]
[[3.80101942]
[3.08513055]]
</pre></div>
</div>
<img alt="_images/chapteroptimization_132_1.png" src="_images/chapteroptimization_132_1.png" />
@@ -1745,15 +1760,15 @@ function.</p>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[3.78515112]
[3.19029687]]
Eigenvalues of Hessian Matrix:[0.30739146 4.15768662]
[[3.56486674]
[3.29918458]]
Eigenvalues of Hessian Matrix:[0.2756303 4.36170438]
theta from own gd
[[3.78515112]
[3.19029687]]
[[3.56486674]
[3.29918458]]
theta from own sdg
[[3.81425332]
[3.25285802]]
[[3.52208436]
[3.31774469]]
</pre></div>
</div>
<img alt="_images/chapteroptimization_148_1.png" src="_images/chapteroptimization_148_1.png" />
+16 -1
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -351,6 +351,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -365,7 +375,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
+128 -113
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -824,15 +839,15 @@ regression.</p>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[3.69887085]
[3.34977681]]
Eigenvalues of Hessian Matrix:[0.25923926 4.67193435]
[[4.16422434]
[2.90414392]]
Eigenvalues of Hessian Matrix:[0.29405153 4.56291744]
theta from own gd
[[3.69887085]
[3.34977681]]
[[4.16422434]
[2.90414392]]
theta from own sdg
[[3.63685221]
[3.37369014]]
[[4.13747168]
[2.89670222]]
</pre></div>
</div>
<img alt="_images/exercisesweek41_5_1.png" src="_images/exercisesweek41_5_1.png" />
@@ -954,14 +969,14 @@ first example shows results with ordinary leats squares.</p>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[3.64342603]
[3.30485583]]
Eigenvalues of Hessian Matrix:[0.29030069 4.6608358 ]
[[3.6398684 ]
[3.27790702]]
Eigenvalues of Hessian Matrix:[0.35845332 4.35403494]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own gd
[[3.64342603]
[3.30485583]]
[[3.6398684 ]
[3.27790702]]
</pre></div>
</div>
<img alt="_images/exercisesweek41_16_2.png" src="_images/exercisesweek41_16_2.png" />
@@ -1032,73 +1047,73 @@ Eigenvalues of Hessian Matrix:[0.29030069 4.6608358 ]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[4.]
[3.]]
Eigenvalues of Hessian Matrix:[0.27335131 4.46000649]
0 [-13.27099835] [-15.86570776]
1 [0.01163425] [-0.00974702]
2 [0.01092119] [-0.00914964]
3 [0.01025184] [-0.00858886]
4 [0.00962351] [-0.00806245]
5 [0.00903369] [-0.00756831]
6 [0.00848002] [-0.00710445]
7 [0.00796028] [-0.00666902]
8 [0.0074724] [-0.00626028]
9 [0.00701442] [-0.00587659]
10 [0.00658451] [-0.00551642]
11 [0.00618095] [-0.00517832]
12 [0.00580212] [-0.00486095]
13 [0.00544651] [-0.00456302]
14 [0.0051127] [-0.00428336]
15 [0.00479935] [-0.00402083]
16 [0.0045052] [-0.0037744]
17 [0.00422908] [-0.00354307]
18 [0.00396988] [-0.00332591]
19 [0.00372657] [-0.00312207]
20 [0.00349817] [-0.00293072]
21 [0.00328377] [-0.0027511]
22 [0.00308251] [-0.00258249]
23 [0.00289358] [-0.00242421]
24 [0.00271624] [-0.00227563]
25 [0.00254976] [-0.00213616]
26 [0.00239349] [-0.00200523]
27 [0.00224679] [-0.00188233]
28 [0.00210909] [-0.00176697]
29 [0.00197982] [-0.00165867]
Eigenvalues of Hessian Matrix:[0.3431178 4.16725475]
0 [-14.28194794] [-15.81268342]
1 [-0.23712617] [0.2073339]
2 [-0.21760199] [0.19026272]
3 [-0.19968537] [0.17459712]
4 [-0.18324395] [0.16022138]
5 [-0.16815626] [0.14702929]
6 [-0.15431083] [0.13492339]
7 [-0.1416054] [0.12381425]
8 [-0.12994608] [0.1136198]
9 [-0.11924676] [0.10426473]
10 [-0.10942838] [0.09567992]
11 [-0.10041841] [0.08780195]
12 [-0.0921503] [0.08057264]
13 [-0.08456295] [0.07393855]
14 [-0.07760032] [0.0678507]
15 [-0.07121097] [0.0622641]
16 [-0.0653477] [0.05713748]
17 [-0.05996719] [0.05243298]
18 [-0.05502969] [0.04811582]
19 [-0.05049873] [0.04415412]
20 [-0.04634083] [0.04051862]
21 [-0.04252528] [0.03718245]
22 [-0.03902389] [0.03412098]
23 [-0.0358108] [0.03131157]
24 [-0.03286226] [0.02873348]
25 [-0.03015649] [0.02636766]
26 [-0.0276735] [0.02419664]
27 [-0.02539496] [0.02220437]
28 [-0.02330402] [0.02037613]
29 [-0.02138525] [0.01869843]
theta from own gd
[[4.00679887]
[2.994304 ]]
0 [0.00185848] [-0.00155701]
1 [0.00174457] [-0.00146158]
2 [0.00160348] [-0.00134337]
3 [0.00146287] [-0.00122558]
4 [0.00133103] [-0.00111512]
5 [0.0012099] [-0.00101364]
6 [0.00109941] [-0.00092107]
7 [0.00099888] [-0.00083685]
8 [0.0009075] [-0.00076029]
9 [0.00082447] [-0.00069073]
10 [0.00074902] [-0.00062752]
11 [0.00068048] [-0.0005701]
12 [0.00061822] [-0.00051793]
13 [0.00056165] [-0.00047054]
14 [0.00051025] [-0.00042748]
15 [0.00046356] [-0.00038836]
16 [0.00042114] [-0.00035283]
17 [0.0003826] [-0.00032054]
18 [0.00034759] [-0.00029121]
19 [0.00031579] [-0.00026456]
20 [0.00028689] [-0.00024035]
21 [0.00026064] [-0.00021836]
22 [0.00023679] [-0.00019838]
23 [0.00021512] [-0.00018022]
24 [0.00019544] [-0.00016373]
25 [0.00017755] [-0.00014875]
26 [0.0001613] [-0.00013514]
27 [0.00014654] [-0.00012277]
28 [0.00013313] [-0.00011154]
29 [0.00012095] [-0.00010133]
[[3.94280548]
[3.05000867]]
0 [-0.01962446] [0.01715886]
1 [-0.01800865] [0.01574606]
2 [-0.01604113] [0.01402574]
3 [-0.0141301] [0.01235481]
4 [-0.01239337] [0.01083628]
5 [-0.01085192] [0.0094885]
6 [-0.00949598] [0.00830291]
7 [-0.00830733] [0.0072636]
8 [-0.00726673] [0.00635375]
9 [-0.00635624] [0.00555765]
10 [-0.00555974] [0.00486122]
11 [-0.00486302] [0.00425203]
12 [-0.0042536] [0.00371918]
13 [-0.00372054] [0.0032531]
14 [-0.00325429] [0.00284542]
15 [-0.00284647] [0.00248884]
16 [-0.00248975] [0.00217694]
17 [-0.00217774] [0.00190413]
18 [-0.00190483] [0.00166551]
19 [-0.00166612] [0.00145679]
20 [-0.00145732] [0.00127423]
21 [-0.00127469] [0.00111454]
22 [-0.00111495] [0.00097487]
23 [-0.00097522] [0.0008527]
24 [-0.00085301] [0.00074584]
25 [-0.00074611] [0.00065237]
26 [-0.00065261] [0.00057062]
27 [-0.00057083] [0.00049911]
28 [-0.00049929] [0.00043656]
29 [-0.00043672] [0.00038185]
theta from own gd wth momentum
[[4.00040199]
[2.99966322]]
[[3.9988867 ]
[3.00097342]]
</pre></div>
</div>
</div>
@@ -1151,17 +1166,17 @@ theta from own gd wth momentum
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[3.71369789]
[3.2314999 ]]
Eigenvalues of Hessian Matrix:[0.30237154 4.4642383 ]
0 [-17.75091492] [-21.33108943]
1 [-4.60742555e-15] [5.64228618e-16]
2 [-5.34294831e-16] [-5.79981535e-16]
3 [-5.34294831e-16] [-5.79981535e-16]
4 [-5.34294831e-16] [-5.79981535e-16]
[[3.87043345]
[3.22475203]]
Eigenvalues of Hessian Matrix:[0.38540656 3.68548206]
0 [-12.40634991] [-11.15578306]
1 [-5.99520433e-15] [-8.10731958e-15]
2 [-2.87964097e-16] [-5.20946226e-16]
3 [4.12864187e-16] [4.15804451e-16]
4 [4.12864187e-16] [4.15804451e-16]
beta from own Newton code
[[3.71369789]
[3.2314999 ]]
[[3.87043345]
[3.22475203]]
</pre></div>
</div>
</div>
@@ -1250,20 +1265,20 @@ beta from own Newton code
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[4.39917327]
[2.69542733]]
Eigenvalues of Hessian Matrix:[0.29765192 4.0375827 ]
[[3.98225665]
[3.11495144]]
Eigenvalues of Hessian Matrix:[0.29378469 4.27347181]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own gd
[[4.39917327]
[2.69542733]]
[[3.98225665]
[3.11495144]]
</pre></div>
</div>
<img alt="_images/exercisesweek41_22_2.png" src="_images/exercisesweek41_22_2.png" />
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own sdg
[[4.32234998]
[2.64530585]]
[[3.89184354]
[3.13010854]]
</pre></div>
</div>
</div>
@@ -1345,17 +1360,17 @@ Eigenvalues of Hessian Matrix:[0.29765192 4.0375827 ]
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[3.7635689 ]
[3.10080981]]
Eigenvalues of Hessian Matrix:[0.31633433 3.9824638 ]
[[4.11385399]
[2.90239437]]
Eigenvalues of Hessian Matrix:[0.2870363 4.27221341]
theta from own gd
[[3.76366462]
[3.1007216 ]]
[[4.11265847]
[2.90343239]]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own sdg with momentum
[[3.75707243]
[3.12422141]]
[[4.07560398]
[2.82894312]]
</pre></div>
</div>
</div>
@@ -1430,9 +1445,9 @@ theta from own gd
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own AdaGrad
[[1.99999956]
[3.00000215]
[3.99999797]]
[[2.00036163]
[2.99784051]
[4.00208264]]
</pre></div>
</div>
</div>
@@ -1514,9 +1529,9 @@ theta from own gd
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own RMSprop
[[1.99907985]
[2.99897733]
[3.99754609]]
[[1.99976935]
[2.99966842]
[4.00437973]]
</pre></div>
</div>
</div>
@@ -1602,9 +1617,9 @@ theta from own gd
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own ADAM
[[2.00003617]
[2.99986253]
[4.00012569]]
[[1.99998899]
[3.00009903]
[3.99988697]]
</pre></div>
</div>
</div>
@@ -1677,7 +1692,7 @@ It provides composable transformations of Python+NumPy programs: differentiate,
return asarray(x, dtype=self.dtype)
</pre></div>
</div>
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&lt;matplotlib.lines.Line2D at 0x11cb23a60&gt;]
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&lt;matplotlib.lines.Line2D at 0x126f4fa00&gt;]
</pre></div>
</div>
<img alt="_images/exercisesweek41_39_2.png" src="_images/exercisesweek41_39_2.png" />
@@ -1716,7 +1731,7 @@ It provides composable transformations of Python+NumPy programs: differentiate,
return asarray(x, dtype=self.dtype)
</pre></div>
</div>
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.collections.PathCollection at 0x11cb23fd0&gt;
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.collections.PathCollection at 0x126f922b0&gt;
</pre></div>
</div>
<img alt="_images/exercisesweek41_41_2.png" src="_images/exercisesweek41_41_2.png" />
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -358,6 +358,11 @@ const thebe_selector_output = ".output, .cell_output"
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -957,8 +962,9 @@ Accuracy score on data set: 0.5
Learning rate = 0.0001
Lambda = 0.001
Accuracy score on data set: 0.5
Learning rate = 0.0001
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Learning rate = 0.0001
Lambda = 0.01
Accuracy score on data set: 0.5
@@ -1137,7 +1143,7 @@ Accuracy score on data set: 0.5
warnings.warn(
</pre></div>
</div>
<img alt="_images/exercisesweek43_26_2.png" src="_images/exercisesweek43_26_2.png" />
<img alt="_images/exercisesweek43_26_3.png" src="_images/exercisesweek43_26_3.png" />
</div>
</div>
</div>
@@ -5444,9 +5450,6 @@ case.</p>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Adam: Eta=0.001, Lambda=0
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> [----------------------------------------] 0.000% | train_error: 12.9 | train_acc: 0.376 | val_error: 12.6 | val_acc: 0.392
</pre></div>
</div>
@@ -8483,9 +8486,6 @@ case.</p>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Adam: Eta=0.0001, Lambda=0
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> [----------------------------------------] 0.000% | train_error: 11.3 | train_acc: 0.453 | val_error: 10.4 | val_acc: 0.497
</pre></div>
</div>
@@ -14567,8 +14567,9 @@ digits between the range of 0 to 9.</p>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Adam: Eta=0.1, Lambda=0
[----------------------------------------] 0.000% | train_error: 10.4 | train_acc: 0.500
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> [----------------------------------------] 0.000% | train_error: 10.4 | train_acc: 0.500
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> [----------------------------------------] 0.1000% | train_error: 10.4 | train_acc: 0.500
@@ -354,6 +354,11 @@ const thebe_selector_output = ".output, .cell_output"
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
+5
View File
@@ -355,6 +355,11 @@ const thebe_selector_output = ".output, .cell_output"
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
+45 -30
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -673,8 +688,8 @@ matrices and vectors.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[ 0.44079937 -0.14839786 -1.00862798 -0.22996417 0.53459992 0.28570701
-0.40043644 0.43989497 -0.27463692 -0.17644873]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[-0.35325013 1.40714201 -1.34943652 0.57794243 -0.3501046 -0.08502551
0.22939767 0.37351692 0.87604059 -0.16082975]
</pre></div>
</div>
</div>
@@ -895,26 +910,26 @@ as (recall that we user lowercase letters for vectors and uppercase letters for
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[0.51727541 0.09312344 0.68284332 0.10399743 0.11110246 0.17604689
0.83716603 0.72598009 0.89142728 0.54640368]
[0.33656494 0.55847112 0.87450434 0.13621148 0.38488879 0.68655761
0.74147751 0.2544422 0.33708747 0.6848187 ]
[0.54213329 0.22197349 0.8702764 0.36674564 0.59816099 0.3225819
0.18856622 0.88595314 0.46132345 0.55685628]
[0.88866133 0.65822169 0.05062537 0.20513942 0.41671085 0.48333258
0.12786653 0.31532451 0.56548318 0.65766777]
[0.55206229 0.11704038 0.2856881 0.26961519 0.13371503 0.26805987
0.34460089 0.09215672 0.53367133 0.34362409]
[0.34642944 0.54617756 0.22752605 0.86192438 0.49901588 0.98157799
0.69802962 0.6513444 0.88050263 0.66725024]
[0.88657125 0.3591093 0.14600426 0.66667985 0.95921115 0.09607524
0.0470705 0.42777999 0.65318467 0.59602968]
[0.37187359 0.6945612 0.7840642 0.78347558 0.60307141 0.95682858
0.99534399 0.1859082 0.4281152 0.11232098]
[0.8459616 0.64874236 0.39148625 0.284499 0.35322418 0.37391132
0.39837199 0.47950427 0.44298022 0.31921368]
[0.89881513 0.0062825 0.19942021 0.86850693 0.90715001 0.3426926
0.98597638 0.71365128 0.79367372 0.86629645]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[0.79473273 0.85144525 0.58083888 0.95534385 0.74978227 0.09375511
0.3762603 0.55342366 0.69948916 0.52180757]
[0.41125816 0.53375204 0.78459969 0.63860117 0.68632877 0.3135197
0.64378812 0.1228485 0.23374497 0.16365729]
[0.06106228 0.41042542 0.72277345 0.87499269 0.25312591 0.97624609
0.30902533 0.35567049 0.01001307 0.60893494]
[0.68303739 0.09712817 0.45884458 0.56841764 0.80038919 0.6266335
0.15169011 0.58487995 0.78177874 0.84856859]
[0.35193678 0.09087594 0.88887574 0.11148997 0.77155539 0.02374036
0.0382287 0.46294168 0.72359843 0.78427913]
[0.97784379 0.14479759 0.46138883 0.85159661 0.18534538 0.96863656
0.84143964 0.01707943 0.61695829 0.41936371]
[0.00693764 0.08822806 0.64624281 0.59033885 0.00622235 0.56069111
0.11141718 0.8736902 0.22015945 0.70367282]
[0.55011282 0.56603693 0.98849276 0.79256181 0.97555188 0.731344
0.50153896 0.88292369 0.05203331 0.10856388]
[0.73582138 0.28478815 0.03418359 0.54608238 0.33959063 0.34619711
0.93037027 0.31960205 0.97702512 0.13990198]
[0.48668089 0.23908241 0.22812848 0.56640341 0.8840647 0.56933711
0.46660343 0.91471524 0.52960552 0.85067652]]
</pre></div>
</div>
</div>
@@ -974,13 +989,13 @@ covariance matrix through the <strong>np.linalg.eig()</strong> function.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.10095106250934528
3.73293228266057
-0.589971818845805
[[ 1.44967228 4.20536556 4.14179769]
[ 4.20536556 13.10814421 12.2161908 ]
[ 4.14179769 12.2161908 17.03056169]]
[28.710746 0.0846527 2.79297948]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.13443663368799186
4.256841168348422
0.26403986587386163
[[0.69773572 2.0163462 1.40881429]
[2.0163462 6.97266041 4.00255459]
[1.40881429 4.00255459 5.66675932]]
[10.95984465 0.0898612 2.2874496 ]
</pre></div>
</div>
</div>
Binary file not shown.
+22 -7
View File
@@ -55,8 +55,8 @@ const thebe_selector_output = ".output, .cell_output"
<script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Project 2 on Machine Learning, deadline November 13 (Midnight)" href="project2.html" />
<link rel="prev" title="Week 45, Recurrent Neural Networks" href="week45.html" />
<link rel="next" title="Project 2 on Machine Learning, deadline November 17 (Midnight)" href="project2.html" />
<link rel="prev" title="Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course" href="week47.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="None">
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -720,7 +735,7 @@ which polynomial fits the data best.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8779/39730396.py:11: MatplotlibDeprecationWarning: Calling gca() with keyword arguments was deprecated in Matplotlib 3.4. Starting two minor releases later, gca() will take no keyword arguments. The gca() function should only be used to get the current axes, or if no axes exist, create new axes with default keyword arguments. To create a new axes with non-default arguments, use plt.axes() or plt.subplot().
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15499/39730396.py:11: MatplotlibDeprecationWarning: Calling gca() with keyword arguments was deprecated in Matplotlib 3.4. Starting two minor releases later, gca() will take no keyword arguments. The gca() function should only be used to get the current axes, or if no axes exist, create new axes with default keyword arguments. To create a new axes with non-default arguments, use plt.axes() or plt.subplot().
ax = fig.gca(projection=&#39;3d&#39;)
</pre></div>
</div>
@@ -1079,17 +1094,17 @@ of code developers and contributors keeps increasing.</p>
<!-- Previous / next buttons -->
<div class='prev-next-area'>
<a class='left-prev' id="prev-link" href="week45.html" title="previous page">
<a class='left-prev' id="prev-link" href="week47.html" title="previous page">
<i class="fas fa-angle-left"></i>
<div class="prev-next-info">
<p class="prev-next-subtitle">previous</p>
<p class="prev-next-title">Week 45, Recurrent Neural Networks</p>
<p class="prev-next-title">Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course</p>
</div>
</a>
<a class='right-next' id="next-link" href="project2.html" title="next page">
<div class="prev-next-info">
<p class="prev-next-subtitle">next</p>
<p class="prev-next-title">Project 2 on Machine Learning, deadline November 13 (Midnight)</p>
<p class="prev-next-title">Project 2 on Machine Learning, deadline November 17 (Midnight)</p>
</div>
<i class="fas fa-angle-right"></i>
</a>
@@ -55,6 +55,7 @@ const thebe_selector_output = ".output, .cell_output"
<script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Project 3 on Machine Learning, deadline December 18 (midnight), 2023" href="project3.html" />
<link rel="prev" title="Project 1 on Machine Learning, deadline October 9 (midnight), 2023" href="project1.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="None">
@@ -357,6 +358,11 @@ const thebe_selector_output = ".output, .cell_output"
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -374,6 +380,11 @@ const thebe_selector_output = ".output, .cell_output"
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
</div>
@@ -807,6 +818,13 @@ we encourage you to collaborate. Optimal working groups consist of
<p class="prev-next-title">Project 1 on Machine Learning, deadline October 9 (midnight), 2023</p>
</div>
</a>
<a class='right-next' id="next-link" href="project3.html" title="next page">
<div class="prev-next-info">
<p class="prev-next-subtitle">next</p>
<p class="prev-next-title">Project 3 on Machine Learning, deadline December 18 (midnight), 2023</p>
</div>
<i class="fas fa-angle-right"></i>
</a>
</div>
</div>
@@ -1,3 +1,14 @@
Traceback (most recent call last):
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 730, in _async_poll_for_reply
msg = await ensure_async(self.kc.shell_channel.get_msg(timeout=new_timeout))
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 96, in ensure_async
result = await obj
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_client/channels.py", line 230, in get_msg
raise Empty
_queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
executenb(
@@ -11,20 +22,18 @@ Traceback (most recent call last):
return future.result()
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
await self.async_execute_cell(
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
await self._check_raise_for_error(cell, cell_index, exec_reply)
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
------------------
conda create -n tf tensorflow
conda activate tf
------------------
 Input In [12]
 conda create -n tf tensorflow
 ^
SyntaxError: invalid syntax
SyntaxError: invalid syntax (2259440937.py, line 1)
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 949, in async_execute_cell
exec_reply = await self.task_poll_for_reply
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 754, in _async_poll_for_reply
await self._async_handle_timeout(timeout, cell)
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 801, in _async_handle_timeout
raise CellTimeoutError.error_from_timeout_and_cell(
nbclient.exceptions.CellTimeoutError: A cell timed out while it was being executed, after 30 seconds.
The message was: Cell execution timed out.
Here is a preview of the cell contents:
-------------------
['eta_vals = np.logspace(-5, 1, 7)', 'lmbd_vals = np.logspace(-5, 1, 7)', '# store the models for later use', 'DNN_numpy = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)', '']
...
[' ', ' print("Learning rate = ", eta)', ' print("Lambda = ", lmbd)', ' print("Accuracy score on test set: ", accuracy_score(Y_test, test_predict))', ' print()']
-------------------
+16 -1
View File
@@ -351,6 +351,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -365,7 +375,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
+5
View File
@@ -360,6 +360,11 @@ const thebe_selector_output = ".output, .cell_output"
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
File diff suppressed because one or more lines are too long
+47 -32
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -1045,27 +1060,27 @@ uncorrelated.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>2.860303069807892
[[24.75576092 22.38035637 6.45399416 23.02131025 23.17927079 13.79482449
14.58098325 8.09978307 10.32858131 7.04416475]
[22.38035637 20.23288045 5.83471014 20.81233249 20.95513615 12.47116132
13.18188532 7.32257967 9.33751667 6.36825174]
[ 6.45399416 5.83471014 1.68259989 6.00181115 6.04299253 3.59640396
3.80136087 2.11166818 2.69273094 1.83646135]
[23.02131025 20.81233249 6.00181115 21.40837954 21.55527296 12.8283245
13.55940301 7.53229196 9.60493501 6.55063291]
[23.17927079 20.95513615 6.04299253 21.55527296 21.7031743 12.91634595
13.65244075 7.58397472 9.67083919 6.59558002]
[13.79482449 12.47116132 3.59640396 12.8283245 12.91634595 7.6869858
8.12506251 4.51349834 5.75546705 3.92526882]
[14.58098325 13.18188532 3.80136087 13.55940301 13.65244075 8.12506251
8.58810494 4.7707199 6.08346766 4.14896753]
[ 8.09978307 7.32257967 2.11166818 7.53229196 7.58397472 4.51349834
4.7707199 2.65015024 3.37938584 2.3047648 ]
[10.32858131 9.33751667 2.69273094 9.60493501 9.67083919 5.75546705
6.08346766 3.37938584 4.30928349 2.9389615 ]
[ 7.04416475 6.36825174 1.83646135 6.55063291 6.59558002 3.92526882
4.14896753 2.3047648 2.9389615 2.00439232]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>3.899444949551402
[[10.50764587 14.915888 4.01878557 10.96438655 3.9173859 11.73359971
9.21793896 -2.24485338 7.74529434 12.25404247]
[14.915888 21.17350714 5.70477499 15.56424378 5.56083543 16.6561627
13.08511411 -3.18663019 10.99465516 17.39494529]
[ 4.01878557 5.70477499 1.53703671 4.19347197 1.49825509 4.48766753
3.52552042 -0.85857332 2.96228836 4.68671762]
[10.96438655 15.56424378 4.19347197 11.4409806 4.08766472 12.2436295
9.61861937 -2.34243146 8.08196262 12.78669458]
[ 3.9173859 5.56083543 1.49825509 4.08766472 1.46045199 4.37443731
3.43656654 -0.83691029 2.88754562 4.56846508]
[11.73359971 16.6561627 4.48766753 12.2436295 4.37443731 13.10258872
10.29341942 -2.50676615 8.64895758 13.68375286]
[ 9.21793896 13.08511411 3.52552042 9.61861937 3.43656654 10.29341942
8.0865305 -1.96932041 6.79463805 10.7499831 ]
[-2.24485338 -3.18663019 -0.85857332 -2.34243146 -0.83691029 -2.50676615
-1.96932041 0.47959046 -1.65470462 -2.61795354]
[ 7.74529434 10.99465516 2.96228836 8.08196262 2.88754562 8.64895758
6.79463805 -1.65470462 5.70913648 9.03258131]
[12.25404247 17.39494529 4.68671762 12.78669458 4.56846508 13.68375286
10.7499831 -2.61795354 9.03258131 14.29069448]]
</pre></div>
</div>
</div>
@@ -1333,15 +1348,15 @@ more practically oriented methods like the blocking technique.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.07023654656164897
4.208190393562401
-0.023810076900619058
1.0331134070762626 10.076560707521647 14.512204707520711
3.055706923889776 3.0768224464930487 8.922010623244745
[[ 1.03311341 3.05570692 3.07682245]
[ 3.05570692 10.07656071 8.92201062]
[ 3.07682245 8.92201062 14.51220471]]
[22.35796655 0.08015655 3.18375572]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.027931820179105067
3.8948621306998614
0.09739722453284225
1.281127658556346 13.800407897050107 32.990171109310765
4.053326337300775 5.0047469652158 15.94611730275583
[[ 1.28112766 4.05332634 5.00474697]
[ 4.05332634 13.8004079 15.9461173 ]
[ 5.00474697 15.9461173 32.99017111]]
[42.9738062 0.07783419 5.02006627]
</pre></div>
</div>
</div>
@@ -1671,7 +1686,7 @@ assumption for approximating <span class="math notranslate nohighlight">\(\sigma
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.006719367598355617 1.0020717457079393
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.005332694146660865 0.995998835818754
</pre></div>
</div>
<img alt="_images/statistics_188_1.png" src="_images/statistics_188_1.png" />
+16 -1
View File
@@ -351,6 +351,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -365,7 +375,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
+16 -1
View File
@@ -351,6 +351,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -365,7 +375,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
+46 -31
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -1835,8 +1850,8 @@ developed in the 1970s, namely EISPACK and LINPACK. We describe them shortly he
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[ 1.303107 1.38160211 0.19790229 1.36099915 -2.08992459 -0.86156954
2.9012691 -0.18410452 -1.06886644 0.01011906]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[ 1.99876055 1.26944417 1.08159052 -0.19114964 -0.60407268 0.65062476
1.21910072 1.34814162 -0.23692158 0.52823177]
</pre></div>
</div>
</div>
@@ -2061,26 +2076,26 @@ lowercase letters for vectors and uppercase letters for matrices)</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[0.27204759 0.8509716 0.98844754 0.6522099 0.81868633 0.74934715
0.53632379 0.2257879 0.88228452 0.33213799]
[0.82550815 0.97032289 0.54852248 0.45000312 0.45227801 0.44437409
0.66608227 0.37871763 0.10320791 0.55812916]
[0.10455569 0.18044829 0.92543216 0.81873184 0.05924492 0.00620039
0.03106988 0.61631038 0.56830193 0.46580623]
[0.97991527 0.62460522 0.51635486 0.08776426 0.80418542 0.94035843
0.63870745 0.64347512 0.03019138 0.45811552]
[0.82050873 0.4757488 0.95696156 0.2970942 0.56217428 0.16487517
0.2522939 0.44886896 0.66951925 0.56135704]
[0.82178144 0.58639705 0.0944958 0.69585594 0.08191117 0.42487977
0.29009852 0.08368077 0.6691852 0.48444949]
[0.55790428 0.58519863 0.35795044 0.65925306 0.53506617 0.60090208
0.22830615 0.30506642 0.79142002 0.68029581]
[0.12867125 0.34373214 0.89558707 0.05629549 0.54342461 0.10888134
0.27485633 0.97326759 0.10477501 0.80621648]
[0.56756375 0.18276764 0.83519995 0.23044077 0.43559429 0.0934955
0.5712104 0.92054587 0.10120164 0.69666941]
[0.17456211 0.42323635 0.03955811 0.54969188 0.5793788 0.49423098
0.78834469 0.80312429 0.94756925 0.83793923]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[0.07178725 0.08695635 0.89462507 0.75563845 0.30666456 0.0295741
0.79835897 0.68599651 0.09215268 0.92098926]
[0.66013062 0.05466359 0.48935121 0.8554451 0.40293251 0.1690242
0.62412322 0.13571683 0.5735888 0.22524684]
[0.77325382 0.25018275 0.77615813 0.91438463 0.79009118 0.67199316
0.35858674 0.54205622 0.95558887 0.35799174]
[0.42109456 0.19802685 0.8478361 0.20265997 0.78724182 0.91581662
0.92419995 0.65805069 0.64192269 0.23499198]
[0.18302441 0.97198474 0.70796162 0.06124676 0.14967691 0.83091912
0.9697031 0.96649164 0.48613114 0.79595791]
[0.15400455 0.92643252 0.75309058 0.24605947 0.50661281 0.47991139
0.54220589 0.10645534 0.55295871 0.71213744]
[0.85824275 0.00915265 0.88395664 0.86901486 0.00286269 0.47340594
0.5703663 0.13201296 0.99246148 0.75848064]
[0.94578579 0.81175543 0.74233133 0.80589357 0.64101039 0.02053512
0.98904619 0.19457423 0.98598055 0.19429581]
[0.27377363 0.89454132 0.31780875 0.11925465 0.02636112 0.23754723
0.20580025 0.53632918 0.39822715 0.69355844]
[0.15449587 0.45133278 0.03230546 0.07962234 0.17757752 0.07225884
0.99267755 0.87211615 0.36537059 0.28596284]]
</pre></div>
</div>
</div>
@@ -2135,13 +2150,13 @@ covariance matrix through the <strong>np.linalg.eig()</strong> function.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.14482255345953607
3.467427755242117
-0.7005538702846336
[[ 0.82032378 2.41772265 2.45808919]
[ 2.41772265 8.23849741 7.23077531]
[ 2.45808919 7.23077531 13.06343533]]
[18.91591367 0.08817972 3.11816312]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.02192091870116783
3.774553354452195
-0.536915581616642
[[ 0.97075378 2.86906683 4.23997187]
[ 2.86906683 9.35109296 12.76954723]
[ 4.23997187 12.76954723 33.47704686]]
[39.63504283 0.07780377 4.08604699]
</pre></div>
</div>
</div>
@@ -2364,7 +2379,7 @@ Name: Aragorn, dtype: object
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_8790/1326197715.py:6: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_15510/1326197715.py:6: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
data_pandas=data_pandas.append(pd.DataFrame(new_hobbit, index=[&#39;Pippin&#39;]))
</pre></div>
</div>
+40 -33
View File
@@ -353,6 +353,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 45, Recurrent Neural Networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week46.html">
Week 46: Decision Trees, Ensemble methods and Random Forests
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week47.html">
Week 47: From Decision Trees to Ensemble Methods, Random Forests and Boosting Methods and Summary of Course
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -367,7 +377,12 @@ const thebe_selector_output = ".output, .cell_output"
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
Project 2 on Machine Learning, deadline November 17 (Midnight)
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project3.html">
Project 3 on Machine Learning, deadline December 18 (midnight), 2023
</a>
</li>
</ul>
@@ -1716,7 +1731,7 @@ Since we are not using <strong>Scikit-Learn</strong> here we can define our own
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.996738628265756
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.9958946686888259
</pre></div>
</div>
</div>
@@ -1733,7 +1748,7 @@ Since we are not using <strong>Scikit-Learn</strong> here we can define our own
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.00846262916105675
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.008142188979400687
</pre></div>
</div>
</div>
@@ -1748,31 +1763,23 @@ Since we are not using <strong>Scikit-Learn</strong> here we can define our own
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[2.18321314e-02 4.63790586e-02 1.86599003e-02 2.57537966e-02
7.75301638e-03 2.41708096e-03 2.05388549e-02 2.24797183e-02
3.80669838e-02 1.77124395e-02 5.74437617e-02 8.91992985e-03
3.79831624e-02 1.33444711e-02 2.46753261e-02 2.04450975e-02
8.98180203e-02 1.21522960e-02 3.12747234e-03 1.31395784e-03
1.84447599e-03 2.96525482e-03 6.28909679e-03 1.52006777e-02
2.87135280e-03 2.40513177e-02 3.35417405e-02 5.92991719e-03
3.54379087e-02 7.18303628e-03 1.54601264e-02 2.15148810e-02
2.79754897e-03 4.12602928e-03 4.22227163e-02 3.09676156e-02
1.25713219e-02 2.32108713e-02 2.44657526e-02 1.05066388e-02
6.68324974e-02 2.97565845e-02 2.42484290e-02 1.89707309e-02
2.19461919e-02 1.41644629e-02 1.41226929e-02 5.23396766e-03
3.21530495e-03 3.66036618e-03 7.91408373e-03 3.18065689e-02
5.10582403e-02 6.76220793e-03 3.09797549e-02 1.01612033e-02
4.64257697e-02 1.98270777e-02 2.88088818e-02 5.94948363e-03
8.94501598e-03 4.64365518e-03 4.55438359e-02 3.34347894e-03
4.97761429e-03 2.71875845e-02 1.57316402e-02 4.15628391e-02
4.75979803e-02 8.77079389e-03 3.22623101e-03 2.53596681e-03
4.02206965e-02 3.06020683e-02 3.07080407e-02 9.75525377e-03
6.45380691e-02 2.66174067e-02 1.94727053e-03 4.82766482e-03
3.39313789e-03 5.00126617e-02 3.25794223e-02 3.97663980e-02
3.51267283e-02 4.43226747e-02 4.45976616e-03 2.86750237e-02
2.33197004e-02 9.78449688e-05 4.38688646e-02 2.86830766e-02
2.90763970e-02 9.24053124e-03 1.36970119e-02 6.97177697e-02
2.34728094e-02 2.31728952e-02 3.08484802e-03 6.25254477e-02]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[0.0476021 0.02689869 0.01088331 0.01783105 0.00544013 0.05110385
0.02900389 0.01629703 0.05594058 0.02527366 0.00657884 0.04127087
0.01925607 0.02221978 0.01212083 0.04919181 0.00745959 0.03110176
0.010203 0.0076995 0.00298213 0.01702968 0.04557362 0.03192124
0.06668218 0.0178392 0.00706728 0.0095239 0.00784983 0.05197707
0.01519861 0.0134093 0.00291822 0.00311528 0.02036289 0.01136976
0.0189559 0.04908155 0.01384493 0.01715895 0.01262581 0.00756465
0.00473818 0.00224783 0.01773579 0.03804636 0.03945128 0.01662346
0.05137822 0.00206124 0.06090176 0.01632212 0.01220987 0.06361921
0.00318122 0.00362359 0.03177421 0.06554078 0.00123144 0.01091059
0.04958045 0.00291334 0.01541622 0.00607264 0.05274561 0.007352
0.06263415 0.01593612 0.00853836 0.01006042 0.00223784 0.02106518
0.02410507 0.08294341 0.0043675 0.06502562 0.03422156 0.00213264
0.02365779 0.01883403 0.00683222 0.01848399 0.02930957 0.02161016
0.02746315 0.02774744 0.03591454 0.04814746 0.00568413 0.00215333
0.03631783 0.02866734 0.01684326 0.00953152 0.01001378 0.00119895
0.02603725 0.00127672 0.04770636 0.028797 ]
</pre></div>
</div>
</div>
@@ -1841,15 +1848,15 @@ but now splitting the data into a training set and a test set.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[ 1.97864285 0.28134042 4.70594499 -0.58368727 0.70917314]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[ 2.02283241 0.15972118 3.84256187 1.89005305 -0.93145755]
Training R2
0.993658072083743
0.9959044445566834
Training MSE
0.012874822204495243
0.010349061754867921
Test R2
0.9945729062189713
0.9961996615568259
Test MSE
0.007472516848671787
0.008771887357306985
</pre></div>
</div>
</div>

Some files were not shown because too many files have changed in this diff Show More