This commit is contained in:
Morten Hjorth-Jensen
2023-08-31 06:19:44 +02:00
parent e9bac09427
commit d05f791ff6
98 changed files with 3861 additions and 2496 deletions
+28 -28
View File
@@ -249,12 +249,12 @@ const thebe_selector_output = ".output, .cell_output"
<ul class="current nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek34.html">
19. Exercises week 34
Exercises week 34
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week34.html">
20. Week 34: Introduction to the course, Logistics and Practicalities
Week 34: Introduction to the course, Logistics and Practicalities
</a>
</li>
<li class="toctree-l1">
@@ -1611,7 +1611,7 @@ Since we are not using <strong>Scikit-Learn</strong> here we can define our own
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.9963864072152893
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.9959898232423614
</pre></div>
</div>
</div>
@@ -1628,7 +1628,7 @@ Since we are not using <strong>Scikit-Learn</strong> here we can define our own
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.008435888964550838
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.008278885543361304
</pre></div>
</div>
</div>
@@ -1643,23 +1643,23 @@ Since we are not using <strong>Scikit-Learn</strong> here we can define our own
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[0.00168141 0.0025074 0.01497781 0.06168748 0.04101587 0.03079528
0.0211496 0.04046799 0.00054272 0.01029589 0.02442398 0.04419696
0.02566258 0.00868337 0.02649453 0.00147197 0.00546438 0.00233441
0.01990155 0.00808144 0.00681644 0.07093644 0.01693 0.00965032
0.00287154 0.00758025 0.02521597 0.00057106 0.01550656 0.04495095
0.03995478 0.01056549 0.00820764 0.00089459 0.02082761 0.03583342
0.01907538 0.00018425 0.02539993 0.02166269 0.0035417 0.0025125
0.01742183 0.01586048 0.03791967 0.02344111 0.02195273 0.03500198
0.01539 0.01176895 0.02868501 0.00201915 0.01588619 0.00754532
0.01135107 0.01242803 0.06121384 0.01678286 0.05855607 0.02206138
0.06031681 0.00523269 0.00911938 0.06038053 0.01957153 0.00449439
0.00191249 0.01152107 0.02335522 0.04573105 0.02612167 0.010154
0.00867698 0.0814721 0.01693278 0.01844381 0.00781035 0.01725808
0.00645183 0.00054144 0.00452742 0.00406231 0.01619802 0.01073921
0.00074389 0.07943621 0.01788423 0.04637311 0.0348171 0.00689391
0.04087592 0.09631112 0.03634298 0.04516608 0.0183718 0.01817919
0.07297557 0.00578738 0.00465403 0.00174508]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[0.02970592 0.01381723 0.01572164 0.02401344 0.06008452 0.0084603
0.00506501 0.08734015 0.00145838 0.00779538 0.00046714 0.02971158
0.02263868 0.02541796 0.02724253 0.04120281 0.00578776 0.01574375
0.08923158 0.03510756 0.00373019 0.03206303 0.02008059 0.03533092
0.01558461 0.00733497 0.01770163 0.03026672 0.05698425 0.02766981
0.02421521 0.00943261 0.00207627 0.03352725 0.00139198 0.00770648
0.03078597 0.00355175 0.00432302 0.04554454 0.05892262 0.0097018
0.04100738 0.03232013 0.02747522 0.04208001 0.00252344 0.03080664
0.00437363 0.01614046 0.00158723 0.01471878 0.03235599 0.01285424
0.01494533 0.01006893 0.01248731 0.0317159 0.02226654 0.0189082
0.01923991 0.01816821 0.02900131 0.0123679 0.08684675 0.00934728
0.04331431 0.01574091 0.00017471 0.0164286 0.00118368 0.00839839
0.00548686 0.02596838 0.02058701 0.00661104 0.02708158 0.03187054
0.0171347 0.04573057 0.04735806 0.00131939 0.00704468 0.02422503
0.02818883 0.003738 0.02212893 0.00732273 0.02212776 0.0202731
0.0214539 0.02712723 0.02200044 0.01588614 0.03610331 0.02808201
0.00801078 0.01885351 0.00458671 0.01133171]
</pre></div>
</div>
</div>
@@ -1728,15 +1728,15 @@ but now splitting the data into a training set and a test set.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[ 2.03739357 -0.54302039 7.21493572 -3.15550086 1.44651551]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[ 2.00025531 0.8850944 -0.44894073 10.27580794 -5.9383327 ]
Training R2
0.9973102337301051
0.9960039497353536
Training MSE
0.006158537606875468
0.007839875253055148
Test R2
0.9954911579937146
0.9962074631757628
Test MSE
0.010751622516868333
0.006275173922218319
</pre></div>
</div>
</div>
@@ -3510,7 +3510,7 @@ least squares is proportional to the second derivative of the cost
function, that is we have</p>
<div class="math notranslate nohighlight">
\[
\frac{\partial^2 C(\boldsymbol{\beta})}{\partial \boldsymbol{\beta}^T\partial \boldsymbol{\beta}} =\frac{2}{n}\boldsymbol{X}^T\boldsymbol{X}.
\frac{\partial^2 C(\boldsymbol{\beta})}{\partial \boldsymbol{\beta}\partial \boldsymbol{\beta}^T} =\frac{2}{n}\boldsymbol{X}^T\boldsymbol{X}.
\]</div>
<p>This quantity defines was what is called the Hessian matrix (the second derivative of a function we want to optimize).</p>
<p>The Hessian matrix plays an important role and is defined in this course as</p>
@@ -3558,7 +3558,7 @@ with a factor <span class="math notranslate nohighlight">\(1/(n-1)\)</span>. Thi
method corrects the bias in the estimation of the population variance
and covariance. It also partially corrects the bias in the estimation
of the population standard deviation. If you use a library like
<strong>Scikit-Learn</strong> or <strong>nunmpys</strong> function calculate the covariance, this
<strong>Scikit-Learn</strong> or <strong>nunmpys</strong> function to calculate the covariance, this
quantity will be computed with a factor <span class="math notranslate nohighlight">\(1/(n-1)\)</span>.</p>
</div>
<div class="section" id="covariance-and-correlation-matrix">