update
This commit is contained in:
@@ -242,6 +242,33 @@ const thebe_selector_output = ".output, .cell_output"
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p aria-level="2" class="caption" role="heading">
|
||||
<span class="caption-text">
|
||||
Weekly material, notes and exercises
|
||||
</span>
|
||||
</p>
|
||||
<ul class="nav bd-sidenav">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="exercisesweek34.html">
|
||||
Exercises week 34
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="week34.html">
|
||||
Week 34: Introduction to the course, Logistics and Practicalities
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="exercisesweek35.html">
|
||||
Exercises week 35
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="week35.html">
|
||||
Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</nav> <!-- To handle the deprecated key -->
|
||||
@@ -642,10 +669,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.046785461905835435
|
||||
4.240670854503034
|
||||
[[0.94986593 2.88137798]
|
||||
[2.88137798 9.93586895]]
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.264540221699101
|
||||
4.673457751724773
|
||||
[[0.83632853 2.54078623]
|
||||
[2.54078623 8.44021223]]
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -685,10 +712,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.08271198519070039
|
||||
1.7306310662842432
|
||||
[[1. 0.58084359]
|
||||
[0.58084359 1. ]]
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.08374032367704139
|
||||
1.7696835316227453
|
||||
[[1. 0.66443521]
|
||||
[0.66443521 1. ]]
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -717,30 +744,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.50488131 -2.2493023 ]
|
||||
[-0.26115367 -1.92631966]
|
||||
[-1.43556723 -2.99992698]
|
||||
[ 0.64528459 2.57643113]
|
||||
[-0.55273102 -2.09964817]
|
||||
[ 0.31681097 1.26466619]
|
||||
[-0.04673082 -0.56607416]
|
||||
[ 1.53394148 5.38629412]
|
||||
[ 0.15092012 -0.22014758]
|
||||
[ 0.15410688 0.83402742]]
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[ 1.20708879 4.33201844]
|
||||
[-0.3838783 -1.24125217]
|
||||
[ 0.74722409 1.60194224]
|
||||
[-0.04086326 0.37419664]
|
||||
[ 0.62422045 2.05587489]
|
||||
[ 1.75357263 5.63710438]
|
||||
[-2.53968309 -7.28219089]
|
||||
[-1.42054337 -4.90629812]
|
||||
[-0.13019959 -0.83320794]
|
||||
[ 0.18306165 0.26181254]]
|
||||
0 1
|
||||
0 -0.504881 -2.249302
|
||||
1 -0.261154 -1.926320
|
||||
2 -1.435567 -2.999927
|
||||
3 0.645285 2.576431
|
||||
4 -0.552731 -2.099648
|
||||
5 0.316811 1.264666
|
||||
6 -0.046731 -0.566074
|
||||
7 1.533941 5.386294
|
||||
8 0.150920 -0.220148
|
||||
9 0.154107 0.834027
|
||||
0 1
|
||||
0 1.00000 0.95302
|
||||
1 0.95302 1.00000
|
||||
0 1.207089 4.332018
|
||||
1 -0.383878 -1.241252
|
||||
2 0.747224 1.601942
|
||||
3 -0.040863 0.374197
|
||||
4 0.624220 2.055875
|
||||
5 1.753573 5.637104
|
||||
6 -2.539683 -7.282191
|
||||
7 -1.420543 -4.906298
|
||||
8 -0.130200 -0.833208
|
||||
9 0.183062 0.261813
|
||||
0 1
|
||||
0 1.000000 0.992504
|
||||
1 0.992504 1.000000
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -797,37 +824,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.088104 0.081216 0.088760 0.086997 0.085010 0.080343 0.079306
|
||||
2 0.0 0.081216 0.075612 0.080764 0.079618 0.078300 0.072530 0.071897
|
||||
3 0.0 0.088760 0.080764 0.094925 0.092249 0.089310 0.089233 0.087615
|
||||
4 0.0 0.086997 0.079618 0.092249 0.089982 0.087470 0.086257 0.084927
|
||||
5 0.0 0.085010 0.078300 0.089310 0.087470 0.085410 0.083021 0.081989
|
||||
6 0.0 0.080343 0.072530 0.089233 0.086257 0.083021 0.086109 0.084269
|
||||
7 0.0 0.079306 0.071897 0.087615 0.084927 0.081989 0.084269 0.082642
|
||||
8 0.0 0.078323 0.071329 0.086021 0.083629 0.080998 0.082431 0.081022
|
||||
9 0.0 0.077372 0.070810 0.084426 0.082339 0.080026 0.080571 0.079383
|
||||
10 0.0 0.071946 0.064637 0.081990 0.079001 0.075770 0.080642 0.078768
|
||||
11 0.0 0.071044 0.064041 0.080699 0.077930 0.074922 0.079218 0.077511
|
||||
12 0.0 0.070222 0.063524 0.079476 0.076927 0.074144 0.077846 0.076306
|
||||
13 0.0 0.069475 0.063084 0.078314 0.075987 0.073433 0.076518 0.075145
|
||||
14 0.0 0.068799 0.062719 0.077203 0.075102 0.072783 0.075222 0.074019
|
||||
1 0.0 0.092290 0.091376 0.091772 0.091659 0.091579 0.083691 0.083321
|
||||
2 0.0 0.091376 0.091209 0.090620 0.090923 0.091266 0.082166 0.082105
|
||||
3 0.0 0.091772 0.090620 0.098069 0.097435 0.096845 0.093556 0.092724
|
||||
4 0.0 0.091659 0.090923 0.097435 0.097111 0.096833 0.092478 0.091896
|
||||
5 0.0 0.091579 0.091266 0.096845 0.096833 0.096872 0.091445 0.091113
|
||||
6 0.0 0.083691 0.082166 0.093556 0.092478 0.091445 0.092007 0.090828
|
||||
7 0.0 0.083321 0.082105 0.092724 0.091896 0.091113 0.090828 0.089857
|
||||
8 0.0 0.083051 0.082145 0.091996 0.091418 0.090888 0.089744 0.088982
|
||||
9 0.0 0.082877 0.082285 0.091369 0.091044 0.090768 0.088754 0.088201
|
||||
10 0.0 0.075829 0.073985 0.087419 0.086021 0.084663 0.087860 0.086440
|
||||
11 0.0 0.075277 0.073684 0.086460 0.085272 0.084124 0.086624 0.085384
|
||||
12 0.0 0.074819 0.073477 0.085603 0.084624 0.083685 0.085484 0.084422
|
||||
13 0.0 0.074453 0.073363 0.084846 0.084076 0.083348 0.084438 0.083555
|
||||
14 0.0 0.074180 0.073344 0.084187 0.083627 0.083111 0.083485 0.082779
|
||||
|
||||
8 9 10 11 12 13 14
|
||||
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
|
||||
1 0.078323 0.077372 0.071946 0.071044 0.070222 0.069475 0.068799
|
||||
2 0.071329 0.070810 0.064637 0.064041 0.063524 0.063084 0.062719
|
||||
3 0.086021 0.084426 0.081990 0.080699 0.079476 0.078314 0.077203
|
||||
4 0.083629 0.082339 0.079001 0.077930 0.076927 0.075987 0.075102
|
||||
5 0.080998 0.080026 0.075770 0.074922 0.074144 0.073433 0.072783
|
||||
6 0.082431 0.080571 0.080642 0.079218 0.077846 0.076518 0.075222
|
||||
7 0.081022 0.079383 0.078768 0.077511 0.076306 0.075145 0.074019
|
||||
8 0.079622 0.078211 0.076886 0.075797 0.074760 0.073768 0.072813
|
||||
9 0.078211 0.077033 0.074969 0.074050 0.073183 0.072364 0.071585
|
||||
10 0.076886 0.074969 0.076632 0.075201 0.073811 0.072452 0.071115
|
||||
11 0.075797 0.074050 0.075201 0.073904 0.072647 0.071421 0.070216
|
||||
12 0.074760 0.073183 0.073811 0.072647 0.071523 0.070428 0.069355
|
||||
13 0.073768 0.072364 0.072452 0.071421 0.070428 0.069465 0.068525
|
||||
14 0.072813 0.071585 0.071115 0.070216 0.069355 0.068525 0.067719
|
||||
1 0.083051 0.082877 0.075829 0.075277 0.074819 0.074453 0.074180
|
||||
2 0.082145 0.082285 0.073985 0.073684 0.073477 0.073363 0.073344
|
||||
3 0.091996 0.091369 0.087419 0.086460 0.085603 0.084846 0.084187
|
||||
4 0.091418 0.091044 0.086021 0.085272 0.084624 0.084076 0.083627
|
||||
5 0.090888 0.090768 0.084663 0.084124 0.083685 0.083348 0.083111
|
||||
6 0.089744 0.088754 0.087860 0.086624 0.085484 0.084438 0.083485
|
||||
7 0.088982 0.088201 0.086440 0.085384 0.084422 0.083555 0.082779
|
||||
8 0.088317 0.087746 0.085108 0.084230 0.083446 0.082756 0.082158
|
||||
9 0.087746 0.087386 0.083859 0.083159 0.082553 0.082040 0.081620
|
||||
10 0.085108 0.083859 0.085252 0.083832 0.082501 0.081258 0.080098
|
||||
11 0.084230 0.083159 0.083832 0.082569 0.081395 0.080305 0.079298
|
||||
12 0.083446 0.082553 0.082501 0.081395 0.080374 0.079437 0.078582
|
||||
13 0.082756 0.082040 0.081258 0.080305 0.079437 0.078652 0.077949
|
||||
14 0.082158 0.081620 0.080098 0.079298 0.078582 0.077949 0.077397
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1016,10 +1043,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 3.967536 1.983164
|
||||
1 1.983164 2.000755
|
||||
[[3.9675364 1.98316352]
|
||||
[1.98316352 2.00075534]]
|
||||
0 3.956454 1.972286
|
||||
1 1.972286 1.977089
|
||||
[[3.95645365 1.97228638]
|
||||
[1.97228638 1.97708897]]
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1046,8 +1073,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
|
||||
[[3.9675364 1.98316352]
|
||||
[1.98316352 2.00075534]]
|
||||
[[3.95645365 1.97228638]
|
||||
[1.97228638 1.97708897]]
|
||||
</pre></div>
|
||||
</div>
|
||||
<img alt="_images/chapter8_65_1.png" src="_images/chapter8_65_1.png" />
|
||||
@@ -1107,16 +1134,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.197738983259782
|
||||
0.7705527590466072
|
||||
5.173439546289586
|
||||
0.7601030735620569
|
||||
First eigenvector
|
||||
[0.84977962 0.52713812]
|
||||
[0.85102768 0.52512084]
|
||||
Second eigenvector
|
||||
[-0.52713812 0.84977962]
|
||||
[-0.52512084 0.85102768]
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Eigenvector of largest eigenvalue
|
||||
[-0.84977962 -0.52713812]
|
||||
[-0.85102768 -0.52512084]
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user