This commit is contained in:
Morten Hjorth-Jensen
2025-09-01 09:36:43 +02:00
parent 7bd40a8c65
commit 18788a20d8
2 changed files with 38 additions and 8 deletions
+1 -1
View File
@@ -323,7 +323,7 @@
"source": [
"n = 100\n",
"x = np.linspace(-3, 3, n)\n",
"y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + np.random.normal(0, 0.1)"
"y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + np.random.normal(0, 1.0)"
]
},
{
+37 -7
View File
@@ -37,7 +37,7 @@
"After having completed these exercises you will have:\n",
"1. Your own code for the implementation of the simplest gradient descent approach applied to ordinary least squares (OLS) and Ridge regression\n",
"\n",
"2. Be able to compare the analytical expressions for OLS and Rudge regression with the gradient descent approach\n",
"2. Be able to compare the analytical expressions for OLS and Ridge regression with the gradient descent approach\n",
"\n",
"3. Explore the role of the learning rate in the gradient descent approach and the hyperparameter $\\lambda$ in Ridge regression\n",
"\n",
@@ -55,7 +55,7 @@
"\n",
"We create a synthetic linear regression dataset with a sparse\n",
"underlying relationship. This means we have many features but only a\n",
"few of them actually contribute to the target. In our example, well\n",
"few of them actually contribute to the target. In our example, we will\n",
"use 10 features with only 3 non-zero weights in the true model. This\n",
"way, the target is generated as a linear combination of a few features\n",
"(with known coefficients) plus some random noise. The steps we include are:\n",
@@ -75,7 +75,10 @@
"id": "9e6acfef",
"metadata": {
"collapsed": false,
"editable": true
"editable": true,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
@@ -176,7 +179,10 @@
"id": "a140aac7",
"metadata": {
"collapsed": false,
"editable": true
"editable": true,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
@@ -223,7 +229,10 @@
"id": "97ac6cb6",
"metadata": {
"collapsed": false,
"editable": true
"editable": true,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
@@ -302,7 +311,10 @@
"id": "a67af634",
"metadata": {
"collapsed": false,
"editable": true
"editable": true,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
@@ -371,7 +383,25 @@
]
}
],
"metadata": {},
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}