This commit is contained in:
Morten Hjorth-Jensen
2024-08-18 22:06:49 +02:00
parent a0f947eef0
commit 1888e0775c
38 changed files with 13132 additions and 4955 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "241c4a61",
"id": "72dc0997",
"metadata": {
"editable": true
},
@@ -14,7 +14,7 @@
},
{
"cell_type": "markdown",
"id": "a33815b9",
"id": "8c591125",
"metadata": {
"editable": true
},
@@ -22,12 +22,12 @@
"# Exercises week 34\n",
"**FYS-STK3155/4155**\n",
"\n",
"Date: **August 21-25, 2023**"
"Date: **August 19-23, 2024**"
]
},
{
"cell_type": "markdown",
"id": "2990585c",
"id": "1ad21876",
"metadata": {
"editable": true
},
@@ -39,7 +39,7 @@
},
{
"cell_type": "markdown",
"id": "be056de0",
"id": "4eaa91e2",
"metadata": {
"editable": true
},
@@ -108,7 +108,7 @@
},
{
"cell_type": "markdown",
"id": "f0f4ffae",
"id": "360adb56",
"metadata": {
"editable": true
},
@@ -122,7 +122,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "93d6a2b2",
"id": "278aa34f",
"metadata": {
"collapsed": false,
"editable": true
@@ -135,7 +135,7 @@
},
{
"cell_type": "markdown",
"id": "45392145",
"id": "1ff20e45",
"metadata": {
"editable": true
},
@@ -149,7 +149,7 @@
},
{
"cell_type": "markdown",
"id": "3eed315b",
"id": "e8809de1",
"metadata": {
"editable": true
},
@@ -162,7 +162,7 @@
},
{
"cell_type": "markdown",
"id": "26038071",
"id": "8c9e5277",
"metadata": {
"editable": true
},
@@ -173,7 +173,7 @@
},
{
"cell_type": "markdown",
"id": "4c750d55",
"id": "85a5881c",
"metadata": {
"editable": true
},
@@ -185,7 +185,7 @@
},
{
"cell_type": "markdown",
"id": "30b4731e",
"id": "4fb35d0d",
"metadata": {
"editable": true
},
@@ -195,7 +195,7 @@
},
{
"cell_type": "markdown",
"id": "49afe51d",
"id": "608f9780",
"metadata": {
"editable": true
},
@@ -207,7 +207,7 @@
},
{
"cell_type": "markdown",
"id": "81f16b80",
"id": "014bbc09",
"metadata": {
"editable": true
},
@@ -218,7 +218,7 @@
},
{
"cell_type": "markdown",
"id": "cb71cb1c",
"id": "f28863ad",
"metadata": {
"editable": true
},
@@ -237,7 +237,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "b8c919e5",
"id": "85f75a99",
"metadata": {
"collapsed": false,
"editable": true
@@ -253,7 +253,7 @@
},
{
"cell_type": "markdown",
"id": "50629e14",
"id": "bee8d814",
"metadata": {
"editable": true
},
@@ -263,7 +263,7 @@
},
{
"cell_type": "markdown",
"id": "0578f08c",
"id": "7c94f8bd",
"metadata": {
"editable": true
},
@@ -274,7 +274,7 @@
},
{
"cell_type": "markdown",
"id": "125ec9a1",
"id": "c0e789dd",
"metadata": {
"editable": true
},
@@ -286,7 +286,7 @@
},
{
"cell_type": "markdown",
"id": "e5bb2036",
"id": "5ee1d70e",
"metadata": {
"editable": true
},
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "053b96d5",
"id": "a15180da",
"metadata": {
"editable": true
},
@@ -14,20 +14,20 @@
},
{
"cell_type": "markdown",
"id": "a09cb811",
"id": "ac77b923",
"metadata": {
"editable": true
},
"source": [
"# Exercises week 35\n",
"**August 28-September 1, 2023**\n",
"**August 26-30, 2024**\n",
"\n",
"Date: **Deadline is Friday September 1 at midnight**"
"Date: **Deadline is Friday August 30 at midnight**"
]
},
{
"cell_type": "markdown",
"id": "8e83839e",
"id": "e8b90270",
"metadata": {
"editable": true
},
@@ -49,7 +49,7 @@
},
{
"cell_type": "markdown",
"id": "fe2b1c49",
"id": "2e2e8f1a",
"metadata": {
"editable": true
},
@@ -61,7 +61,7 @@
},
{
"cell_type": "markdown",
"id": "259f2ad1",
"id": "1cdc68da",
"metadata": {
"editable": true
},
@@ -71,7 +71,7 @@
},
{
"cell_type": "markdown",
"id": "5ac63202",
"id": "b87f9fdd",
"metadata": {
"editable": true
},
@@ -83,7 +83,7 @@
},
{
"cell_type": "markdown",
"id": "a52c6353",
"id": "6ab53932",
"metadata": {
"editable": true
},
@@ -93,7 +93,7 @@
},
{
"cell_type": "markdown",
"id": "910282dd",
"id": "1a7a8ec2",
"metadata": {
"editable": true
},
@@ -105,7 +105,7 @@
},
{
"cell_type": "markdown",
"id": "f3d0f2f5",
"id": "3bdb1514",
"metadata": {
"editable": true
},
@@ -120,7 +120,7 @@
},
{
"cell_type": "markdown",
"id": "5fe4bc49",
"id": "3e54eca9",
"metadata": {
"editable": true
},
@@ -132,7 +132,7 @@
},
{
"cell_type": "markdown",
"id": "55fee214",
"id": "3db49a1c",
"metadata": {
"editable": true
},
@@ -142,7 +142,7 @@
},
{
"cell_type": "markdown",
"id": "92b0b614",
"id": "5d4d3a0e",
"metadata": {
"editable": true
},
@@ -154,7 +154,7 @@
},
{
"cell_type": "markdown",
"id": "6b68973e",
"id": "90eecd1c",
"metadata": {
"editable": true
},
@@ -164,7 +164,7 @@
},
{
"cell_type": "markdown",
"id": "89e679e8",
"id": "7eb7605f",
"metadata": {
"editable": true
},
@@ -176,7 +176,7 @@
},
{
"cell_type": "markdown",
"id": "a35b6ab2",
"id": "b30dd90f",
"metadata": {
"editable": true
},
@@ -186,7 +186,7 @@
},
{
"cell_type": "markdown",
"id": "747d2724",
"id": "1167ec1f",
"metadata": {
"editable": true
},
@@ -198,7 +198,7 @@
},
{
"cell_type": "markdown",
"id": "911dc89a",
"id": "8f309e9e",
"metadata": {
"editable": true
},
@@ -216,7 +216,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "09971906",
"id": "2df1063f",
"metadata": {
"collapsed": false,
"editable": true
@@ -230,7 +230,7 @@
},
{
"cell_type": "markdown",
"id": "de82ebe8",
"id": "0cb75ec5",
"metadata": {
"editable": true
},
@@ -244,7 +244,7 @@
},
{
"cell_type": "markdown",
"id": "21b2c91f",
"id": "f0c36bdb",
"metadata": {
"editable": true
},
@@ -257,7 +257,7 @@
},
{
"cell_type": "markdown",
"id": "3b542aa1",
"id": "8c3ce778",
"metadata": {
"editable": true
},
@@ -268,7 +268,7 @@
},
{
"cell_type": "markdown",
"id": "5393a93f",
"id": "f861d243",
"metadata": {
"editable": true
},
@@ -280,7 +280,7 @@
},
{
"cell_type": "markdown",
"id": "df1b8e23",
"id": "51500e4b",
"metadata": {
"editable": true
},
@@ -290,7 +290,7 @@
},
{
"cell_type": "markdown",
"id": "30ad9bb6",
"id": "fda9dadd",
"metadata": {
"editable": true
},
@@ -302,7 +302,7 @@
},
{
"cell_type": "markdown",
"id": "0e2c0d15",
"id": "6b691499",
"metadata": {
"editable": true
},
@@ -313,7 +313,7 @@
},
{
"cell_type": "markdown",
"id": "80eab896",
"id": "b6f10ab9",
"metadata": {
"editable": true
},
@@ -333,7 +333,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "887378fa",
"id": "285159ae",
"metadata": {
"collapsed": false,
"editable": true
@@ -349,7 +349,7 @@
},
{
"cell_type": "markdown",
"id": "a059a330",
"id": "c2840fc9",
"metadata": {
"editable": true
},
@@ -359,7 +359,7 @@
},
{
"cell_type": "markdown",
"id": "e2614fe9",
"id": "9dbda275",
"metadata": {
"editable": true
},
@@ -370,7 +370,7 @@
},
{
"cell_type": "markdown",
"id": "8522c8f4",
"id": "824dba6f",
"metadata": {
"editable": true
},
@@ -382,7 +382,7 @@
},
{
"cell_type": "markdown",
"id": "c4e99901",
"id": "a3f059cf",
"metadata": {
"editable": true
},
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -268,123 +268,6 @@ const thebe_selector_output = ".output, .cell_output"
Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek36.html">
Exercises week 36
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week36.html">
Week 36: Statistical interpretation of Linear Regression and Resampling techniques
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek37.html">
Exercises week 37
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week37.html">
Week 37: Statistical interpretations and Resampling Methods
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek38.html">
Exercises week 38
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week38.html">
Week 38: Logistic Regression and Optimization
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek39.html">
Exercises week 39
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week39.html">
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>
<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>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek43.html">
Exercises weeks 43 and 44
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week43.html">
Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations
</a>
</li>
<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, Recurrent Neural Networks
</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 and Summary of Course
</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">
<li class="toctree-l1">
<a class="reference internal" href="project1.html">
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 17 (Midnight)
</a>
</li>
</ul>
</div>
@@ -530,7 +413,7 @@ doconce format html exercisesweek34.do.txt -->
<!-- dom:TITLE: Exercises week 34 --><div class="tex2jax_ignore mathjax_ignore section" id="exercises-week-34">
<h1>Exercises week 34<a class="headerlink" href="#exercises-week-34" title="Permalink to this headline"></a></h1>
<p><strong>FYS-STK3155/4155</strong></p>
<p>Date: <strong>August 21-25, 2023</strong></p>
<p>Date: <strong>August 19-23, 2024</strong></p>
<div class="section" id="exercises">
<h2>Exercises<a class="headerlink" href="#exercises" title="Permalink to this headline"></a></h2>
<p>Here are three possible exercises for week 34</p>
@@ -605,7 +488,7 @@ The following simple Python instructions define our <span class="math notranslat
<div class="cell_output docutils container">
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span><span class="gt">---------------------------------------------------------------------------</span>
<span class="ne">NameError</span><span class="g g-Whitespace"> </span>Traceback (most recent call last)
<span class="nn">Input In [1],</span> in <span class="ni">&lt;cell line: 1&gt;</span><span class="nt">()</span>
<span class="n">Cell</span> <span class="n">In</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">line</span> <span class="mi">1</span>
<span class="ne">----&gt; </span><span class="mi">1</span> <span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">rand</span><span class="p">(</span><span class="mi">100</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
<span class="g g-Whitespace"> </span><span class="mi">2</span> <span class="n">y</span> <span class="o">=</span> <span class="mf">2.0</span><span class="o">+</span><span class="mi">5</span><span class="o">*</span><span class="n">x</span><span class="o">*</span><span class="n">x</span><span class="o">+</span><span class="mf">0.1</span><span class="o">*</span><span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="mi">100</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
@@ -268,123 +268,6 @@ const thebe_selector_output = ".output, .cell_output"
Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek36.html">
Exercises week 36
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week36.html">
Week 36: Statistical interpretation of Linear Regression and Resampling techniques
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek37.html">
Exercises week 37
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week37.html">
Week 37: Statistical interpretations and Resampling Methods
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek38.html">
Exercises week 38
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week38.html">
Week 38: Logistic Regression and Optimization
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek39.html">
Exercises week 39
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week39.html">
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>
<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>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek43.html">
Exercises weeks 43 and 44
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week43.html">
Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations
</a>
</li>
<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, Recurrent Neural Networks
</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 and Summary of Course
</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">
<li class="toctree-l1">
<a class="reference internal" href="project1.html">
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 17 (Midnight)
</a>
</li>
</ul>
</div>
@@ -519,8 +402,8 @@ const thebe_selector_output = ".output, .cell_output"
doconce format html exercisesweek35.do.txt -->
<!-- dom:TITLE: Exercises week 35 --><div class="tex2jax_ignore mathjax_ignore section" id="exercises-week-35">
<h1>Exercises week 35<a class="headerlink" href="#exercises-week-35" title="Permalink to this headline"></a></h1>
<p><strong>August 28-September 1, 2023</strong></p>
<p>Date: <strong>Deadline is Friday September 1 at midnight</strong></p>
<p><strong>August 26-30, 2024</strong></p>
<p>Date: <strong>Deadline is Friday August 30 at midnight</strong></p>
<div class="section" id="exercise-1-analytical-exercises">
<h2>Exercise 1: Analytical exercises<a class="headerlink" href="#exercise-1-analytical-exercises" title="Permalink to this headline"></a></h2>
<p>In this exercise we derive the expressions for various derivatives of
-117
View File
@@ -264,123 +264,6 @@ const thebe_selector_output = ".output, .cell_output"
Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek36.html">
Exercises week 36
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week36.html">
Week 36: Statistical interpretation of Linear Regression and Resampling techniques
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek37.html">
Exercises week 37
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week37.html">
Week 37: Statistical interpretations and Resampling Methods
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek38.html">
Exercises week 38
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week38.html">
Week 38: Logistic Regression and Optimization
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek39.html">
Exercises week 39
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week39.html">
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>
<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>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek43.html">
Exercises weeks 43 and 44
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week43.html">
Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations
</a>
</li>
<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, Recurrent Neural Networks
</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 and Summary of Course
</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">
<li class="toctree-l1">
<a class="reference internal" href="project1.html">
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 17 (Midnight)
</a>
</li>
</ul>
</div>
-119
View File
@@ -265,123 +265,6 @@ const thebe_selector_output = ".output, .cell_output"
Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek36.html">
Exercises week 36
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week36.html">
Week 36: Statistical interpretation of Linear Regression and Resampling techniques
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek37.html">
Exercises week 37
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week37.html">
Week 37: Statistical interpretations and Resampling Methods
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek38.html">
Exercises week 38
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week38.html">
Week 38: Logistic Regression and Optimization
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek39.html">
Exercises week 39
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week39.html">
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>
<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>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek43.html">
Exercises weeks 43 and 44
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week43.html">
Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations
</a>
</li>
<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, Recurrent Neural Networks
</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 and Summary of Course
</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">
<li class="toctree-l1">
<a class="reference internal" href="project1.html">
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 17 (Midnight)
</a>
</li>
</ul>
</div>
@@ -736,8 +619,6 @@ It provides composable transformations of Python+NumPy programs: differentiate,
</div>
<div class="toctree-wrapper compound">
</div>
<div class="toctree-wrapper compound">
</div>
</div>
<script type="text/x-thebe-config">
Binary file not shown.
@@ -7,7 +7,7 @@ Traceback (most recent call last):
return just_run(coro(*args, **kwargs))
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
return loop.run_until_complete(coro)
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
await self.async_execute_cell(
@@ -23,7 +23,7 @@ y = 2.0+5*x*x+0.1*np.random.randn(100,1)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [1], in <cell line: 1>()
Cell In[1], line 1
----> 1 x = np.random.rand(100,1)
 2 y = 2.0+5*x*x+0.1*np.random.randn(100,1)
+23 -48
View File
@@ -7,7 +7,7 @@ Traceback (most recent call last):
return just_run(coro(*args, **kwargs))
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
return loop.run_until_complete(coro)
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
await self.async_execute_cell(
@@ -17,55 +17,30 @@ Traceback (most recent call last):
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
------------------
# Read the experimental data with Pandas
Masses = pd.read_fwf(infile, usecols=(2,3,4,6,11),
names=('N', 'Z', 'A', 'Element', 'Ebinding'),
widths=(1,3,5,5,5,1,3,4,1,13,11,11,9,1,2,11,9,1,3,1,12,11,1),
header=39,
index_col=False)
# Extrapolated values are indicated by '#' in place of the decimal place, so
# the Ebinding column won't be numeric. Coerce to float and drop these entries.
Masses['Ebinding'] = pd.to_numeric(Masses['Ebinding'], errors='coerce')
Masses = Masses.dropna()
# Convert from keV to MeV.
Masses['Ebinding'] /= 1000
# Group the DataFrame by nucleon number, A.
Masses = Masses.groupby('A')
# Find the rows of the grouped DataFrame with the maximum binding energy.
Masses = Masses.apply(lambda t: t[t.Ebinding==t.Ebinding.max()])
new_hobbit = {'First Name': ["Peregrin"],
'Last Name': ["Took"],
'Place of birth': ["Shire"],
'Date of Birth T.A.': [2990]
}
data_pandas=data_pandas.append(pd.DataFrame(new_hobbit, index=['Pippin']))
display(data_pandas)
------------------
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Input In [30], in <cell line: 2>()
 1 # Read the experimental data with Pandas
----> 2 Masses = pd.read_fwf(infile, usecols=(2,3,4,6,11),
 3  names=('N', 'Z', 'A', 'Element', 'Ebinding'),
 4  widths=(1,3,5,5,5,1,3,4,1,13,11,11,9,1,2,11,9,1,3,1,12,11,1),
 5  header=39,
 6  index_col=False)
 8 # Extrapolated values are indicated by '#' in place of the decimal place, so
 9 # the Ebinding column won't be numeric. Coerce to float and drop these entries.
 10 Masses['Ebinding'] = pd.to_numeric(Masses['Ebinding'], errors='coerce')
AttributeError Traceback (most recent call last)
/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_12649/1326197715.py in ?()
----> 6 new_hobbit = {'First Name': ["Peregrin"],
 7 'Last Name': ["Took"],
 8 'Place of birth': ["Shire"],
 9 'Date of Birth T.A.': [2990]
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/pandas/util/_decorators.py:311, in deprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper(*args, **kwargs)
 305 if len(args) > num_allow_args:
 306 warnings.warn(
 307 msg.format(arguments=arguments),
 308 FutureWarning,
 309 stacklevel=stacklevel,
 310 )
--> 311 return func(*args, **kwargs)
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/pandas/io/parsers/readers.py:871, in read_fwf(filepath_or_buffer, colspecs, widths, infer_nrows, **kwds)
 869 len_index = len(index_col)
 870 if len(names) + len_index != len(colspecs):
--> 871 raise ValueError("Length of colspecs must match length of names")
 873 kwds["colspecs"] = colspecs
 874 kwds["infer_nrows"] = infer_nrows
ValueError: Length of colspecs must match length of names
ValueError: Length of colspecs must match length of names
~/miniforge3/envs/myenv/lib/python3.9/site-packages/pandas/core/generic.py in ?(self, name)
 6200 and name not in self._accessors
 6201 and self._info_axis._can_hold_identifiers_and_holds_name(name)
 6202 ):
 6203 return self[name]
-> 6204 return object.__getattribute__(self, name)

AttributeError: 'DataFrame' object has no attribute 'append'
AttributeError: 'DataFrame' object has no attribute 'append'
+122 -9
View File
@@ -7,7 +7,7 @@ Traceback (most recent call last):
return just_run(coro(*args, **kwargs))
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
return loop.run_until_complete(coro)
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
await self.async_execute_cell(
@@ -17,16 +17,129 @@ Traceback (most recent call last):
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
------------------
fit = np.linalg.lstsq(X, Energies, rcond =None)[0]
ytildenp = np.dot(fit,X.T)
from sklearn.datasets import load_boston
boston_dataset = load_boston()
# boston_dataset is a dictionary
# let's check what it contains
boston_dataset.keys()
------------------
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 fit = np.linalg.lstsq(X, Energies, rcond =None)[0]
 2 ytildenp = np.dot(fit,X.T)
ImportError Traceback (most recent call last)
Cell In[16], line 1
----> 1 from sklearn.datasets import load_boston
 3 boston_dataset = load_boston()
 5 # boston_dataset is a dictionary
 6 # let's check what it contains
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/datasets/__init__.py:157, in __getattr__(name)
 108 if name == "load_boston":
 109 msg = textwrap.dedent("""
 110  `load_boston` has been removed from scikit-learn since version 1.2.
 111
 (...)
 155  <https://www.researchgate.net/publication/4974606_Hedonic_housing_prices_and_the_demand_for_clean_air>
 156  """)
--> 157 raise ImportError(msg)
 158 try:
 159 return globals()[name]
ImportError:
`load_boston` has been removed from scikit-learn since version 1.2.
The Boston housing prices dataset has an ethical problem: as
investigated in [1], the authors of this dataset engineered a
non-invertible variable "B" assuming that racial self-segregation had a
positive impact on house prices [2]. Furthermore the goal of the
research that led to the creation of this dataset was to study the
impact of air quality but it did not give adequate demonstration of the
validity of this assumption.
The scikit-learn maintainers therefore strongly discourage the use of
this dataset unless the purpose of the code is to study and educate
about ethical issues in data science and machine learning.
In this special case, you can fetch the dataset from the original
source::
import pandas as pd
import numpy as np
data_url = "http://lib.stat.cmu.edu/datasets/boston"
raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None)
data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])
target = raw_df.values[1::2, 2]
Alternative datasets include the California housing dataset and the
Ames housing dataset. You can load the datasets as follows::
from sklearn.datasets import fetch_california_housing
housing = fetch_california_housing()
for the California housing dataset and::
from sklearn.datasets import fetch_openml
housing = fetch_openml(name="house_prices", as_frame=True)
for the Ames housing dataset.
[1] M Carlisle.
"Racist data destruction?"
<https://medium.com/@docintangible/racist-data-destruction-113e3eff54a8>
[2] Harrison Jr, David, and Daniel L. Rubinfeld.
"Hedonic housing prices and the demand for clean air."
Journal of environmental economics and management 5.1 (1978): 81-102.
<https://www.researchgate.net/publication/4974606_Hedonic_housing_prices_and_the_demand_for_clean_air>
ImportError:
`load_boston` has been removed from scikit-learn since version 1.2.
The Boston housing prices dataset has an ethical problem: as
investigated in [1], the authors of this dataset engineered a
non-invertible variable "B" assuming that racial self-segregation had a
positive impact on house prices [2]. Furthermore the goal of the
research that led to the creation of this dataset was to study the
impact of air quality but it did not give adequate demonstration of the
validity of this assumption.
The scikit-learn maintainers therefore strongly discourage the use of
this dataset unless the purpose of the code is to study and educate
about ethical issues in data science and machine learning.
In this special case, you can fetch the dataset from the original
source::
import pandas as pd
import numpy as np
data_url = "http://lib.stat.cmu.edu/datasets/boston"
raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None)
data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])
target = raw_df.values[1::2, 2]
Alternative datasets include the California housing dataset and the
Ames housing dataset. You can load the datasets as follows::
from sklearn.datasets import fetch_california_housing
housing = fetch_california_housing()
for the California housing dataset and::
from sklearn.datasets import fetch_openml
housing = fetch_openml(name="house_prices", as_frame=True)
for the Ames housing dataset.
[1] M Carlisle.
"Racist data destruction?"
<https://medium.com/@docintangible/racist-data-destruction-113e3eff54a8>
[2] Harrison Jr, David, and Daniel L. Rubinfeld.
"Hedonic housing prices and the demand for clean air."
Journal of environmental economics and management 5.1 (1978): 81-102.
<https://www.researchgate.net/publication/4974606_Hedonic_housing_prices_and_the_demand_for_clean_air>
NameError: name 'Energies' is not defined
NameError: name 'Energies' is not defined
-117
View File
@@ -270,123 +270,6 @@ const thebe_selector_output = ".output, .cell_output"
Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek36.html">
Exercises week 36
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week36.html">
Week 36: Statistical interpretation of Linear Regression and Resampling techniques
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek37.html">
Exercises week 37
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week37.html">
Week 37: Statistical interpretations and Resampling Methods
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek38.html">
Exercises week 38
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week38.html">
Week 38: Logistic Regression and Optimization
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek39.html">
Exercises week 39
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week39.html">
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>
<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>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek43.html">
Exercises weeks 43 and 44
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week43.html">
Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations
</a>
</li>
<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, Recurrent Neural Networks
</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 and Summary of Course
</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">
<li class="toctree-l1">
<a class="reference internal" href="project1.html">
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 17 (Midnight)
</a>
</li>
</ul>
</div>
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+83 -343
View File
@@ -55,7 +55,6 @@ const thebe_selector_output = ".output, .cell_output"
<script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Exercises week 36" href="exercisesweek36.html" />
<link rel="prev" title="Exercises week 35" href="exercisesweek35.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="None">
@@ -268,123 +267,6 @@ const thebe_selector_output = ".output, .cell_output"
Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek36.html">
Exercises week 36
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week36.html">
Week 36: Statistical interpretation of Linear Regression and Resampling techniques
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek37.html">
Exercises week 37
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week37.html">
Week 37: Statistical interpretations and Resampling Methods
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek38.html">
Exercises week 38
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week38.html">
Week 38: Logistic Regression and Optimization
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek39.html">
Exercises week 39
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week39.html">
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>
<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>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek43.html">
Exercises weeks 43 and 44
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week43.html">
Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations
</a>
</li>
<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, Recurrent Neural Networks
</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 and Summary of Course
</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">
<li class="toctree-l1">
<a class="reference internal" href="project1.html">
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 17 (Midnight)
</a>
</li>
</ul>
</div>
@@ -1240,7 +1122,7 @@ doconce format html week35.do.txt --no_mako -->
<!-- dom:TITLE: Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression --><div class="tex2jax_ignore mathjax_ignore section" id="week-35-from-ordinary-linear-regression-to-ridge-and-lasso-regression">
<h1>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression<a class="headerlink" href="#week-35-from-ordinary-linear-regression-to-ridge-and-lasso-regression" title="Permalink to this headline"></a></h1>
<p><strong>Morten Hjorth-Jensen</strong>, Department of Physics, University of Oslo and Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</p>
<p>Date: <strong>August 28-September 1</strong></p>
<p>Date: <strong>August 26-30</strong></p>
<div class="section" id="plans-for-week-35">
<h2>Plans for week 35<a class="headerlink" href="#plans-for-week-35" title="Permalink to this headline"></a></h2>
<p>The main topics are:</p>
@@ -1248,17 +1130,14 @@ doconce format html week35.do.txt --no_mako -->
<li><p>Brief repetition from last week</p></li>
<li><p>Derivation of the equations for ordinary least squares</p></li>
<li><p>Discussion on how to prepare data and examples of applications of linear regression</p></li>
<li><p>Material for the lecture on Thursday: Mathematical interpretations of linear regression</p></li>
<li><p>Thursday: Ridge and Lasso regression and Singular Value Decomposition</p></li>
<li><p><a class="reference external" href="https://youtu.be/qBNm-HGSxL4">Video of lecture</a></p></li>
<li><p><a class="reference external" href="https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2023/NotesAug31.pdf">Whiteboard notes</a></p></li>
<li><p>Material for the lecture on Monday: Mathematical interpretations of linear regression</p></li>
<li><p>Monday: Ridge and Lasso regression and Singular Value Decomposition</p></li>
</ol>
<div class="section" id="reading-recommendations">
<h3>Reading recommendations:<a class="headerlink" href="#reading-recommendations" title="Permalink to this headline"></a></h3>
<ol class="simple">
<li><p>See lecture notes for week 35 at <a class="reference external" href="https://compphysics.github.io/MachineLearning/doc/web/course.html">https://compphysics.github.io/MachineLearning/doc/web/course.html</a></p></li>
<li><p>Goodfellow, Bengio and Courville, Deep Learning, chapter 2 on linear algebra and sections 3.1-3.10 on elements of statistics (background)</p></li>
<li><p>Hastie, Tibshirani and Friedman, The elements of statistical learning, sections 3.1-3.4 (on relevance for the discussion of linear regression).</p></li>
</ol>
</div>
</div>
@@ -1731,7 +1610,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.9958946686888259
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.9952638231265687
</pre></div>
</div>
</div>
@@ -1748,7 +1627,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.008142188979400687
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.011761161707539526
</pre></div>
</div>
</div>
@@ -1763,23 +1642,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.0476021 0.02689869 0.01088331 0.01783105 0.00544013 0.05110385
0.02900389 0.01629703 0.05594058 0.02527366 0.00657884 0.04127087
0.01925607 0.02221978 0.01212083 0.04919181 0.00745959 0.03110176
0.010203 0.0076995 0.00298213 0.01702968 0.04557362 0.03192124
0.06668218 0.0178392 0.00706728 0.0095239 0.00784983 0.05197707
0.01519861 0.0134093 0.00291822 0.00311528 0.02036289 0.01136976
0.0189559 0.04908155 0.01384493 0.01715895 0.01262581 0.00756465
0.00473818 0.00224783 0.01773579 0.03804636 0.03945128 0.01662346
0.05137822 0.00206124 0.06090176 0.01632212 0.01220987 0.06361921
0.00318122 0.00362359 0.03177421 0.06554078 0.00123144 0.01091059
0.04958045 0.00291334 0.01541622 0.00607264 0.05274561 0.007352
0.06263415 0.01593612 0.00853836 0.01006042 0.00223784 0.02106518
0.02410507 0.08294341 0.0043675 0.06502562 0.03422156 0.00213264
0.02365779 0.01883403 0.00683222 0.01848399 0.02930957 0.02161016
0.02746315 0.02774744 0.03591454 0.04814746 0.00568413 0.00215333
0.03631783 0.02866734 0.01684326 0.00953152 0.01001378 0.00119895
0.02603725 0.00127672 0.04770636 0.028797 ]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[0.00035753 0.04937621 0.02268114 0.03112297 0.01856502 0.05322899
0.01397927 0.03999935 0.02508836 0.01834042 0.0652633 0.00887114
0.01956921 0.01987248 0.06294313 0.01152476 0.00328431 0.03564082
0.02337045 0.01743586 0.01278035 0.02400968 0.08388138 0.03270341
0.00335956 0.01031903 0.09575469 0.00956774 0.00900879 0.01867985
0.01191227 0.02090296 0.04045671 0.03582958 0.06692165 0.06615863
0.06594872 0.03756493 0.00488992 0.01405237 0.00117071 0.0017567
0.05006306 0.02545639 0.03456485 0.00373984 0.02576476 0.03530741
0.00092902 0.0275742 0.05948007 0.01321652 0.18500705 0.00382166
0.00327313 0.01853877 0.01771317 0.05293662 0.07199977 0.00836148
0.01541649 0.00343257 0.00626797 0.05350297 0.01548272 0.05235058
0.04310698 0.00225189 0.02356396 0.01690512 0.03467756 0.00064364
0.02593596 0.00019607 0.0029508 0.0180194 0.06825695 0.01659559
0.01971341 0.02012338 0.02241311 0.00135736 0.0095653 0.05695438
0.00395659 0.07068033 0.02699873 0.00919237 0.02493299 0.00803115
0.0293055 0.02178063 0.00594353 0.04081883 0.01325225 0.0386443
0.01889695 0.02810253 0.0181166 0.01135924]
</pre></div>
</div>
</div>
@@ -1848,15 +1727,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.02283241 0.15972118 3.84256187 1.89005305 -0.93145755]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[ 2.00507876 0.39026883 3.20764972 2.73806921 -1.39609089]
Training R2
0.9959044445566834
0.9972493421341901
Training MSE
0.010349061754867921
0.007021475481484069
Test R2
0.9961996615568259
0.9976639055733267
Test MSE
0.008771887357306985
0.00575158411598985
</pre></div>
</div>
</div>
@@ -2903,45 +2782,73 @@ the house using the features (predictors) listed here.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function load_boston is deprecated; `load_boston` is deprecated in 1.0 and will be removed in 1.2.
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span>---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[16], line 1
----&gt; 1 from sklearn.datasets import load_boston
3 boston_dataset = load_boston()
5 # boston_dataset is a dictionary
6 # let&#39;s check what it contains
The Boston housing prices dataset has an ethical problem. You can refer to
the documentation of this function for further details.
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/sklearn/datasets/__init__.py:157, in __getattr__(name)
108 if name == &quot;load_boston&quot;:
109 msg = textwrap.dedent(&quot;&quot;&quot;
110 `load_boston` has been removed from scikit-learn since version 1.2.
111
(...)
155 &lt;https://www.researchgate.net/publication/4974606_Hedonic_housing_prices_and_the_demand_for_clean_air&gt;
156 &quot;&quot;&quot;)
--&gt; 157 raise ImportError(msg)
158 try:
159 return globals()[name]
The scikit-learn maintainers therefore strongly discourage the use of this
dataset unless the purpose of the code is to study and educate about
ethical issues in data science and machine learning.
ImportError:
`load_boston` has been removed from scikit-learn since version 1.2.
In this special case, you can fetch the dataset from the original
source::
The Boston housing prices dataset has an ethical problem: as
investigated in [1], the authors of this dataset engineered a
non-invertible variable &quot;B&quot; assuming that racial self-segregation had a
positive impact on house prices [2]. Furthermore the goal of the
research that led to the creation of this dataset was to study the
impact of air quality but it did not give adequate demonstration of the
validity of this assumption.
import pandas as pd
import numpy as np
The scikit-learn maintainers therefore strongly discourage the use of
this dataset unless the purpose of the code is to study and educate
about ethical issues in data science and machine learning.
In this special case, you can fetch the dataset from the original
source::
data_url = &quot;http://lib.stat.cmu.edu/datasets/boston&quot;
raw_df = pd.read_csv(data_url, sep=&quot;\s+&quot;, skiprows=22, header=None)
data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])
target = raw_df.values[1::2, 2]
import pandas as pd
import numpy as np
Alternative datasets include the California housing dataset (i.e.
:func:`~sklearn.datasets.fetch_california_housing`) and the Ames housing
dataset. You can load the datasets as follows::
data_url = &quot;http://lib.stat.cmu.edu/datasets/boston&quot;
raw_df = pd.read_csv(data_url, sep=&quot;\s+&quot;, skiprows=22, header=None)
data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])
target = raw_df.values[1::2, 2]
from sklearn.datasets import fetch_california_housing
housing = fetch_california_housing()
Alternative datasets include the California housing dataset and the
Ames housing dataset. You can load the datasets as follows::
for the California housing dataset and::
from sklearn.datasets import fetch_california_housing
housing = fetch_california_housing()
from sklearn.datasets import fetch_openml
housing = fetch_openml(name=&quot;house_prices&quot;, as_frame=True)
for the California housing dataset and::
for the Ames housing dataset.
warnings.warn(msg, category=FutureWarning)
</pre></div>
</div>
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>dict_keys([&#39;data&#39;, &#39;target&#39;, &#39;feature_names&#39;, &#39;DESCR&#39;, &#39;filename&#39;, &#39;data_module&#39;])
from sklearn.datasets import fetch_openml
housing = fetch_openml(name=&quot;house_prices&quot;, as_frame=True)
for the Ames housing dataset.
[1] M Carlisle.
&quot;Racist data destruction?&quot;
&lt;https://medium.com/@docintangible/racist-data-destruction-113e3eff54a8&gt;
[2] Harrison Jr, David, and Daniel L. Rubinfeld.
&quot;Hedonic housing prices and the demand for clean air.&quot;
Journal of environmental economics and management 5.1 (1978): 81-102.
&lt;https://www.researchgate.net/publication/4974606_Hedonic_housing_prices_and_the_demand_for_clean_air&gt;
</pre></div>
</div>
</div>
@@ -2964,25 +2871,6 @@ the house using the features (predictors) listed here.</p>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>CRIM 0
ZN 0
INDUS 0
CHAS 0
NOX 0
RM 0
AGE 0
DIS 0
RAD 0
TAX 0
PTRATIO 0
B 0
LSTAT 0
MEDV 0
dtype: int64
</pre></div>
</div>
</div>
</div>
<p>We can then visualize the data</p>
<div class="cell docutils container">
@@ -2996,13 +2884,6 @@ dtype: int64
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/seaborn/distributions.py:2619: FutureWarning: `distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).
warnings.warn(msg, FutureWarning)
</pre></div>
</div>
<img alt="_images/week35_199_1.png" src="_images/week35_199_1.png" />
</div>
</div>
<p>It is now useful to look at the correlation matrix</p>
<div class="cell docutils container">
@@ -3015,12 +2896,6 @@ dtype: int64
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;AxesSubplot:&gt;
</pre></div>
</div>
<img alt="_images/week35_201_1.png" src="_images/week35_201_1.png" />
</div>
</div>
<p>From the above coorelation plot we can see that <strong>MEDV</strong> is strongly correlated to <strong>LSTAT</strong> and <strong>RM</strong>. We see also that <strong>RAD</strong> and <strong>TAX</strong> are stronly correlated, but we dont include this in our features together to avoid multi-colinearity</p>
<div class="cell docutils container">
@@ -3041,9 +2916,6 @@ dtype: int64
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/week35_203_0.png" src="_images/week35_203_0.png" />
</div>
</div>
<p>Now we start training our model</p>
<div class="cell docutils container">
@@ -3069,14 +2941,6 @@ dtype: int64
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>(404, 2)
(102, 2)
(404,)
(102,)
</pre></div>
</div>
</div>
</div>
<p>Then we use the linear regression functionality from <strong>Scikit-Learn</strong></p>
<div class="cell docutils container">
@@ -3115,20 +2979,6 @@ dtype: int64
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>The model performance for training set
--------------------------------------
RMSE is 5.637129335071195
R2 score is 0.6300745149331701
The model performance for testing set
--------------------------------------
RMSE is 5.137400784702911
R2 score is 0.6628996975186953
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
@@ -3139,9 +2989,6 @@ R2 score is 0.6628996975186953
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="_images/week35_210_0.png" src="_images/week35_210_0.png" />
</div>
</div>
</div>
<div class="section" id="material-for-lecture-thursday-august-31">
@@ -3421,25 +3268,6 @@ In general the economy-size SVD leads to less FLOPS and still conserving the des
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[ 1. -1.]
[ 1. -1.]]
test U
[[0. 0.]
[0. 0.]]
test VT
[[0. 0.]
[0. 0.]]
[[-0.70710678 -0.70710678]
[-0.70710678 0.70710678]]
[2.00000000e+00 3.35470445e-17]
[[-0.70710678 0.70710678]
[ 0.70710678 0.70710678]]
[[-3.33066907e-16 4.44089210e-16]
[ 0.00000000e+00 2.22044605e-16]]
</pre></div>
</div>
</div>
</div>
<p>The matrix <span class="math notranslate nohighlight">\(\boldsymbol{X}\)</span> has columns that are linearly dependent. The first
column is the row-wise sum of the other two columns. The rank of a
@@ -3795,14 +3623,6 @@ covariance matrix through the <strong>np.linalg.eig()</strong> function.</p>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.10790125813226321
4.340071371496255
[[ 1.04193203 3.08165104]
[ 3.08165104 10.18383522]]
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="correlation-matrix">
@@ -3838,14 +3658,6 @@ a more brute force way. Here we scale the mean values for each column of the des
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.08881497884574564
1.7086067479626619
[[1. 0.66080313]
[0.66080313 1. ]]
</pre></div>
</div>
</div>
</div>
<p>We see that the matrix elements along the diagonal are one as they
should be and that the matrix is symmetric. Furthermore, diagonalizing
@@ -3874,34 +3686,6 @@ this matrix we easily see that it is a positive definite matrix.</p>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[-0.40620066 -2.01265755]
[ 0.01458611 0.37737221]
[-1.0895387 -3.65442354]
[ 0.2338675 1.12044974]
[ 0.4676059 1.54393936]
[-0.65891389 -3.16304863]
[-0.1715252 0.39197698]
[ 0.71142161 2.95511792]
[ 0.39214397 0.13069442]
[ 0.50655336 2.3105791 ]]
0 1
0 -0.406201 -2.012658
1 0.014586 0.377372
2 -1.089539 -3.654424
3 0.233868 1.120450
4 0.467606 1.543939
5 -0.658914 -3.163049
6 -0.171525 0.391977
7 0.711422 2.955118
8 0.392144 0.130694
9 0.506553 2.310579
0 1
0 1.000000 0.952387
1 0.952387 1.000000
</pre></div>
</div>
</div>
</div>
<p>We expand this model to the Franke function discussed above.</p>
</div>
@@ -3955,43 +3739,6 @@ this matrix we easily see that it is a positive definite matrix.</p>
</pre></div>
</div>
</div>
<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.078974 0.081276 0.075889 0.077168 0.078540 0.065410 0.066474
2 0.0 0.081276 0.084076 0.078336 0.079946 0.081655 0.067707 0.069028
3 0.0 0.075889 0.078336 0.077460 0.078986 0.080616 0.069452 0.070737
4 0.0 0.077168 0.079946 0.078986 0.080764 0.082653 0.070986 0.072476
5 0.0 0.078540 0.081655 0.080616 0.082653 0.084809 0.072621 0.074323
6 0.0 0.065410 0.067707 0.069452 0.070986 0.072621 0.064074 0.065378
7 0.0 0.066474 0.069028 0.070737 0.072476 0.074323 0.065378 0.066854
8 0.0 0.067637 0.070457 0.072132 0.074084 0.076150 0.066787 0.068441
9 0.0 0.068906 0.072000 0.073644 0.075816 0.078110 0.068307 0.070146
10 0.0 0.055734 0.057835 0.060872 0.062337 0.063894 0.057393 0.058645
11 0.0 0.056683 0.058996 0.062016 0.063653 0.065390 0.058552 0.059951
12 0.0 0.057722 0.060254 0.063260 0.065077 0.066999 0.059807 0.061359
13 0.0 0.058854 0.061614 0.064609 0.066612 0.068727 0.061163 0.062874
14 0.0 0.060083 0.063080 0.066066 0.068264 0.070582 0.062624 0.064501
8 9 10 11 12 13 14
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.067637 0.068906 0.055734 0.056683 0.057722 0.058854 0.060083
2 0.070457 0.072000 0.057835 0.058996 0.060254 0.061614 0.063080
3 0.072132 0.073644 0.060872 0.062016 0.063260 0.064609 0.066066
4 0.074084 0.075816 0.062337 0.063653 0.065077 0.066612 0.068264
5 0.076150 0.078110 0.063894 0.065390 0.066999 0.068727 0.070582
6 0.066787 0.068307 0.057393 0.058552 0.059807 0.061163 0.062624
7 0.068441 0.070146 0.058645 0.059951 0.061359 0.062874 0.064501
8 0.070213 0.072111 0.059993 0.061452 0.063019 0.064699 0.066500
9 0.072111 0.074210 0.061443 0.063061 0.064793 0.066647 0.068629
10 0.059993 0.061443 0.052305 0.053417 0.054617 0.055910 0.057300
11 0.061452 0.063061 0.053417 0.054655 0.055987 0.057418 0.058952
12 0.063019 0.064793 0.054617 0.055987 0.057457 0.059031 0.060716
13 0.064699 0.066647 0.055910 0.057418 0.059031 0.060756 0.062599
14 0.066500 0.068629 0.057300 0.058952 0.060716 0.062599 0.064606
</pre></div>
</div>
</div>
</div>
<p>We note here that the covariance is zero for the first rows and
columns since all matrix elements in the design matrix were set to one
@@ -4331,13 +4078,6 @@ C(\boldsymbol{X},\boldsymbol{\beta})=\frac{1}{n}\left\{(\boldsymbol{y}-\boldsymb
<p class="prev-next-title">Exercises week 35</p>
</div>
</a>
<a class='right-next' id="next-link" href="exercisesweek36.html" title="next page">
<div class="prev-next-info">
<p class="prev-next-subtitle">next</p>
<p class="prev-next-title">Exercises week 36</p>
</div>
<i class="fas fa-angle-right"></i>
</a>
</div>
</div>
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "241c4a61",
"id": "72dc0997",
"metadata": {
"editable": true
},
@@ -14,7 +14,7 @@
},
{
"cell_type": "markdown",
"id": "a33815b9",
"id": "8c591125",
"metadata": {
"editable": true
},
@@ -22,12 +22,12 @@
"# Exercises week 34\n",
"**FYS-STK3155/4155**\n",
"\n",
"Date: **August 21-25, 2023**"
"Date: **August 19-23, 2024**"
]
},
{
"cell_type": "markdown",
"id": "2990585c",
"id": "1ad21876",
"metadata": {
"editable": true
},
@@ -39,7 +39,7 @@
},
{
"cell_type": "markdown",
"id": "be056de0",
"id": "4eaa91e2",
"metadata": {
"editable": true
},
@@ -108,7 +108,7 @@
},
{
"cell_type": "markdown",
"id": "f0f4ffae",
"id": "360adb56",
"metadata": {
"editable": true
},
@@ -122,7 +122,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "93d6a2b2",
"id": "278aa34f",
"metadata": {
"collapsed": false,
"editable": true
@@ -135,7 +135,7 @@
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [1]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[43mnp\u001b[49m\u001b[38;5;241m.\u001b[39mrandom\u001b[38;5;241m.\u001b[39mrand(\u001b[38;5;241m100\u001b[39m,\u001b[38;5;241m1\u001b[39m)\n\u001b[1;32m 2\u001b[0m y \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m2.0\u001b[39m\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m5\u001b[39m\u001b[38;5;241m*\u001b[39mx\u001b[38;5;241m*\u001b[39mx\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m0.1\u001b[39m\u001b[38;5;241m*\u001b[39mnp\u001b[38;5;241m.\u001b[39mrandom\u001b[38;5;241m.\u001b[39mrandn(\u001b[38;5;241m100\u001b[39m,\u001b[38;5;241m1\u001b[39m)\n",
"Cell \u001b[0;32mIn[1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[43mnp\u001b[49m\u001b[38;5;241m.\u001b[39mrandom\u001b[38;5;241m.\u001b[39mrand(\u001b[38;5;241m100\u001b[39m,\u001b[38;5;241m1\u001b[39m)\n\u001b[1;32m 2\u001b[0m y \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m2.0\u001b[39m\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m5\u001b[39m\u001b[38;5;241m*\u001b[39mx\u001b[38;5;241m*\u001b[39mx\u001b[38;5;241m+\u001b[39m\u001b[38;5;241m0.1\u001b[39m\u001b[38;5;241m*\u001b[39mnp\u001b[38;5;241m.\u001b[39mrandom\u001b[38;5;241m.\u001b[39mrandn(\u001b[38;5;241m100\u001b[39m,\u001b[38;5;241m1\u001b[39m)\n",
"\u001b[0;31mNameError\u001b[0m: name 'np' is not defined"
]
}
@@ -147,7 +147,7 @@
},
{
"cell_type": "markdown",
"id": "45392145",
"id": "1ff20e45",
"metadata": {
"editable": true
},
@@ -161,7 +161,7 @@
},
{
"cell_type": "markdown",
"id": "3eed315b",
"id": "e8809de1",
"metadata": {
"editable": true
},
@@ -174,7 +174,7 @@
},
{
"cell_type": "markdown",
"id": "26038071",
"id": "8c9e5277",
"metadata": {
"editable": true
},
@@ -185,7 +185,7 @@
},
{
"cell_type": "markdown",
"id": "4c750d55",
"id": "85a5881c",
"metadata": {
"editable": true
},
@@ -197,7 +197,7 @@
},
{
"cell_type": "markdown",
"id": "30b4731e",
"id": "4fb35d0d",
"metadata": {
"editable": true
},
@@ -207,7 +207,7 @@
},
{
"cell_type": "markdown",
"id": "49afe51d",
"id": "608f9780",
"metadata": {
"editable": true
},
@@ -219,7 +219,7 @@
},
{
"cell_type": "markdown",
"id": "81f16b80",
"id": "014bbc09",
"metadata": {
"editable": true
},
@@ -230,7 +230,7 @@
},
{
"cell_type": "markdown",
"id": "cb71cb1c",
"id": "f28863ad",
"metadata": {
"editable": true
},
@@ -249,7 +249,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "b8c919e5",
"id": "85f75a99",
"metadata": {
"collapsed": false,
"editable": true
@@ -265,7 +265,7 @@
},
{
"cell_type": "markdown",
"id": "50629e14",
"id": "bee8d814",
"metadata": {
"editable": true
},
@@ -275,7 +275,7 @@
},
{
"cell_type": "markdown",
"id": "0578f08c",
"id": "7c94f8bd",
"metadata": {
"editable": true
},
@@ -286,7 +286,7 @@
},
{
"cell_type": "markdown",
"id": "125ec9a1",
"id": "c0e789dd",
"metadata": {
"editable": true
},
@@ -298,7 +298,7 @@
},
{
"cell_type": "markdown",
"id": "e5bb2036",
"id": "5ee1d70e",
"metadata": {
"editable": true
},
@@ -319,7 +319,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.10"
"version": "3.9.18"
}
},
"nbformat": 4,
@@ -8,7 +8,7 @@
# # Exercises week 34
# **FYS-STK3155/4155**
#
# Date: **August 21-25, 2023**
# Date: **August 19-23, 2024**
# ## Exercises
#
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "053b96d5",
"id": "a15180da",
"metadata": {
"editable": true
},
@@ -14,20 +14,20 @@
},
{
"cell_type": "markdown",
"id": "a09cb811",
"id": "ac77b923",
"metadata": {
"editable": true
},
"source": [
"# Exercises week 35\n",
"**August 28-September 1, 2023**\n",
"**August 26-30, 2024**\n",
"\n",
"Date: **Deadline is Friday September 1 at midnight**"
"Date: **Deadline is Friday August 30 at midnight**"
]
},
{
"cell_type": "markdown",
"id": "8e83839e",
"id": "e8b90270",
"metadata": {
"editable": true
},
@@ -49,7 +49,7 @@
},
{
"cell_type": "markdown",
"id": "fe2b1c49",
"id": "2e2e8f1a",
"metadata": {
"editable": true
},
@@ -61,7 +61,7 @@
},
{
"cell_type": "markdown",
"id": "259f2ad1",
"id": "1cdc68da",
"metadata": {
"editable": true
},
@@ -71,7 +71,7 @@
},
{
"cell_type": "markdown",
"id": "5ac63202",
"id": "b87f9fdd",
"metadata": {
"editable": true
},
@@ -83,7 +83,7 @@
},
{
"cell_type": "markdown",
"id": "a52c6353",
"id": "6ab53932",
"metadata": {
"editable": true
},
@@ -93,7 +93,7 @@
},
{
"cell_type": "markdown",
"id": "910282dd",
"id": "1a7a8ec2",
"metadata": {
"editable": true
},
@@ -105,7 +105,7 @@
},
{
"cell_type": "markdown",
"id": "f3d0f2f5",
"id": "3bdb1514",
"metadata": {
"editable": true
},
@@ -120,7 +120,7 @@
},
{
"cell_type": "markdown",
"id": "5fe4bc49",
"id": "3e54eca9",
"metadata": {
"editable": true
},
@@ -132,7 +132,7 @@
},
{
"cell_type": "markdown",
"id": "55fee214",
"id": "3db49a1c",
"metadata": {
"editable": true
},
@@ -142,7 +142,7 @@
},
{
"cell_type": "markdown",
"id": "92b0b614",
"id": "5d4d3a0e",
"metadata": {
"editable": true
},
@@ -154,7 +154,7 @@
},
{
"cell_type": "markdown",
"id": "6b68973e",
"id": "90eecd1c",
"metadata": {
"editable": true
},
@@ -164,7 +164,7 @@
},
{
"cell_type": "markdown",
"id": "89e679e8",
"id": "7eb7605f",
"metadata": {
"editable": true
},
@@ -176,7 +176,7 @@
},
{
"cell_type": "markdown",
"id": "a35b6ab2",
"id": "b30dd90f",
"metadata": {
"editable": true
},
@@ -186,7 +186,7 @@
},
{
"cell_type": "markdown",
"id": "747d2724",
"id": "1167ec1f",
"metadata": {
"editable": true
},
@@ -198,7 +198,7 @@
},
{
"cell_type": "markdown",
"id": "911dc89a",
"id": "8f309e9e",
"metadata": {
"editable": true
},
@@ -216,7 +216,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "09971906",
"id": "2df1063f",
"metadata": {
"collapsed": false,
"editable": true
@@ -230,7 +230,7 @@
},
{
"cell_type": "markdown",
"id": "de82ebe8",
"id": "0cb75ec5",
"metadata": {
"editable": true
},
@@ -244,7 +244,7 @@
},
{
"cell_type": "markdown",
"id": "21b2c91f",
"id": "f0c36bdb",
"metadata": {
"editable": true
},
@@ -257,7 +257,7 @@
},
{
"cell_type": "markdown",
"id": "3b542aa1",
"id": "8c3ce778",
"metadata": {
"editable": true
},
@@ -268,7 +268,7 @@
},
{
"cell_type": "markdown",
"id": "5393a93f",
"id": "f861d243",
"metadata": {
"editable": true
},
@@ -280,7 +280,7 @@
},
{
"cell_type": "markdown",
"id": "df1b8e23",
"id": "51500e4b",
"metadata": {
"editable": true
},
@@ -290,7 +290,7 @@
},
{
"cell_type": "markdown",
"id": "30ad9bb6",
"id": "fda9dadd",
"metadata": {
"editable": true
},
@@ -302,7 +302,7 @@
},
{
"cell_type": "markdown",
"id": "0e2c0d15",
"id": "6b691499",
"metadata": {
"editable": true
},
@@ -313,7 +313,7 @@
},
{
"cell_type": "markdown",
"id": "80eab896",
"id": "b6f10ab9",
"metadata": {
"editable": true
},
@@ -333,7 +333,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "887378fa",
"id": "285159ae",
"metadata": {
"collapsed": false,
"editable": true
@@ -349,7 +349,7 @@
},
{
"cell_type": "markdown",
"id": "a059a330",
"id": "c2840fc9",
"metadata": {
"editable": true
},
@@ -359,7 +359,7 @@
},
{
"cell_type": "markdown",
"id": "e2614fe9",
"id": "9dbda275",
"metadata": {
"editable": true
},
@@ -370,7 +370,7 @@
},
{
"cell_type": "markdown",
"id": "8522c8f4",
"id": "824dba6f",
"metadata": {
"editable": true
},
@@ -382,7 +382,7 @@
},
{
"cell_type": "markdown",
"id": "c4e99901",
"id": "a3f059cf",
"metadata": {
"editable": true
},
@@ -403,7 +403,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.10"
"version": "3.9.18"
}
},
"nbformat": 4,
@@ -6,9 +6,9 @@
# <!-- dom:TITLE: Exercises week 35 -->
# # Exercises week 35
# **August 28-September 1, 2023**
# **August 26-30, 2024**
#
# Date: **Deadline is Friday September 1 at midnight**
# Date: **Deadline is Friday August 30 at midnight**
# ## Exercise 1: Analytical exercises
#
File diff suppressed because one or more lines are too long
+55 -153
View File
@@ -8,7 +8,7 @@
# # Week 34: Introduction to the course, Logistics and Practicalities
# **Morten Hjorth-Jensen**, Department of Physics and Center for Computing in Science Education, University of Oslo, Norway and Department of Physics and Astronomy and Facility for Rare Isotope Beams, Michigan State University, USA
#
# Date: **Week 34, August 21-25, 2023**
# Date: **Week 34, August 19-23, 2024**
# ## Overview of first week
#
@@ -22,23 +22,25 @@
#
# * Wednesdays 815am-12pm and 1215pm-4pm.
#
# 4. On Thursdays we have a regular lecture. These lectures start at 1215pm and end at 2pm and serve the aims of giving an overview over various topics. These lectures will also be recorded.
# 4. On Mondays we have a regular lecture which will be organized as a mix of active learning sessions and regular lectures. These lectures/active learning sessions start at 1015am and end at 12pm and serve the aims of giving an overview over various topics as well as solving specific problems. These lectures will also be recorded.
#
# * [Link to recording of lecture TBA](https://youtu.be/)
#
# The labs are also available till 6pm Tuesdays and Wednesdays. Videos and learning material with reading suggestions will be made available before each week starts.
# ## Schedule first week
#
# * August 22: Presentation of the course, aims and content. Introduction to software and repetition of Python Programming, linear algebra and basic elements of statistics. Please select group.
# * August 19: Lecture: Presentation of course, Linear regression, examples and theory
#
# * August 23: Presentation of the course, aims and content. Introduction to software and repetition of Python Programming, linear algebra and basic elements of statistics. Please select group.
# * August 20: Introduction to software and repetition of Python Programming, linear algebra and basic elements of statistics. Please select group.
#
# * August 24: Lecture: Linear regression, examples and theory
# * August 23: Introduction to software and repetition of Python Programming, linear algebra and basic elements of statistics. Please select group.
# ## Lectures and ComputerLab
#
# * The sessions on Tuesdays and Wednesdays last four hours and will include partly lectures in a flipped mode (promoting active learning) and work on exercices and projects.
# * Mondays: regular lectures/active learning sessions (10.15am-12pm)
#
# * Thursdays: regular lectures (12.15pm-2pm)
# * The sessions on Tuesdays and Wednesdays last four hours and will include partly lectures and discussions in the beginning.
#
# * Weekly reading assignments and videos needed to solve projects and exercises.
#
@@ -52,9 +54,9 @@
# ## Communication channels
#
# * Chat and communications via <canvas.uio.no>
# * Communications (email and more) via <canvas.uio.no>
#
# * **Discord** channel will be added asap
# * **Discord** channel at <https://discord.gg/hAaBRWFT72>
# ## Course Format
#
@@ -88,19 +90,19 @@
#
# * Karl Henrik Fredly, k.h.fredly@fys.uio.no
#
# * Adam Jakobsen, adam.jakobsen@fys.uio.no
# * Sigurd k. Huse, s.k.huse@fys.uio.no
#
# * Daniel Haas Beccatini Lima, d.h.b.lima@fys.uio.no
# * Odin Johansen, odin.johansen@fys.uio.no
# ## Deadlines for projects (tentative)
#
# 1. Project 1: October 9 (available September 4) graded with feedback)
# 1. Project 1: October 7 (available September 2) graded with feedback)
#
# 2. Project 2: November 6 (available October 6, graded with feedback)
# 2. Project 2: November 4 (available October 8, graded with feedback)
#
# 3. Project 3: December 11 (available November 10, graded with feedback)
# 3. Project 3: December 9 (available November 5, graded with feedback)
#
# Extra Credit (not mandatory), weekly exercise assignments, 10 in total (due Friday same week), 10% additional score. The extra credit assignments are due each Friday and can be uploaed to **Canvas** in your preferred format (although we prefer jupyter-notebooks). First assignment is for week 35. Each weekly exercise set counts 1%.
# Extra Credit (not mandatory), weekly exercise assignments, 10 in total (due Friday same week), 10% additional score. The extra credit assignments are due each Sunday and can be uploaed to **Canvas** in your preferred format (although we prefer jupyter-notebooks). First assignment is for week 35. Each weekly exercise set counts 1%.
# ## Grading
#
@@ -125,12 +127,25 @@
# ## Reading material
#
# The lecture notes are collected as a jupyter-book at <https://compphysics.github.io/MachineLearning/doc/LectureNotes/_build/html/intro.html>.
# The lecture notes can also be retrieved as a standard PDF file at <https://compphysics.github.io/MachineLearning/doc/LectureNotes/MLbook.pdf>.
#
# In addition to the lecture notes, we recommend the books of Bishop, Hastie et al, Murphy and Goodfellow et al. We will follow these texts closely and the weekly reading assignments refer to these texts. The text by Hastie et al is also widely used in the Machine Learning community. Finally, we also recommend the hands-on text by Geron, see next slide for links.
# In addition to the lecture notes, we recommend the books of Rasckha et
# al and Goodfellow et al. We will follow these texts closely and the
# weekly reading assignments refer to these texts. The text by Hastie et
# al is also widely used in the Machine Learning community. See next slide for link to textbooks.
# ## Textbooks
# ## Main textbooks
#
# * [Goodfellow, Bengio, and Courville (GBC), Deep Learning](https://www.deeplearningbook.org/)
# * Goodfellow, Bengio, and Courville (GBC), Deep Learning <https://www.deeplearningbook.org/>
#
# * Sebastian Raschka, Yuxi Lie, and Vahid Mirjalili (RLM), Machine Learning with PyTorch and Scikit-Learn at <https://www.packtpub.com/product/machine-learning-with-pytorch-and-scikit-learn/9781801819312>, see also <https://sebastianraschka.com/blog/2022/ml-pytorch-book.html>
#
# The weekly reading suggestions are all from these two texts. The text by GBC can be accessed chapter by chapter from the abovementioned URL.
# Each chapter of RLM gives access to the pertinent notebooks. These notebooks are highly recommended.
# ## Other popular texts
#
# **Other texts.**
#
# * Christopher M. Bishop (CB), Pattern Recognition and Machine Learning
#
@@ -139,10 +154,14 @@
# * [Aurelien Geron (AG), HandsOn Machine Learning with ScikitLearn and TensorFlow, O'Reilly](https://www.oreilly.com/library/view/hands-on-machine-learning/9781492032632/). This text is very useful since it contains many code examples and hands-on applications of all algorithms discussed in this course.
#
# * [Kevin Murphy (KM), Probabilistic Machine Learning, an Introduction](https://probml.github.io/pml-book/book1.html)
#
# * David Foster (DF), Generative Deep Learning, <https://www.oreilly.com/library/view/generative-deep-learning/9781098134174/>
#
# * Babcock and Gavras (BG), Generative AI with Python and TensorFlow, <https://github.com/PacktPublishing/Hands-On-Generative-AI-with-Python-and-TensorFlow-2>
# ## Reading suggestions week 34
#
# This week: Refresh linear algebra, GBC chapters 1 and 2. HTF chapters 2 and 3. Install scikit-learn. See lecture notes for week 34 at <https://compphysics.github.io/MachineLearning/doc/web/course.html> (these notes).
# This week: Refresh linear algebra, GBC chapter 2. Install scikit-learn. See lecture notes for week 34 at <https://compphysics.github.io/MachineLearning/doc/web/course.html> (these notes).
# ## Prerequisites
#
@@ -195,7 +214,9 @@
#
# * Support vector machines (only survey);
#
# * Unsupervised learning and dimensionality reduction, from PCA to clustering;
# * Unsupervised learning and dimensionality reduction, from PCA to clustering;
# ## Deep learning methods
#
# * Deep learning
#
@@ -207,7 +228,7 @@
#
# * Autoencoders
#
# * Generative methods with an emphasis on Boltzmann Machines, Variational Autoencoders and Generalized Adversarial Networks;
# * Generative methods with an emphasis on Boltzmann Machines, Variational Autoencoders and Generalized Adversarial Networks(covered by FYS5429);
#
# Hands-on demonstrations, exercises and projects aim at deepening your understanding of these topics.
@@ -245,20 +266,6 @@
# ## Learning outcomes
#
# This course aims at giving you insights and knowledge about many of
# the central algorithms used in Data Analysis and Machine Learning.
# The course is project based and through various numerical projects,
# normally three, you will be exposed to fundamental research problems
# in these fields, with the aim to reproduce state of the art scientific
# results. Both supervised and unsupervised methods will be covered. The
# emphasis is on a frequentist approach, although we will try to link it
# with a Bayesian approach as well. You will learn to develop and
# structure large codes for studying different cases where Machine
# Learning is applied to, get acquainted with computing facilities and
# learn to handle large scientific projects. A good scientific and
# ethical conduct is emphasized throughout the course. More
# specifically, after this course you will
#
# * Learn about basic data analysis, statistical analysis, Bayesian statistics, Monte Carlo sampling, data optimization and machine learning;
#
# * Be capable of extending the acquired knowledge to other systems and cases;
@@ -279,118 +286,6 @@
#
# * Work on numerical projects to illustrate the theory. The projects play a central role and you are expected to know modern programming languages like Python or C++ and/or Fortran (Fortran2003 or later) or Julia or other.
# ## Introduction
#
# Our emphasis throughout this series of lectures
# is on understanding the mathematical aspects of
# different algorithms used in the fields of data analysis and machine learning.
#
# However, where possible we will emphasize the
# importance of using available software. We start thus with a hands-on
# and top-down approach to machine learning. The aim is thus to start with
# relevant data or data we have produced
# and use these to introduce statistical data analysis
# concepts and machine learning algorithms before we delve into the
# algorithms themselves. The examples we will use in the beginning, start with simple
# polynomials with random noise added. We will use the Python
# software package [Scikit-Learn](http://scikit-learn.org/stable/) and
# introduce various machine learning algorithms to make fits of
# the data and predictions. We move thereafter to more interesting
# cases such as data from say experiments (below we will look at experimental nuclear binding energies as an example).
# These are examples where we can easily set up the data and
# then use machine learning algorithms included in for example
# **Scikit-Learn**.
#
# These examples will serve us the purpose of getting
# started. Furthermore, they allow us to catch more than two birds with
# a stone. They will allow us to bring in some programming specific
# topics and tools as well as showing the power of various Python
# libraries for machine learning and statistical data analysis.
#
# Although we have projects where you write your own codes, we will also focus on two
# specific Python packages for Machine Learning, Scikit-Learn and
# Tensorflow with Keras (see below for links etc). Moreover, the examples we
# introduce will serve as inputs to many of our discussions later, as
# well as allowing you to set up models and produce your own data and
# get started with programming.
# ## AI/ML and some statements you may have heard (and what do they mean?)
#
# 1. Fei-Fei Li on ImageNet: **map out the entire world of objects** ([The data that transformed AI research](https://cacm.acm.org/news/219702-the-data-that-transformed-ai-research-and-possibly-the-world/fulltext))
#
# 2. Russell and Norvig in their popular textbook: **relevant to any intellectual task; it is truly a universal field** ([Artificial Intelligence, A modern approach](http://aima.cs.berkeley.edu/))
#
# 3. Woody Bledsoe puts it more bluntly: **in the long run, AI is the only science** (quoted in Pamilla McCorduck, [Machines who think](https://www.pamelamccorduck.com/machines-who-think))
#
# If you wish to have a critical read on AI/ML from a societal point of view, see [Kate Crawford's recent text Atlas of AI](https://www.katecrawford.net/)
#
# **Here: with AI/ML we intend a collection of machine learning methods with an emphasis on statistical learning and data analysis**
# ## What is Machine Learning?
#
# Statistics, data science and machine learning form important fields of
# research in modern science. They describe how to learn and make
# predictions from data, as well as allowing us to extract important
# correlations about physical process and the underlying laws of motion
# in large data sets. The latter, big data sets, appear frequently in
# essentially all disciplines, from the traditional Science, Technology,
# Mathematics and Engineering fields to Life Science, Law, education
# research, the Humanities and the Social Sciences.
#
# It has become more
# and more common to see research projects on big data in for example
# the Social Sciences where extracting patterns from complicated survey
# data is one of many research directions. Having a solid grasp of data
# analysis and machine learning is thus becoming central to scientific
# computing in many fields, and competences and skills within the fields
# of machine learning and scientific computing are nowadays strongly
# requested by many potential employers. The latter cannot be
# overstated, familiarity with machine learning has almost become a
# prerequisite for many of the most exciting employment opportunities,
# whether they are in bioinformatics, life science, physics or finance,
# in the private or the public sector. This author has had several
# students or met students who have been hired recently based on their
# skills and competences in scientific computing and data science, often
# with marginal knowledge of machine learning.
#
# Machine learning is a subfield of computer science, and is closely
# related to computational statistics. It evolved from the study of
# pattern recognition in artificial intelligence (AI) research, and has
# made contributions to AI tasks like computer vision, natural language
# processing and speech recognition. Many of the methods we will study are also
# strongly rooted in basic mathematics and physics research.
#
# Ideally, machine learning represents the science of giving computers
# the ability to learn without being explicitly programmed. The idea is
# that there exist generic algorithms which can be used to find patterns
# in a broad class of data sets without having to write code
# specifically for each problem. The algorithm will build its own logic
# based on the data. You should however always keep in mind that
# machines and algorithms are to a large extent developed by humans. The
# insights and knowledge we have about a specific system, play a central
# role when we develop a specific machine learning algorithm.
#
# Machine learning is an extremely rich field, in spite of its young
# age. The increases we have seen during the last three decades in
# computational capabilities have been followed by developments of
# methods and techniques for analyzing and handling large date sets,
# relying heavily on statistics, computer science and mathematics. The
# field is rather new and developing rapidly. Popular software packages
# written in Python for machine learning like
# [Scikit-learn](http://scikit-learn.org/stable/),
# [Tensorflow](https://www.tensorflow.org/),
# [PyTorch](http://pytorch.org/) and [Keras](https://keras.io/), all
# freely available at their respective GitHub sites, encompass
# communities of developers in the thousands or more. And the number of
# code developers and contributors keeps increasing. Not all the
# algorithms and methods can be given a rigorous mathematical
# justification, opening up thereby large rooms for experimenting and
# trial and error and thereby exciting new developments. However, a
# solid command of linear algebra, multivariate theory, probability
# theory, statistical data analysis, understanding errors and Monte
# Carlo methods are central elements in a proper understanding of many
# of algorithms and methods we will discuss.
# ## Types of Machine Learning
#
# The approaches to machine learning are many, but are often split into
@@ -579,7 +474,9 @@
#
# * [Keras](https://keras.io/) is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano
#
# * And many more such as [pytorch](https://pytorch.org/), [Theano](https://pypi.org/project/Theano/) etc
# * [Pytorch](https://pytorch.org/), highly recommened
#
# * [Theano](https://pypi.org/project/Theano/) and many other
# ## Installing R, C++, cython or Julia
#
@@ -1551,31 +1448,36 @@ from sklearn.neural_network import MLPRegressor
from sklearn.metrics import accuracy_score
import seaborn as sns
X_train = X
Y_train = Energies
n_hidden_neurons = 100
n_hidden_neurons = 50
epochs = 100
# store models for later use
eta_vals = np.logspace(-5, 1, 7)
lmbd_vals = np.logspace(-5, 1, 7)
eta_vals = np.logspace(-3, 0, 4)
lmbd_vals = np.logspace(-3, 0, 4)
# store the models for later use
DNN_scikit = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)
train_accuracy = np.zeros((len(eta_vals), len(lmbd_vals)))
sns.set()
for i, eta in enumerate(eta_vals):
for j, lmbd in enumerate(lmbd_vals):
dnn = MLPRegressor(hidden_layer_sizes=(n_hidden_neurons), activation='logistic',
dnn = MLPRegressor(hidden_layer_sizes=(n_hidden_neurons), activation='relu', solver='adam',
alpha=lmbd, learning_rate_init=eta, max_iter=epochs)
dnn.fit(X_train, Y_train)
DNN_scikit[i][j] = dnn
train_accuracy[i][j] = dnn.score(X_train, Y_train)
fity = dnn.predict(X_train)
MSE = mean_squared_error(Y_train, fity)
print("Mean squared error: %.2f" % mean_squared_error(Y_train, fity))
train_accuracy[i][j] = MSE
fig, ax = plt.subplots(figsize = (10, 10))
sns.heatmap(train_accuracy, annot=True, ax=ax, cmap="viridis")
ax.set_title("Training Accuracy")
ax.set_ylabel("$\eta$")
ax.set_xlabel("$\lambda$")
plt.show()
print(train_accuracy)
# ## A first summary
Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@
# # Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression
# **Morten Hjorth-Jensen**, Department of Physics, University of Oslo and Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
#
# Date: **August 28-September 1**
# Date: **August 26-30**
# ## Plans for week 35
#
@@ -20,21 +20,15 @@
#
# 3. Discussion on how to prepare data and examples of applications of linear regression
#
# 4. Material for the lecture on Thursday: Mathematical interpretations of linear regression
# 4. Material for the lecture on Monday: Mathematical interpretations of linear regression
#
# 5. Thursday: Ridge and Lasso regression and Singular Value Decomposition
#
# 6. [Video of lecture](https://youtu.be/qBNm-HGSxL4)
#
# 7. [Whiteboard notes](https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2023/NotesAug31.pdf)
# 5. Monday: Ridge and Lasso regression and Singular Value Decomposition
# ### Reading recommendations:
#
# 1. See lecture notes for week 35 at <https://compphysics.github.io/MachineLearning/doc/web/course.html>
#
# 2. Goodfellow, Bengio and Courville, Deep Learning, chapter 2 on linear algebra and sections 3.1-3.10 on elements of statistics (background)
#
# 3. Hastie, Tibshirani and Friedman, The elements of statistical learning, sections 3.1-3.4 (on relevance for the discussion of linear regression).
# ## Why Linear Regression (aka Ordinary Least Squares and family), repeat from last week
#
Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff