This commit is contained in:
Morten Hjorth-Jensen
2024-10-08 17:04:26 +02:00
parent 87d1e4455c
commit dbbebedb06
114 changed files with 3736 additions and 1751 deletions
+90 -70
View File
@@ -308,6 +308,21 @@ const thebe_selector_output = ".output, .cell_output"
Week 39: Optimization and Gradient Methods
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week40.html">
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>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -320,6 +335,11 @@ const thebe_selector_output = ".output, .cell_output"
Project 1 on Machine Learning, deadline October 7 (midnight), 2024
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 4 (Midnight)
</a>
</li>
</ul>
</div>
@@ -721,10 +741,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.13035147135400782
4.25879315330607
[[0.86867512 2.59009792]
[2.59009792 8.82533209]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.012423940191689783
4.101008878523571
[[0.89527291 2.65532045]
[2.65532045 8.81987609]]
</pre></div>
</div>
</div>
@@ -764,10 +784,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.08690184845323
1.521422502348998
[[1. 0.69768266]
[0.69768266 1. ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.08705631913312815
1.7026908764394864
[[1. 0.65870313]
[0.65870313 1. ]]
</pre></div>
</div>
</div>
@@ -796,30 +816,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.14550854 1.96870431]
[ 0.79787194 3.11438414]
[-0.18497496 -1.31315504]
[-1.52706754 -4.97482498]
[-1.30190897 -3.11113486]
[-0.08421808 -1.70928399]
[ 0.11992194 -0.07776381]
[-0.90717653 -2.20404927]
[ 1.05201041 5.38762019]
[ 0.89003324 2.9195033 ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[-1.7755649 -4.56778296]
[-0.81015037 -2.80072356]
[ 0.73628249 1.95206335]
[ 0.97366347 1.61130099]
[ 0.7271324 1.97965627]
[ 0.36881837 0.56037913]
[-1.33163086 -2.59391196]
[-0.68953877 -1.58298728]
[ 0.19982428 -1.08010965]
[ 1.60116388 6.52211567]]
0 1
0 1.145509 1.968704
1 0.797872 3.114384
2 -0.184975 -1.313155
3 -1.527068 -4.974825
4 -1.301909 -3.111135
5 -0.084218 -1.709284
6 0.119922 -0.077764
7 -0.907177 -2.204049
8 1.052010 5.387620
9 0.890033 2.919503
0 1
0 1.000000 0.937057
1 0.937057 1.000000
0 -1.775565 -4.567783
1 -0.810150 -2.800724
2 0.736282 1.952063
3 0.973663 1.611301
4 0.727132 1.979656
5 0.368818 0.560379
6 -1.331631 -2.593912
7 -0.689539 -1.582987
8 0.199824 -1.080110
9 1.601164 6.522116
0 1
0 1.00000 0.94335
1 0.94335 1.00000
</pre></div>
</div>
</div>
@@ -876,37 +896,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.080345 0.078573 0.079174 0.077839 0.076679 0.070275 0.069320
2 0.0 0.078573 0.078146 0.079202 0.078688 0.078268 0.071580 0.071186
3 0.0 0.079174 0.079202 0.083342 0.083016 0.082784 0.076947 0.076648
4 0.0 0.077839 0.078688 0.083016 0.083260 0.083547 0.077485 0.077601
5 0.0 0.076679 0.078268 0.082784 0.083547 0.084312 0.078044 0.078541
6 0.0 0.070275 0.071580 0.076947 0.077485 0.078044 0.072947 0.073258
7 0.0 0.069320 0.071186 0.076648 0.077601 0.078541 0.073258 0.073882
8 0.0 0.068539 0.070918 0.076479 0.077813 0.079107 0.073647 0.074561
9 0.0 0.067922 0.070772 0.076434 0.078123 0.079747 0.074115 0.075302
10 0.0 0.061319 0.063395 0.068977 0.070098 0.071191 0.066686 0.067431
11 0.0 0.060726 0.063206 0.068843 0.070274 0.071656 0.066988 0.067974
12 0.0 0.060275 0.063130 0.068827 0.070547 0.072200 0.067374 0.068587
13 0.0 0.059956 0.063161 0.068924 0.070916 0.072824 0.067843 0.069270
14 0.0 0.059761 0.063294 0.069129 0.071379 0.073528 0.068394 0.070024
1 0.0 0.088650 0.084209 0.092689 0.091653 0.090476 0.085764 0.085378
2 0.0 0.084209 0.080559 0.088599 0.087876 0.087020 0.082478 0.082249
3 0.0 0.092689 0.088599 0.102209 0.101292 0.100209 0.097667 0.097380
4 0.0 0.091653 0.087876 0.101292 0.100523 0.099588 0.097017 0.096811
5 0.0 0.090476 0.087020 0.100209 0.099588 0.098803 0.096203 0.096078
6 0.0 0.085764 0.082478 0.097667 0.097017 0.096203 0.095425 0.095278
7 0.0 0.085378 0.082249 0.097380 0.096811 0.096078 0.095278 0.095178
8 0.0 0.084976 0.082002 0.097060 0.096570 0.095915 0.095090 0.095037
9 0.0 0.084550 0.081730 0.096700 0.096287 0.095710 0.094857 0.094849
10 0.0 0.077672 0.075070 0.090429 0.090002 0.089421 0.089826 0.089786
11 0.0 0.077490 0.074976 0.090319 0.089940 0.089408 0.089800 0.089790
12 0.0 0.077310 0.074882 0.090204 0.089872 0.089386 0.089763 0.089783
13 0.0 0.077131 0.074787 0.090081 0.089795 0.089354 0.089714 0.089763
14 0.0 0.076951 0.074688 0.089949 0.089708 0.089311 0.089653 0.089730
8 9 10 11 12 13 14
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.068539 0.067922 0.061319 0.060726 0.060275 0.059956 0.059761
2 0.070918 0.070772 0.063395 0.063206 0.063130 0.063161 0.063294
3 0.076479 0.076434 0.068977 0.068843 0.068827 0.068924 0.069129
4 0.077813 0.078123 0.070098 0.070274 0.070547 0.070916 0.071379
5 0.079107 0.079747 0.071191 0.071656 0.072200 0.072824 0.073528
6 0.073647 0.074115 0.066686 0.066988 0.067374 0.067843 0.068394
7 0.074561 0.075302 0.067431 0.067974 0.068587 0.069270 0.070024
8 0.075513 0.076508 0.068215 0.068985 0.069811 0.070696 0.071643
9 0.076508 0.077745 0.069045 0.070027 0.071055 0.072132 0.073262
10 0.068215 0.069045 0.061898 0.062520 0.063197 0.063933 0.064728
11 0.068985 0.070027 0.062520 0.063332 0.064189 0.065096 0.066054
12 0.069811 0.071055 0.063197 0.064189 0.065217 0.066286 0.067400
13 0.070696 0.072132 0.063933 0.065096 0.066286 0.067511 0.068775
14 0.071643 0.073262 0.064728 0.066054 0.067400 0.068775 0.070183
1 0.084976 0.084550 0.077672 0.077490 0.077310 0.077131 0.076951
2 0.082002 0.081730 0.075070 0.074976 0.074882 0.074787 0.074688
3 0.097060 0.096700 0.090429 0.090319 0.090204 0.090081 0.089949
4 0.096570 0.096287 0.090002 0.089940 0.089872 0.089795 0.089708
5 0.095915 0.095710 0.089421 0.089408 0.089386 0.089354 0.089311
6 0.095090 0.094857 0.089826 0.089800 0.089763 0.089714 0.089653
7 0.095037 0.094849 0.089786 0.089790 0.089783 0.089763 0.089730
8 0.094941 0.094797 0.089704 0.089738 0.089760 0.089769 0.089763
9 0.094797 0.094697 0.089576 0.089639 0.089690 0.089726 0.089748
10 0.089704 0.089576 0.085655 0.085690 0.085712 0.085722 0.085716
11 0.089738 0.089639 0.085690 0.085747 0.085790 0.085819 0.085833
12 0.089760 0.089690 0.085712 0.085790 0.085853 0.085902 0.085935
13 0.089769 0.089726 0.085722 0.085819 0.085902 0.085970 0.086021
14 0.089763 0.089748 0.085716 0.085833 0.085935 0.086021 0.086092
</pre></div>
</div>
</div>
@@ -1095,10 +1115,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.032196 2.034476
1 2.034476 1.997746
[[4.0321956 2.03447649]
[2.03447649 1.99774602]]
0 3.914672 1.954823
1 1.954823 1.963858
[[3.91467223 1.95482298]
[1.95482298 1.96385798]]
</pre></div>
</div>
</div>
@@ -1125,8 +1145,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.0321956 2.03447649]
[2.03447649 1.99774602]]
[[3.91467223 1.95482298]
[1.95482298 1.96385798]]
</pre></div>
</div>
<img alt="_images/chapter8_65_1.png" src="_images/chapter8_65_1.png" />
@@ -1186,16 +1206,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.2895786617507
0.7403629637766833
5.123928000581825
0.7546022135629743
First eigenvector
[0.85064942 0.52573336]
[0.85043503 0.5260801 ]
Second eigenvector
[-0.52573336 0.85064942]
[-0.5260801 0.85043503]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Eigenvector of largest eigenvalue
[-0.85064942 -0.52573336]
[0.85043503 0.5260801 ]
</pre></div>
</div>
</div>