Skip to content

Commit a06558c

Browse files
authored
Merge branch 'main' into dev_kons
2 parents bbd766a + f5bd467 commit a06558c

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ Feel free to read more about nox at https://nox.thea.codes/en/stable/ .
1212

1313
### Part 1: Proof of concept
1414
Use `b = pandas.read_csv('./data/noisy_signal.tab')` to load a noisy signal.
15-
The first part will be concerned with modeling this signal using polynomials.
15+
The first part will be concerned with modelling this signal using polynomials.
1616

1717
#### Regression:
1818
Linear regression is usually a good first step. Start by implementing the function
1919
`set_up_point_matrix` from the `src/regularization.py` module.
20-
The function should produce polynomial-coordinate matrices $\mathbf{A}_m$ of the form:
20+
The function should produce polynomial-coordinate matrices $\mathbf{A}_n$ of the form:
2121

2222
$$
23-
\mathbf{A}_m =
23+
\mathbf{A}_n =
2424
\begin{pmatrix}
25-
1 & a_1^1 & a_1^2 & \dots & a_1^{m-1} \\\\
26-
1 & a_2^1 & a_2^2 & \dots & a_2^{m-1} \\\\
27-
1 & a_3^1 & a_3^2 & \dots & a_3^{m-1} \\\\
25+
1 & a_1^1 & a_1^2 & \dots & a_1^{n-1} \\\\
26+
1 & a_2^1 & a_2^2 & \dots & a_2^{n-1} \\\\
27+
1 & a_3^1 & a_3^2 & \dots & a_3^{n-1} \\\\
2828
\vdots & \vdots & \vdots & \ddots & \vdots \\\\
29-
1 & a_n^1 & a_n^2 & \dots & a_n^{m-1} \\\\
29+
1 & a_m^1 & a_m^2 & \dots & a_m^{n-1} \\\\
3030
\end{pmatrix}
3131
$$
3232

33-
With m=2,
33+
With n=2,
3434

35-
$$\mathbf{A}_m^{\dagger}\mathbf{b} = \mathbf{x}$$
35+
$$\mathbf{A}_2^{\dagger}\mathbf{b} = \mathbf{x}$$
3636

3737
will produce the coefficients for a straight line. Evaluate your first-degree polynomial via $ax+b$.
3838
Plot the result using `matplotlib.pyplot`'s `plot` function.
@@ -101,19 +101,19 @@ $$
101101

102102
with
103103

104-
$$\mathbf{A} \in \mathbb{R}^{m,n}, \mathbf{U} \in \mathbb{R}^{m,m}, \mathbf{V} \in \mathbb{R}^{n,n}, \mathbf{F} \in \mathbb{R}^{m,m}, \Sigma^{\dagger} \in \mathbb{R}^{n,m} \text{ and } \mathbf{b} \in \mathbb{R}^{n,1}.$$
104+
$$\mathbf{V} \in \mathbb{R}^{n,n}, \mathbf{F} \in \mathbb{R}^{n,n}, \Sigma^{\dagger} \in \mathbb{R}^{n,m}, \mathbf{U} \in \mathbb{R}^{m,m} \text{ and } \mathbf{b} \in \mathbb{R}^{m,1}.$$
105105

106106
Setting $m=300$ turns $A$ into a square matrix. In this case, the zero block in the sigma-matrix disappears.
107107
Plot the result for epsilon equal to 0.1, 1e-6, and 1e-12.
108108

109109
#### Model Complexity (Optional):
110110
Another solution to the overfitting problem is reducing the complexity of the model.
111-
To assess the quality of polynomial fit to the data, compute and plot the Mean Squared Error (Mean Squared Error (MSE) measure how close the regression line is to data points) for every degree of polynomial upto 20.
111+
To assess the quality of polynomial fit to the data, compute and plot the Mean Squared Error (Mean Squared Error (MSE) measure how close the regression line is to data points) for every degree of polynomial up to 20.
112112

113113
MSE can be calculated using the following equation, where $N$ is the number of samples, $y_i$ is the original point and $\hat{y_i}$ is the predictied output.
114114
$$MSE=\frac{1}{N} \sum_{i=1}^{N} (y_i-\hat{y_i})^2$$
115115

116-
From the plot, estimate the optimal degree of polynomial and fit the polynomial with this new degree and compare the regression.
116+
Are the degree of the polynomial and the MSE linked?
117117

118118
### Part 2: Real data analysis
119119
Now we are ready to deal with real data! Feel free to use your favorite time series data or work with the Rhine level data we provide.
@@ -123,7 +123,8 @@ Data source: https://pegel.bonn.de.
123123
#### Regression:
124124
The `src/pegel_bonn.py` file already contains code to pre-load the data for you.
125125
Make the Rhine level measurements your new vector $\mathbf{b}$.
126-
Generate a matrix A with m=2 using the timestamps for the data set and compute
126+
127+
Generate a matrix A with n=2 using the timestamps for the data set and compute
127128

128129
$$\mathbf{A}^{\dagger}\mathbf{b}.$$
129130

@@ -134,9 +135,7 @@ Plot the result. Compute the zero. When do the regression line and the x-axis in
134135
Re-using the code you wrote for the proof of concept task, fit a polynomial of degree 20 to the data. Before plotting have a closer look at `datetime_stamps` and its values and scale the axis appropriately.
135136
Plot the result.
136137

137-
138138
#### Regularization:
139-
Something happened around the year 2000. To investigate further, focus on the data from 2000 onward and
140-
filter the singular values.
139+
Focus on the data from the year 2000 onward and filter the singular values.
141140
Matrix A is not square in this case. Consequently, a zero block must appear in your singular value matrix.
142141
Plot filtered eigen-polynomials using epsilon equal to 0.1, 1e-3, 1e-9.

0 commit comments

Comments
 (0)