update on jupyter-book

This commit is contained in:
Morten Hjorth-Jensen
2024-09-17 14:17:00 +02:00
parent 999bca6d69
commit 8afe465b5f
95 changed files with 2624 additions and 1515 deletions
+74 -69
View File
@@ -293,6 +293,11 @@ const thebe_selector_output = ".output, .cell_output"
Exercises week 38
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week38.html">
Week 38: Logistic Regression and Optimization
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -706,10 +711,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.10541723644166373
4.575870409023631
[[0.84972787 2.5321613 ]
[2.5321613 8.59875207]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.14934258650797513
4.548263635652985
[[ 1.0875061 3.3260513 ]
[ 3.3260513 11.10994958]]
</pre></div>
</div>
</div>
@@ -749,10 +754,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.0768805855280187
1.6568154596723088
[[1. 0.69438869]
[0.69438869 1. ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.09291556244521161
2.096511363983559
[[1. 0.7198234]
[0.7198234 1. ]]
</pre></div>
</div>
</div>
@@ -781,30 +786,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.6629598 -6.60625144]
[-1.59424119 -4.17676247]
[ 0.13699574 -1.26680052]
[ 1.67275915 7.04206048]
[ 1.48931464 4.73718419]
[ 0.82341746 3.16411163]
[ 0.56141009 1.13137881]
[ 0.38616125 0.98338288]
[-1.28000355 -3.69734609]
[-0.53285379 -1.31095745]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[ 0.20480187 0.26586817]
[ 0.72601722 1.13675593]
[ 0.02649469 -0.9834505 ]
[ 0.97548406 1.6266783 ]
[-1.59078383 -4.25673276]
[-0.40596423 -0.31486917]
[-0.34654596 -1.94627617]
[-1.33062878 -3.73785069]
[ 2.22810365 9.25389111]
[-0.48697869 -1.04401421]]
0 1
0 -1.662960 -6.606251
1 -1.594241 -4.176762
2 0.136996 -1.266801
3 1.672759 7.042060
4 1.489315 4.737184
5 0.823417 3.164112
6 0.561410 1.131379
7 0.386161 0.983383
8 -1.280004 -3.697346
9 -0.532854 -1.310957
0 0.204802 0.265868
1 0.726017 1.136756
2 0.026495 -0.983450
3 0.975484 1.626678
4 -1.590784 -4.256733
5 -0.405964 -0.314869
6 -0.346546 -1.946276
7 -1.330629 -3.737851
8 2.228104 9.253891
9 -0.486979 -1.044014
0 1
0 1.000000 0.972149
1 0.972149 1.000000
0 1.000000 0.950423
1 0.950423 1.000000
</pre></div>
</div>
</div>
@@ -861,37 +866,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.083793 0.077516 0.081955 0.073791 0.066763 0.071803 0.064695
2 0.0 0.077516 0.074112 0.078363 0.072304 0.066838 0.070556 0.064873
3 0.0 0.081955 0.078363 0.084619 0.077941 0.071937 0.076833 0.070462
4 0.0 0.073791 0.072304 0.077941 0.073102 0.068533 0.072132 0.067141
5 0.0 0.066763 0.066838 0.071937 0.068533 0.065108 0.067671 0.063791
6 0.0 0.071803 0.070556 0.076833 0.072132 0.067671 0.071608 0.066653
7 0.0 0.064695 0.064873 0.070462 0.067141 0.063791 0.066653 0.062797
8 0.0 0.058641 0.059876 0.064878 0.062637 0.060171 0.062173 0.059201
9 0.0 0.053462 0.055477 0.059977 0.058582 0.056826 0.058133 0.055876
10 0.0 0.061862 0.062199 0.067948 0.064820 0.061637 0.064615 0.060898
11 0.0 0.056026 0.057316 0.062429 0.060312 0.057964 0.060087 0.057216
12 0.0 0.051042 0.053036 0.057609 0.056287 0.054609 0.056041 0.053854
13 0.0 0.046764 0.049276 0.053387 0.052692 0.051554 0.052427 0.050796
14 0.0 0.043072 0.045963 0.049677 0.049481 0.048781 0.049196 0.048020
1 0.0 0.072147 0.072728 0.071758 0.072209 0.072843 0.064428 0.064668
2 0.0 0.072728 0.075385 0.069979 0.071530 0.073408 0.061386 0.062260
3 0.0 0.071758 0.069979 0.076968 0.076244 0.075522 0.072286 0.071935
4 0.0 0.072209 0.071530 0.076244 0.076161 0.076150 0.070898 0.070950
5 0.0 0.072843 0.073408 0.075522 0.076150 0.076934 0.069399 0.069885
6 0.0 0.064428 0.061386 0.072286 0.070898 0.069399 0.069873 0.069179
7 0.0 0.064668 0.062260 0.071935 0.070950 0.069885 0.069179 0.068758
8 0.0 0.065062 0.063354 0.071655 0.071103 0.070514 0.068494 0.068360
9 0.0 0.065616 0.064690 0.071433 0.071356 0.071291 0.067793 0.067967
10 0.0 0.057287 0.053787 0.066153 0.064505 0.062691 0.065212 0.064382
11 0.0 0.057387 0.054286 0.065949 0.064573 0.063048 0.064834 0.064202
12 0.0 0.057607 0.054932 0.065830 0.064739 0.063518 0.064507 0.064077
13 0.0 0.057951 0.055737 0.065788 0.065001 0.064107 0.064218 0.064000
14 0.0 0.058422 0.056717 0.065818 0.065358 0.064820 0.063954 0.063959
8 9 10 11 12 13 14
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.058641 0.053462 0.061862 0.056026 0.051042 0.046764 0.043072
2 0.059876 0.055477 0.062199 0.057316 0.053036 0.049276 0.045963
3 0.064878 0.059977 0.067948 0.062429 0.057609 0.053387 0.049677
4 0.062637 0.058582 0.064820 0.060312 0.056287 0.052692 0.049481
5 0.060171 0.056826 0.061637 0.057964 0.054609 0.051554 0.048781
6 0.062173 0.058133 0.064615 0.060087 0.056041 0.052427 0.049196
7 0.059201 0.055876 0.060898 0.057216 0.053854 0.050796 0.048020
8 0.056328 0.053599 0.057420 0.054434 0.051645 0.049060 0.046678
9 0.053599 0.051368 0.054197 0.051787 0.049479 0.047299 0.045258
10 0.057420 0.054197 0.059243 0.055653 0.052370 0.049380 0.046663
11 0.054434 0.051787 0.055653 0.052738 0.050015 0.047489 0.045161
12 0.051645 0.049479 0.052370 0.050015 0.047760 0.045630 0.043637
13 0.049060 0.047299 0.049380 0.047489 0.045630 0.043839 0.042136
14 0.046678 0.045258 0.046663 0.045161 0.043637 0.042136 0.040684
1 0.065062 0.065616 0.057287 0.057387 0.057607 0.057951 0.058422
2 0.063354 0.064690 0.053787 0.054286 0.054932 0.055737 0.056717
3 0.071655 0.071433 0.066153 0.065949 0.065830 0.065788 0.065818
4 0.071103 0.071356 0.064505 0.064573 0.064739 0.065001 0.065358
5 0.070514 0.071291 0.062691 0.063048 0.063518 0.064107 0.064820
6 0.068494 0.067793 0.065212 0.064834 0.064507 0.064218 0.063954
7 0.068360 0.067967 0.064382 0.064202 0.064077 0.064000 0.063959
8 0.068268 0.068206 0.063526 0.063549 0.063637 0.063781 0.063977
9 0.068206 0.068504 0.062616 0.062853 0.063163 0.063545 0.063995
10 0.063526 0.062616 0.061724 0.061284 0.060870 0.060471 0.060071
11 0.063549 0.062853 0.061284 0.060994 0.060734 0.060490 0.060251
12 0.063637 0.063163 0.060870 0.060734 0.060629 0.060547 0.060475
13 0.063781 0.063545 0.060471 0.060490 0.060547 0.060631 0.060735
14 0.063977 0.063995 0.060071 0.060251 0.060475 0.060735 0.061025
</pre></div>
</div>
</div>
@@ -1080,10 +1085,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.986362 1.994474
1 1.994474 2.001468
[[3.98636199 1.99447418]
[1.99447418 2.00146807]]
0 3.935972 1.991047
1 1.991047 2.000783
[[3.93597168 1.99104747]
[1.99104747 2.00078324]]
</pre></div>
</div>
</div>
@@ -1110,8 +1115,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.98636199 1.99447418]
[1.99447418 2.00146807]]
[[3.93597168 1.99104747]
[1.99104747 2.00078324]]
</pre></div>
</div>
<img alt="_images/chapter8_65_1.png" src="_images/chapter8_65_1.png" />
@@ -1171,16 +1176,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.221666864828611
0.766163196245293
5.182086698929565
0.7546682196464342
First eigenvector
[0.85014487 0.52654886]
[0.84767088 0.53052247]
Second eigenvector
[-0.52654886 0.85014487]
[-0.53052247 0.84767088]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Eigenvector of largest eigenvalue
[-0.85014487 -0.52654886]
[0.84767088 0.53052247]
</pre></div>
</div>
</div>