updated book
This commit is contained in:
@@ -1624,7 +1624,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.211 14.8834 100.212 0.149388
|
||||
100.213 14.98 100.211 0.149466
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1844,7 +1844,9 @@ Error: 0.08426840630693411
|
||||
Bias^2: 0.0796891867672603
|
||||
Var: 0.004579219539673834
|
||||
0.08426840630693411 >= 0.0796891867672603 + 0.004579219539673834 = 0.08426840630693413
|
||||
Polynomial degree: 2
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Polynomial degree: 2
|
||||
Error: 0.10398646080125035
|
||||
Bias^2: 0.1007711427354898
|
||||
Var: 0.0032153180657605116
|
||||
@@ -1866,14 +1868,14 @@ Error: 0.05227921801205686
|
||||
Bias^2: 0.0481872773043029
|
||||
Var: 0.004091940707753939
|
||||
0.05227921801205686 >= 0.0481872773043029 + 0.004091940707753939 = 0.052279218012056844
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Polynomial degree: 6
|
||||
Polynomial degree: 6
|
||||
Error: 0.037813671417389005
|
||||
Bias^2: 0.033657685071527665
|
||||
Var: 0.00415598634586135
|
||||
0.037813671417389005 >= 0.033657685071527665 + 0.00415598634586135 = 0.03781367141738902
|
||||
Polynomial degree: 7
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Polynomial degree: 7
|
||||
Error: 0.02760977349102253
|
||||
Bias^2: 0.022999498260366312
|
||||
Var: 0.004610275230656212
|
||||
@@ -1895,7 +1897,9 @@ Error: 0.021592704588025025
|
||||
Bias^2: 0.010516485576645508
|
||||
Var: 0.011076219011379514
|
||||
0.021592704588025025 >= 0.010516485576645508 + 0.011076219011379514 = 0.021592704588025022
|
||||
Polynomial degree: 11
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Polynomial degree: 11
|
||||
Error: 0.07160048164233104
|
||||
Bias^2: 0.014436800088904942
|
||||
Var: 0.05716368155342608
|
||||
@@ -1912,7 +1916,7 @@ Var: 0.20867052175034223
|
||||
0.22842468702219465 >= 0.01975416527185249 + 0.20867052175034223 = 0.2284246870221947
|
||||
</pre></div>
|
||||
</div>
|
||||
<img alt="_images/week37_139_4.png" src="_images/week37_139_4.png" />
|
||||
<img alt="_images/week37_139_6.png" src="_images/week37_139_6.png" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2263,29 +2267,31 @@ Mean squared error on test data: 10.50427787
|
||||
Degree of polynomial: 7
|
||||
Mean squared error on training data: 0.47313680
|
||||
Mean squared error on test data: 1.53738247
|
||||
Degree of polynomial: 8
|
||||
Mean squared error on training data: 0.04926746
|
||||
Mean squared error on test data: 0.14629156
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 9
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 8
|
||||
Mean squared error on training data: 0.04926746
|
||||
Mean squared error on test data: 0.14629156
|
||||
Degree of polynomial: 9
|
||||
Mean squared error on training data: 0.02546675
|
||||
Mean squared error on test data: 0.11202337
|
||||
Degree of polynomial: 10
|
||||
Mean squared error on training data: 0.02424794
|
||||
Mean squared error on test data: 0.22467274
|
||||
Degree of polynomial: 11
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 11
|
||||
Mean squared error on training data: 0.01594452
|
||||
Mean squared error on test data: 1.07641937
|
||||
Degree of polynomial: 12
|
||||
Mean squared error on training data: 0.00805074
|
||||
Mean squared error on test data: 0.04295757
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 13
|
||||
Degree of polynomial: 13
|
||||
Mean squared error on training data: 0.00781918
|
||||
Mean squared error on test data: 0.56965674
|
||||
Degree of polynomial: 14
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 14
|
||||
Mean squared error on training data: 0.00465099
|
||||
Mean squared error on test data: 0.28443039
|
||||
Degree of polynomial: 15
|
||||
@@ -2305,29 +2311,31 @@ Mean squared error on test data: 429.25695398
|
||||
Degree of polynomial: 19
|
||||
Mean squared error on training data: 0.00154853
|
||||
Mean squared error on test data: 239.97065359
|
||||
Degree of polynomial: 20
|
||||
Mean squared error on training data: 0.00140846
|
||||
Mean squared error on test data: 1350.24493666
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 21
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 20
|
||||
Mean squared error on training data: 0.00140846
|
||||
Mean squared error on test data: 1350.24493666
|
||||
Degree of polynomial: 21
|
||||
Mean squared error on training data: 0.00119688
|
||||
Mean squared error on test data: 1840.50530832
|
||||
Degree of polynomial: 22
|
||||
Mean squared error on training data: 0.00092898
|
||||
Mean squared error on test data: 1184.60929685
|
||||
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.00089193
|
||||
Mean squared error on test data: 3892.17483760
|
||||
Degree of polynomial: 24
|
||||
Mean squared error on training data: 0.00083355
|
||||
Mean squared error on test data: 1332.46736215
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 25
|
||||
Degree of polynomial: 25
|
||||
Mean squared error on training data: 0.00079904
|
||||
Mean squared error on test data: 7577.76690383
|
||||
Degree of polynomial: 26
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Degree of polynomial: 26
|
||||
Mean squared error on training data: 0.00075590
|
||||
Mean squared error on test data: 1079.36895644
|
||||
Degree of polynomial: 27
|
||||
@@ -2343,13 +2351,13 @@ Mean squared error on training data: 0.00063866
|
||||
Mean squared error on test data: 3099.60342978
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_1579/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_6729/626635268.py:73: RuntimeWarning: divide by zero encountered in log10
|
||||
plt.plot(polynomial, np.log10(trainingerror), label='Training Error')
|
||||
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_1579/626635268.py:74: RuntimeWarning: divide by zero encountered in log10
|
||||
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_6729/626635268.py:74: RuntimeWarning: divide by zero encountered in log10
|
||||
plt.plot(polynomial, np.log10(testerror), label='Test Error')
|
||||
</pre></div>
|
||||
</div>
|
||||
<img alt="_images/week37_148_9.png" src="_images/week37_148_9.png" />
|
||||
<img alt="_images/week37_148_11.png" src="_images/week37_148_11.png" />
|
||||
</div>
|
||||
</div>
|
||||
<p>Note that we kept the intercept column in the fitting here. This means that we need to set the <strong>intercept</strong> in the call to the <strong>Scikit-Learn</strong> function as <strong>False</strong>. Alternatively, we could have set up the design matrix <span class="math notranslate nohighlight">\(X\)</span> without the first column of ones.</p>
|
||||
@@ -2430,7 +2438,7 @@ Mean squared error on test data: 3099.60342978
|
||||
</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_1579/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_6729/3817475779.py:63: RuntimeWarning: divide by zero encountered in log10
|
||||
plt.plot(polynomial, np.log10(estimated_mse_sklearn), label='Test Error')
|
||||
</pre></div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user