@@ -37,7 +37,7 @@ def set_up_point_matrix(axis_x: np.ndarray, degree: int) -> np.ndarray:
37
37
plt .plot (x_axis , b_noise , "." , label = "b_noise" )
38
38
plt .show ()
39
39
40
- # TODO put your code here!
40
+ # TODO put your code for Part 1 here!
41
41
42
42
# 1.1 Regression
43
43
@@ -48,6 +48,8 @@ def set_up_point_matrix(axis_x: np.ndarray, degree: int) -> np.ndarray:
48
48
49
49
# 1.1.4 Plot the original data as well as the estimated polynomial by evaluating it.
50
50
51
+
52
+
51
53
# 1.2 Higher order Polynomial
52
54
53
55
# 1.2.1 Create the point-matrix A for n=300
@@ -56,4 +58,35 @@ def set_up_point_matrix(axis_x: np.ndarray, degree: int) -> np.ndarray:
56
58
57
59
# 1.2.3 Plot the original data as well as the estimated polynomial by evaluating it.
58
60
61
+
62
+
59
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