@@ -24,17 +24,69 @@ def set_up_point_matrix(axis_x: np.ndarray, degree: int) -> np.ndarray:
2424 np.ndarray: The polynomial point matrix A.
2525 """
2626 mat_a = np .zeros ((len (axis_x ), degree ))
27- # TODO implement me!
27+ # TODO 1.1.1 implement me!
2828 return mat_a
2929
3030
3131if __name__ == "__main__" :
3232 b_noise_p = pandas .read_csv ("./data/noisy_signal.tab" , header = None )
33- b_noise = np .asarray (b_noise_p )
33+ b_noise = np .asarray (b_noise_p ) # This is the artificial data we work with
3434
3535 x_axis = np .linspace (0 , 1 , num = len (b_noise ))
3636
3737 plt .plot (x_axis , b_noise , "." , label = "b_noise" )
3838 plt .show ()
3939
40- # TODO put your code here!
40+ # TODO put your code for Part 1 here!
41+
42+ # 1.1 Regression
43+
44+ # 1.1.2 Create the point-matrix A for n=2
45+
46+ # 1.1.3 Calculate the estimated coefficients for the polynomial
47+ # You can use np.linalg.pinv to compute the Pseudo-Inverse
48+
49+ # 1.1.4 Plot the original data as well as the estimated polynomial by evaluating it.
50+
51+
52+
53+ # 1.2 Higher order Polynomial
54+
55+ # 1.2.1 Create the point-matrix A for n=300
56+
57+ # 1.2.2 Calculate the estimated coefficients for the polynomial
58+
59+ # 1.2.3 Plot the original data as well as the estimated polynomial by evaluating it.
60+
61+
62+
63+ # 1.3 Regularization
64+
65+ # 1.3.1 Compute the SVD of A
66+
67+ # 1.3.2 Compute the filter matrix
68+
69+ # 1.3.3 Estimate the coefficients by applying regularization
70+
71+ # 1.3.4 Plot your results
72+
73+ #----------------------------------------------------------------------------------------#
74+ # Optional Task 1.4 Model Complexity
75+
76+ # For every degree from 1 to 20:
77+
78+ # 1.4.1 Set up the point matrix for the current degree
79+
80+ # 1.4.2 Estimate the coefficients for the polynomial via the pseudoinverse
81+
82+ # 1.4.3 Compute the predictions by evaluating the estimated polynomial at the x-values
83+
84+ # 1.4.4 Compute the MSE between the predictions and the original b-values
85+
86+ # 1.4.5 Plot the MSE-error against the degree
87+
88+ # 1.4.6 Take a look at the graph with all 20 MSE's and see if there is a link between degree and MSE
89+ # Estimate the optimal degree of polynomial and fit the polynomial with this new degree
90+ # --> so perform the usual steps but only once with the optimal degree
91+
92+ # Plot the result
0 commit comments