last update, perhaps

This commit is contained in:
Morten Hjorth-Jensen
2024-10-14 13:54:09 +02:00
parent 7d4725e646
commit 0bc2e08294
52 changed files with 2146 additions and 1626 deletions
+64 -63
View File
@@ -1315,10 +1315,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.04718566894028431
4.11080997912276
[[ 1.10517643 3.48455788]
[ 3.48455788 12.00216162]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.014394967608286841
4.011594819155615
[[ 1.24508783 3.8595836 ]
[ 3.8595836 12.92663007]]
</pre></div>
</div>
</div>
@@ -1355,10 +1355,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.07836997022107646
1.1378267322316808
[[1. 0.63980097]
[0.63980097 1. ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.07630326327869198
1.6893421391051477
[[1. 0.6373454]
[0.6373454 1. ]]
</pre></div>
</div>
</div>
@@ -1388,30 +1388,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.34931214 3.06139439]
[-0.44476964 -2.60794187]
[ 0.02225493 0.16388664]
[-1.91193672 -3.82324216]
[-0.2044881 -1.56027537]
[-1.15572395 -3.25982474]
[ 0.94217756 1.49888671]
[ 0.28472162 2.92474572]
[ 2.38943 7.14118216]
[-1.27097785 -3.5388115 ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[ 0.20396326 0.93053605]
[ 0.51936974 2.03440431]
[-0.53851084 -1.2527027 ]
[-0.50429483 0.72966563]
[ 0.71314288 1.60421343]
[-0.29995377 -2.31356849]
[-0.14484831 -2.19932442]
[-0.00570826 -0.32643011]
[-0.22821607 0.56775345]
[ 0.28505619 0.22545286]]
0 1
0 1.349312 3.061394
1 -0.444770 -2.607942
2 0.022255 0.163887
3 -1.911937 -3.823242
4 -0.204488 -1.560275
5 -1.155724 -3.259825
6 0.942178 1.498887
7 0.284722 2.924746
8 2.389430 7.141182
9 -1.270978 -3.538811
0 1
0 1.000000 0.950873
1 0.950873 1.000000
0 0.203963 0.930536
1 0.519370 2.034404
2 -0.538511 -1.252703
3 -0.504295 0.729666
4 0.713143 1.604213
5 -0.299954 -2.313568
6 -0.144848 -2.199324
7 -0.005708 -0.326430
8 -0.228216 0.567753
9 0.285056 0.225453
0 1
0 1.0000 0.6373
1 0.6373 1.0000
</pre></div>
</div>
</div>
@@ -1468,37 +1468,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.074334 0.080585 0.077061 0.078751 0.080220 0.070657 0.071406
2 0.0 0.080585 0.088425 0.082009 0.084289 0.086338 0.074009 0.075052
3 0.0 0.077061 0.082009 0.085147 0.086339 0.087297 0.081324 0.081796
4 0.0 0.078751 0.084289 0.086339 0.087789 0.089007 0.081926 0.082537
5 0.0 0.080220 0.086338 0.087297 0.089007 0.090492 0.082307 0.083061
6 0.0 0.070657 0.074009 0.081324 0.081926 0.082307 0.079874 0.080032
7 0.0 0.071406 0.075052 0.081796 0.082537 0.083061 0.080032 0.080271
8 0.0 0.072148 0.076101 0.082240 0.083128 0.083801 0.080150 0.080474
9 0.0 0.072902 0.077180 0.082670 0.083714 0.084548 0.080237 0.080651
10 0.0 0.063646 0.065859 0.075320 0.075498 0.075472 0.075478 0.075409
11 0.0 0.064071 0.066452 0.075576 0.075838 0.075897 0.075542 0.075525
12 0.0 0.064514 0.067074 0.075838 0.076189 0.076340 0.075602 0.075639
13 0.0 0.064980 0.067731 0.076108 0.076555 0.076803 0.075658 0.075753
14 0.0 0.065472 0.068429 0.076389 0.076938 0.077292 0.075711 0.075868
1 0.0 0.072835 0.076616 0.071253 0.074193 0.077337 0.063283 0.065305
2 0.0 0.076616 0.082149 0.073794 0.077643 0.081811 0.064373 0.066929
3 0.0 0.071253 0.073794 0.075423 0.077534 0.079745 0.070414 0.071978
4 0.0 0.074193 0.077643 0.077534 0.080199 0.083034 0.071575 0.073483
5 0.0 0.077337 0.081811 0.079745 0.083034 0.086576 0.072733 0.075028
6 0.0 0.063283 0.064373 0.070414 0.071575 0.072733 0.068008 0.068984
7 0.0 0.065305 0.066929 0.071978 0.073483 0.075028 0.068984 0.070181
8 0.0 0.067523 0.069754 0.073667 0.075563 0.077550 0.070010 0.071459
9 0.0 0.069964 0.072888 0.075496 0.077839 0.080330 0.071092 0.072826
10 0.0 0.055866 0.055925 0.064324 0.064790 0.065183 0.063660 0.064182
11 0.0 0.057298 0.057682 0.065508 0.066192 0.066830 0.064471 0.065139
12 0.0 0.058866 0.059624 0.066786 0.067719 0.068637 0.065330 0.066162
13 0.0 0.060590 0.061775 0.068171 0.069388 0.070625 0.066241 0.067260
14 0.0 0.062489 0.064164 0.069675 0.071217 0.072820 0.067209 0.068440
8 9 10 11 12 13 14
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.072148 0.072902 0.063646 0.064071 0.064514 0.064980 0.065472
2 0.076101 0.077180 0.065859 0.066452 0.067074 0.067731 0.068429
3 0.082240 0.082670 0.075320 0.075576 0.075838 0.076108 0.076389
4 0.083128 0.083714 0.075498 0.075838 0.076189 0.076555 0.076938
5 0.083801 0.084548 0.075472 0.075897 0.076340 0.076803 0.077292
6 0.080150 0.080237 0.075478 0.075542 0.075602 0.075658 0.075711
7 0.080474 0.080651 0.075409 0.075525 0.075639 0.075753 0.075868
8 0.080766 0.081038 0.075293 0.075463 0.075634 0.075809 0.075988
9 0.081038 0.081411 0.075136 0.075363 0.075595 0.075834 0.076082
10 0.075293 0.075136 0.072406 0.072329 0.072240 0.072140 0.072028
11 0.075463 0.075363 0.072329 0.072286 0.072234 0.072173 0.072101
12 0.075634 0.075595 0.072240 0.072234 0.072220 0.072199 0.072171
13 0.075809 0.075834 0.072140 0.072173 0.072199 0.072221 0.072238
14 0.075988 0.076082 0.072028 0.072101 0.072171 0.072238 0.072303
1 0.067523 0.069964 0.055866 0.057298 0.058866 0.060590 0.062489
2 0.069754 0.072888 0.055925 0.057682 0.059624 0.061775 0.064164
3 0.073667 0.075496 0.064324 0.065508 0.066786 0.068171 0.069675
4 0.075563 0.077839 0.064790 0.066192 0.067719 0.069388 0.071217
5 0.077550 0.080330 0.065183 0.066830 0.068637 0.070625 0.072820
6 0.070010 0.071092 0.063660 0.064471 0.065330 0.066241 0.067209
7 0.071459 0.072826 0.064182 0.065139 0.066162 0.067260 0.068440
8 0.073021 0.074713 0.064703 0.065823 0.067032 0.068341 0.069761
9 0.074713 0.076776 0.065219 0.066524 0.067943 0.069492 0.071186
10 0.064703 0.065219 0.060678 0.061187 0.061707 0.062241 0.062786
11 0.065823 0.066524 0.061187 0.061793 0.062424 0.063082 0.063768
12 0.067032 0.067943 0.061707 0.062424 0.063180 0.063978 0.064823
13 0.068341 0.069492 0.062241 0.063082 0.063978 0.064935 0.065960
14 0.069761 0.071186 0.062786 0.063768 0.064823 0.065960 0.067192
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>
</pre></div>
</div>
</div>
@@ -1979,13 +1982,11 @@ We select values of the hyperparameter <span class="math notranslate nohighlight
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[2. 2.]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Training MSE for OLS
Training MSE for OLS
3.0
</pre></div>
</div>
<img alt="_images/chapter2_252_2.png" src="_images/chapter2_252_2.png" />
<img alt="_images/chapter2_252_1.png" src="_images/chapter2_252_1.png" />
</div>
</div>
<p>We see here that we reach a plateau for the Ridge results. Writing out the coefficients <span class="math notranslate nohighlight">\(\boldsymbol{\beta}\)</span>, we observe that they are getting smaller and smaller and our error stabilizes since the predicted values of <span class="math notranslate nohighlight">\(\tilde{\boldsymbol{y}}\)</span> approach zero.</p>