Answered step by step
Verified Expert Solution
Question
1 Approved Answer
USE PYTHON ONLY. I cannot upload the files. Please leave a template for me to use. Thank you. Will upvote best answer! Download the files
USE PYTHON ONLY.
I cannot upload the files. Please leave a template for me to use. Thank you. Will upvote best answer!
Download the files x-train. csv, y-train. csv, x-test. csv, and y-test. csv. The following is the description of these datasets: - X-train.csv: This is Np matrix. The rows correspond to the feature vectors of the training samples. - y-train.csv: This is N1 vector, whose elements correspond to the quality of the wines in the training set. - X-test.csv: This is Np matrix. The rows correspond to the feature vectors of the test samples. - y-test. csv: This is N1 vector, whose elements correspond to the quality of the wines in test set. (a) Obtain the parameters (0,) by solving the least-squares problem via the closed-form solution. Report the MSE of your designed linear model on the test set. (b) Obtain the parameters (0,) by solving the least-squares problem via the gradient descent (GD) algorithm. Set the maximum number of iterations to 1,000 and the step size to 0.1. Plot the 2-norm of the difference between the solution at every iteration of GD and the closed form solution obtained in part (a). The x-axis should correspond to the iteration index, and y-axis should correspond to the 2-norm of the difference between the solution at every iteration of GD and the closed form solution. (c) Repeat part (b) with step size =5. Plot the 2-norm of the difference between the solution at every iteration of GD and the closed form solution obtained in part (a). Compare the obtained plot with the one from part (b). (d) Obtain the parameters (0,) by solving the least-squares problem via stochastic gradient descent (SGD) algorithm. Set the maximum number of iterations to 10,000 and step size to 0.001. Plot the 2-norm of the difference between the solution at every iteration of SGD and the closed form solution obtained in part (a). Does the error converge to zero? (e) Repeat part (d) with exponentially decaying step size, i.e., t=t for every iteration t, where =0.005 and =0.995. Plot the 2-norm of the difference between the solution at every iteration of SGD and the closed form solution obtained in part (a). Compare the obtained plot with the one from part (d). (f) Repeat part (e) with exponentially decaying step size, i.e., t=t for different values of and . Plot the 2-norm of the difference between the solution at every iteration of SGD and the closed form solution for different values of (,). Explain the effect of large and small values for (,) on the performance of SGD. Based on your experiments, what values would you pick for (,) ? Explain your
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