This commit is contained in:
Morten Hjorth-Jensen
2024-11-17 15:55:37 +01:00
parent df2f85227b
commit 3147098147
191 changed files with 20795 additions and 4445 deletions
+74 -71
View File
@@ -34,7 +34,7 @@
<link rel="stylesheet" type="text/css" href="_static/styles/sphinx-book-theme.css?v=a3416100" />
<link rel="stylesheet" type="text/css" href="_static/togglebutton.css?v=13237357" />
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="_static/mystnb.4510f1fc1dee50b3e5859aac5469c37c29e427902b24a333a5f9fcb2f0b3ac41.css" />
<link rel="stylesheet" type="text/css" href="_static/mystnb.4510f1fc1dee50b3e5859aac5469c37c29e427902b24a333a5f9fcb2f0b3ac41.css?v=be8a1c11" />
<link rel="stylesheet" type="text/css" href="_static/sphinx-thebe.css?v=4fa983c6" />
<link rel="stylesheet" type="text/css" href="_static/sphinx-design.min.css?v=95c83b7e" />
@@ -254,6 +254,9 @@
<li class="toctree-l1"><a class="reference internal" href="week44.html">Week 44, Convolutional Neural Networks (CNN)</a></li>
<li class="toctree-l1"><a class="reference internal" href="week45.html">Week 45, Convolutional Neural Networks (CCNs) and Recurrent Neural Networks (RNNs)</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</a></li>
<li class="toctree-l1"><a class="reference internal" href="exercisesweek47.html">Exercise week 47</a></li>
</ul>
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Projects</span></p>
<ul class="nav bd-sidenav">
@@ -614,10 +617,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.10788894797253629
3.6790874039223653
[[ 1.18171035 3.52117449]
[ 3.52117449 11.6382529 ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.08913527419249101
3.7127415072708665
[[ 1.13025431 3.39215451]
[ 3.39215451 11.15061293]]
</pre></div>
</div>
</div>
@@ -657,10 +660,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.08881838553924991
1.6247013033699416
[[1. 0.65701477]
[0.65701477 1. ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.09335279187105122
2.2108106787032815
[[1. 0.66771869]
[0.66771869 1. ]]
</pre></div>
</div>
</div>
@@ -689,30 +692,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.05662878 1.37467921]
[-1.56333824 -3.5136046 ]
[ 0.15344015 1.34849765]
[ 0.71518529 2.50939698]
[-0.2748515 -2.1020484 ]
[-0.10159408 -2.63005749]
[-0.64480719 -1.2968224 ]
[ 0.55460489 1.06146057]
[ 1.03970435 4.18061699]
[ 0.1782851 -0.93211852]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[ 0.35582913 0.96196912]
[ 0.20039135 1.07902642]
[-0.47708415 -1.39752266]
[-0.0118395 0.55664957]
[-0.18990703 1.30646904]
[ 0.22370063 -0.76173777]
[-0.25925579 -1.7132548 ]
[-0.56061802 -1.9921751 ]
[-1.14025916 -4.44655399]
[ 1.85904253 6.40713017]]
0 1
0 -0.056629 1.374679
1 -1.563338 -3.513605
2 0.153440 1.348498
3 0.715185 2.509397
4 -0.274852 -2.102048
5 -0.101594 -2.630057
6 -0.644807 -1.296822
7 0.554605 1.061461
8 1.039704 4.180617
9 0.178285 -0.932119
0 0.355829 0.961969
1 0.200391 1.079026
2 -0.477084 -1.397523
3 -0.011839 0.556650
4 -0.189907 1.306469
5 0.223701 -0.761738
6 -0.259256 -1.713255
7 -0.560618 -1.992175
8 -1.140259 -4.446554
9 1.859043 6.407130
0 1
0 1.000000 0.845552
1 0.845552 1.000000
0 1.000000 0.946278
1 0.946278 1.000000
</pre></div>
</div>
</div>
@@ -769,37 +772,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.084442 0.087416 0.085903 0.084926 0.083769 0.078992 0.077203
2 0.0 0.087416 0.092483 0.089654 0.089681 0.089361 0.082384 0.081118
3 0.0 0.085903 0.089654 0.093779 0.092882 0.091642 0.089976 0.087925
4 0.0 0.084926 0.089681 0.092882 0.092595 0.091896 0.089004 0.087346
5 0.0 0.083769 0.089361 0.091642 0.091896 0.091694 0.087651 0.086360
6 0.0 0.078992 0.082384 0.089976 0.089004 0.087651 0.088697 0.086573
7 0.0 0.077203 0.081118 0.087925 0.087346 0.086360 0.086573 0.084743
8 0.0 0.075459 0.079833 0.085858 0.085639 0.084999 0.084404 0.082852
9 0.0 0.073790 0.078582 0.083819 0.083940 0.083630 0.082237 0.080953
10 0.0 0.071660 0.074465 0.083896 0.082819 0.081372 0.084236 0.082113
11 0.0 0.069730 0.072833 0.081583 0.080779 0.079598 0.081839 0.079946
12 0.0 0.067898 0.071271 0.079347 0.078801 0.077874 0.079503 0.077829
13 0.0 0.066167 0.069798 0.077201 0.076902 0.076222 0.077241 0.075780
14 0.0 0.064543 0.068424 0.075155 0.075095 0.074656 0.075064 0.073809
1 0.0 0.075894 0.073179 0.073456 0.072746 0.071970 0.064485 0.064123
2 0.0 0.073179 0.070833 0.070597 0.070031 0.069409 0.061930 0.061649
3 0.0 0.073456 0.070597 0.076555 0.075647 0.074674 0.070295 0.069812
4 0.0 0.072746 0.070031 0.075647 0.074821 0.073930 0.069398 0.068968
5 0.0 0.071970 0.069409 0.074674 0.073930 0.073126 0.068445 0.068069
6 0.0 0.064485 0.061930 0.070295 0.069398 0.068445 0.066551 0.066050
7 0.0 0.064123 0.061649 0.069812 0.068968 0.068069 0.066050 0.065589
8 0.0 0.063763 0.061372 0.069330 0.068539 0.067694 0.065550 0.065128
9 0.0 0.063403 0.061097 0.068844 0.068107 0.067318 0.065047 0.064664
10 0.0 0.055942 0.053732 0.062913 0.062085 0.061210 0.060946 0.060463
11 0.0 0.055680 0.053525 0.062569 0.061780 0.060945 0.060582 0.060130
12 0.0 0.055429 0.053330 0.062237 0.061487 0.060692 0.060229 0.059808
13 0.0 0.055190 0.053147 0.061915 0.061205 0.060449 0.059887 0.059497
14 0.0 0.054960 0.052974 0.061603 0.060933 0.060217 0.059554 0.059195
8 9 10 11 12 13 14
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.075459 0.073790 0.071660 0.069730 0.067898 0.066167 0.064543
2 0.079833 0.078582 0.074465 0.072833 0.071271 0.069798 0.068424
3 0.085858 0.083819 0.083896 0.081583 0.079347 0.077201 0.075155
4 0.085639 0.083940 0.082819 0.080779 0.078801 0.076902 0.075095
5 0.084999 0.083630 0.081372 0.079598 0.077874 0.076222 0.074656
6 0.084404 0.082237 0.084236 0.081839 0.079503 0.077241 0.075064
7 0.082852 0.080953 0.082113 0.079946 0.077829 0.075780 0.073809
8 0.081230 0.079591 0.079936 0.077991 0.076088 0.074246 0.072478
9 0.079591 0.078208 0.077748 0.076019 0.074325 0.072688 0.071121
10 0.079936 0.077748 0.081045 0.078681 0.076364 0.074111 0.071928
11 0.077991 0.076019 0.078681 0.076508 0.074378 0.072303 0.070295
12 0.076088 0.074325 0.076364 0.074378 0.072426 0.070527 0.068690
13 0.074246 0.072688 0.074111 0.072303 0.070527 0.068798 0.067128
14 0.072478 0.071121 0.071928 0.070295 0.068690 0.067128 0.065622
1 0.063763 0.063403 0.055942 0.055680 0.055429 0.055190 0.054960
2 0.061372 0.061097 0.053732 0.053525 0.053330 0.053147 0.052974
3 0.069330 0.068844 0.062913 0.062569 0.062237 0.061915 0.061603
4 0.068539 0.068107 0.062085 0.061780 0.061487 0.061205 0.060933
5 0.067694 0.067318 0.061210 0.060945 0.060692 0.060449 0.060217
6 0.065550 0.065047 0.060946 0.060582 0.060229 0.059887 0.059554
7 0.065128 0.064664 0.060463 0.060130 0.059808 0.059497 0.059195
8 0.064706 0.064282 0.059981 0.059679 0.059388 0.059108 0.058837
9 0.064282 0.063898 0.059497 0.059226 0.058967 0.058718 0.058478
10 0.059981 0.059497 0.056837 0.056475 0.056124 0.055783 0.055452
11 0.059679 0.059226 0.056475 0.056139 0.055814 0.055499 0.055194
12 0.059388 0.058967 0.056124 0.055814 0.055515 0.055226 0.054947
13 0.059108 0.058718 0.055783 0.055499 0.055226 0.054963 0.054709
14 0.058837 0.058478 0.055452 0.055194 0.054947 0.054709 0.054481
</pre></div>
</div>
</div>
@@ -988,10 +991,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.970238 1.999801
1 1.999801 2.021273
[[3.97023801 1.99980092]
[1.99980092 2.02127327]]
0 3.946263 1.971035
1 1.971035 1.988524
[[3.94626291 1.97103474]
[1.97103474 1.98852413]]
</pre></div>
</div>
</div>
@@ -1018,11 +1021,11 @@ 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.97023801 1.99980092]
[1.99980092 2.02127327]]
[[3.94626291 1.97103474]
[1.97103474 1.98852413]]
</pre></div>
</div>
<img alt="_images/e5e6bf0c464c3e5a86a023adac1e329391745d4c31e520e53767d038a5bcf4ae.png" src="_images/e5e6bf0c464c3e5a86a023adac1e329391745d4c31e520e53767d038a5bcf4ae.png" />
<img alt="_images/6ca0e6a8c6122c37cbb752b49917fd1e67a1de46298e8c2247a990d083fdb3c7.png" src="_images/6ca0e6a8c6122c37cbb752b49917fd1e67a1de46298e8c2247a990d083fdb3c7.png" />
</div>
</div>
<p>Depending on the number of points <span class="math notranslate nohighlight">\(n\)</span>, we will get results that are close to the covariance values defined above.
@@ -1079,16 +1082,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.220349900775413
0.7711613838358012
5.168112312789667
0.7666747242371026
First eigenvector
[0.84795327 0.53007099]
[0.84993979 0.52687982]
Second eigenvector
[-0.53007099 0.84795327]
[-0.52687982 0.84993979]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Eigenvector of largest eigenvalue
[-0.84795327 -0.53007099]
[0.84993979 0.52687982]
</pre></div>
</div>
</div>