This commit is contained in:
Morten Hjorth-Jensen
2023-10-15 21:55:49 +02:00
parent cb5ab447ad
commit edf33b439c
171 changed files with 18722 additions and 1691 deletions
+94 -69
View File
@@ -313,6 +313,26 @@ const thebe_selector_output = ".output, .cell_output"
Week 40: Gradient descent methods (continued) and start Neural networks
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek41.html">
Exercises week 41
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week41.html">
Week 41 Neural networks and constructing a neural network code
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek42.html">
Exercises week 42
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week42.html">
Week 42 Constructing a Neural Network code with introduction to Tensor flow
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -325,6 +345,11 @@ const thebe_selector_output = ".output, .cell_output"
Project 1 on Machine Learning, deadline October 9 (midnight), 2023
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
</a>
</li>
</ul>
</div>
@@ -726,10 +751,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.026250840755899812
3.9783319210079595
[[ 1.06075426 3.40216748]
[ 3.40216748 11.8635085 ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.10776220958055382
3.743189104728408
[[0.82379443 2.29894362]
[2.29894362 7.75174305]]
</pre></div>
</div>
</div>
@@ -769,10 +794,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.08076969085177746
1.9295763474254684
[[1. 0.7135487]
[0.7135487 1. ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.0704374681593734
1.3273472571412799
[[1. 0.58076367]
[0.58076367 1. ]]
</pre></div>
</div>
</div>
@@ -801,30 +826,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.52944573 4.65218729]
[ 0.12050822 0.97069774]
[ 0.40413036 1.80861057]
[-0.07004211 0.30763135]
[-1.27793476 -4.21460652]
[-0.14670413 -1.48950243]
[-0.41506637 -1.52573941]
[ 1.75627883 5.73410729]
[-0.47187428 -1.10927588]
[-1.42874148 -5.13410999]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[-0.92200223 -1.78838813]
[-0.90854751 -2.66047048]
[ 0.83618601 2.91748202]
[-0.88821402 -4.10035098]
[ 0.44781662 2.48685204]
[ 1.20493234 2.32729105]
[ 1.02509184 2.42265837]
[-0.84210141 -3.82012236]
[-0.01031541 1.40111899]
[ 0.05715377 0.81392948]]
0 1
0 1.529446 4.652187
1 0.120508 0.970698
2 0.404130 1.808611
3 -0.070042 0.307631
4 -1.277935 -4.214607
5 -0.146704 -1.489502
6 -0.415066 -1.525739
7 1.756279 5.734107
8 -0.471874 -1.109276
9 -1.428741 -5.134110
0 -0.922002 -1.788388
1 -0.908548 -2.660470
2 0.836186 2.917482
3 -0.888214 -4.100351
4 0.447817 2.486852
5 1.204932 2.327291
6 1.025092 2.422658
7 -0.842101 -3.820122
8 -0.010315 1.401119
9 0.057154 0.813929
0 1
0 1.000000 0.988835
1 0.988835 1.000000
0 1.000000 0.920619
1 0.920619 1.000000
</pre></div>
</div>
</div>
@@ -881,37 +906,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.076825 0.078868 0.077705 0.077226 0.076504 0.071258 0.070157
2 0.0 0.078868 0.083096 0.081976 0.082506 0.082577 0.076127 0.075513
3 0.0 0.077705 0.081976 0.085023 0.085454 0.085391 0.081955 0.081126
4 0.0 0.077226 0.082506 0.085454 0.086441 0.086843 0.082760 0.082255
5 0.0 0.076504 0.082577 0.085391 0.086843 0.087642 0.083000 0.082781
6 0.0 0.071258 0.076127 0.081955 0.082760 0.083000 0.081584 0.080933
7 0.0 0.070157 0.075513 0.081126 0.082255 0.082781 0.080933 0.080505
8 0.0 0.069033 0.074780 0.080163 0.081570 0.082347 0.080105 0.079878
9 0.0 0.067915 0.073984 0.079124 0.080773 0.081772 0.079165 0.079121
10 0.0 0.064634 0.069384 0.076833 0.077710 0.078029 0.078187 0.077613
11 0.0 0.063407 0.068403 0.075582 0.076662 0.077171 0.076996 0.076587
12 0.0 0.062221 0.067419 0.074327 0.075587 0.076266 0.075779 0.075521
13 0.0 0.061084 0.066453 0.073088 0.074509 0.075342 0.074560 0.074439
14 0.0 0.060001 0.065517 0.071879 0.073445 0.074419 0.073354 0.073362
1 0.0 0.076527 0.079731 0.075684 0.075421 0.075030 0.066467 0.065808
2 0.0 0.079731 0.084207 0.080233 0.080607 0.080750 0.071252 0.070964
3 0.0 0.075684 0.080233 0.079381 0.079948 0.080284 0.072483 0.072285
4 0.0 0.075421 0.080607 0.079948 0.080953 0.081677 0.073541 0.073640
5 0.0 0.075030 0.080750 0.080284 0.081677 0.082746 0.074340 0.074708
6 0.0 0.066467 0.071252 0.072483 0.073541 0.074340 0.068082 0.068257
7 0.0 0.065808 0.070964 0.072285 0.073640 0.074708 0.068257 0.068650
8 0.0 0.065215 0.070694 0.072098 0.073720 0.075030 0.068406 0.068997
9 0.0 0.064696 0.070461 0.071942 0.073802 0.075331 0.068551 0.069320
10 0.0 0.057462 0.062071 0.064444 0.065735 0.066768 0.061869 0.062273
11 0.0 0.056898 0.061747 0.064145 0.065645 0.066870 0.061826 0.062390
12 0.0 0.056418 0.061484 0.063905 0.065593 0.066992 0.061813 0.062523
13 0.0 0.056019 0.061281 0.063722 0.065582 0.067139 0.061833 0.062675
14 0.0 0.055697 0.061138 0.063597 0.065614 0.067315 0.061888 0.062852
8 9 10 11 12 13 14
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.069033 0.067915 0.064634 0.063407 0.062221 0.061084 0.060001
2 0.074780 0.073984 0.069384 0.068403 0.067419 0.066453 0.065517
3 0.080163 0.079124 0.076833 0.075582 0.074327 0.073088 0.071879
4 0.081570 0.080773 0.077710 0.076662 0.075587 0.074509 0.073445
5 0.082347 0.081772 0.078029 0.077171 0.076266 0.075342 0.074419
6 0.080105 0.079165 0.078187 0.076996 0.075779 0.074560 0.073354
7 0.079878 0.079121 0.077613 0.076587 0.075521 0.074439 0.073362
8 0.079434 0.078845 0.076857 0.075984 0.075058 0.074108 0.073152
9 0.078845 0.078412 0.075980 0.075249 0.074457 0.073630 0.072790
10 0.076857 0.075980 0.076105 0.074970 0.073802 0.072624 0.071452
11 0.075984 0.075249 0.074970 0.073972 0.072931 0.071872 0.070811
12 0.075058 0.074457 0.073802 0.072931 0.072009 0.071062 0.070107
13 0.074108 0.073630 0.072624 0.071872 0.071062 0.070220 0.069365
14 0.073152 0.072790 0.071452 0.070811 0.070107 0.069365 0.068606
1 0.065215 0.064696 0.057462 0.056898 0.056418 0.056019 0.055697
2 0.070694 0.070461 0.062071 0.061747 0.061484 0.061281 0.061138
3 0.072098 0.071942 0.064444 0.064145 0.063905 0.063722 0.063597
4 0.073720 0.073802 0.065735 0.065645 0.065593 0.065582 0.065614
5 0.075030 0.075331 0.066768 0.066870 0.066992 0.067139 0.067315
6 0.068406 0.068551 0.061869 0.061826 0.061813 0.061833 0.061888
7 0.068997 0.069320 0.062273 0.062390 0.062523 0.062675 0.062852
8 0.069522 0.070009 0.062631 0.062894 0.063159 0.063434 0.063723
9 0.070009 0.070645 0.062963 0.063359 0.063747 0.064134 0.064527
10 0.062631 0.062963 0.057231 0.057361 0.057502 0.057657 0.057831
11 0.062894 0.063359 0.057361 0.057613 0.057864 0.058121 0.058388
12 0.063159 0.063747 0.057502 0.057864 0.058216 0.058567 0.058921
13 0.063434 0.064134 0.057657 0.058121 0.058567 0.059004 0.059439
14 0.063723 0.064527 0.057831 0.058388 0.058921 0.059439 0.059949
</pre></div>
</div>
</div>
@@ -1100,10 +1125,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.942604 1.984308
1 1.984308 1.984182
[[3.94260358 1.98430782]
[1.98430782 1.98418221]]
0 3.949162 1.987722
1 1.987722 2.004480
[[3.94916237 1.98772232]
[1.98772232 2.00447992]]
</pre></div>
</div>
</div>
@@ -1130,8 +1155,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.94260358 1.98430782]
[1.98430782 1.98418221]]
[[3.94916237 1.98772232]
[1.98772232 2.00447992]]
</pre></div>
</div>
<img alt="_images/chapter8_65_1.png" src="_images/chapter8_65_1.png" />
@@ -1191,16 +1216,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.17615838052499
0.7506274061293645
5.189621963782685
0.7640203256838339
First eigenvector
[0.84927263 0.52795454]
[0.84835621 0.52942586]
Second eigenvector
[-0.52795454 0.84927263]
[-0.52942586 0.84835621]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Eigenvector of largest eigenvalue
[0.84927263 0.52795454]
[0.84835621 0.52942586]
</pre></div>
</div>
</div>