Question: 1. (50 points) Complete the linear regression functions (least squares and ridge regression). Use the code to conduct the following experiments: (a) (5 points)

1. (50 points) Complete the linear regression functions (least squares and ridge  

1. (50 points) Complete the linear regression functions (least squares and ridge regression). Use the code to conduct the following experiments: (a) (5 points) Randomly generate 30 data points from the sine function, where each data point (x, y) has the form: x = [x0,x, x, x10], x = [0,2] y=sin(x), EN(0, 0.3) (b) (5 points) Plot the data points along with the sine function. You should be able to see a figure similar to the following: 1.5 1.0 0.5 0.0 -0.5 -1.0- 0 1 3 4 5 6 t (c) (20 points) Randomly split the dataset (you can use the function provided in the Regres- sion code) and use 70% of the data points for training and the rest for testing. Apply ridge regression using different A E A = [le - 10, le 5, le 2, le 1, 1, 10, 100, 1000]. Plot the training and testing performance per \. (d) (20 points) Implement the k-fold cross validation function. Use k = 4 to choose the optimal from the set A above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!