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
+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>