Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started