You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately, the fit is not ideal. The polynomial is too complex and tracks the noise.
121
121
The singular value decomposition (SVD) can help!
122
122
Recall that the SVD turns a matrix
@@ -178,14 +178,14 @@ Setting n=300 turns A into a square matrix. In this case, the zero block in the
178
178
179
179
To sum it up, your tasks are:
180
180
1. Compute the SVD of A.
181
-
182
-
Perform the following steps 2. - 4. for epsilon equal to 0.1, 1e-6, and 1e-12.
183
181
2. Compute the diagonal for the filter matrix and turn it into a matrix.
184
182
3. Estimate the regularized coefficients by applying the formula above.
185
183
4. Plot the result.
186
184
185
+
Perform the steps 2. - 4. for epsilon equal to 0.1, 1e-6, and 1e-12.
186
+
187
187
188
-
#### ✪Task 1.4: Model Complexity (Optional):
188
+
#### ✪Task 1.4: Model Complexity (Optional):
189
189
Another solution to the overfitting problem is reducing the complexity of the model.
190
190
To assess the quality of polynomial fit to the data, compute and plot the Mean Squared Error (Mean Squared Error measure how close the regression line is to data points) for every degree of polynomial upto 20.
191
191
So as before:
@@ -207,7 +207,7 @@ Now we are ready to deal with real data! Feel free to use your favorite time ser
207
207
The file `./data/pegel.tab` contains the Rhine water levels measured in Bonn over the last 100 years.
208
208
Data source: https://pegel.bonn.de.
209
209
210
-
#### ⊙Task 2.1 Regression
210
+
#### ⊙Task 2.1 Regression
211
211
The `src/pegel_bonn.py` file already contains code to pre-load the data for you.
212
212
The Rhine level measurements will be your new vector $\mathbf{b}$ from before.
213
213
Now we want to do the same as in Part 1 and start with linear regression!
@@ -233,16 +233,17 @@ Re-using the code you wrote for the proof of concept task, fit a polynomial of d
233
233
234
234
235
235
236
-
#### ⊙Task 2.3: Regularization
236
+
#### ⊙Task 2.3: Regularization
237
237
Focus on the data from the year 2000 onward and filter the singular values.
238
238
We will use again a degree of 20.
239
239
Matrix A is not square in this case, because the degree is smaller than the number of datapoints! Consequently, a zero block must appear in your singular value matrix and when computing the Pseudoinverse from the SVD, $\sigma$ has to be transposed!
240
240
Like in Part 1:
241
-
1. Compute the SVD of the point matrix from the previous task.
242
241
243
-
Perform the following steps 2. - 4. for epsilon equal to 0.1, 1e-3, and 1e-9.
242
+
1. Compute the SVD of the point matrix from the previous task.
244
243
2. Compute the filter matrix.
245
244
3. Estimate the regularized coefficients by applying the formula from before.
246
245
> **Hint:** Remember the zero-block! You need degree-many rows and number-of-datapoints-many columns!
247
246
4. Evaluate the regularized polynomial and plot the results.
248
247
248
+
Perform the steps 2. - 4. for epsilon equal to 0.1, 1e-3, and 1e-9.
0 commit comments