Question: a) Write a code in Python whose input is a training dataset { (a, y ), ..., (a , y) } and its output is

a) Write a code in Python whose input is a training dataset { (a, y ), ..., (a , y) } and its output is the weight vector 0 in the linear regression model y = 0'(x), for a given nonlinear mapping (.). Implement two cases: i) using the closed-form solution, ii) using a gradient descent algo- rithm. b) Consider n-degree polynomials, 4(.) = 1 x x2 ... x" . Download the dataset on the course webpage and work with 'datasetl'. Run the code on the training data to compute 0 for n E {2,3}. Evaluate the regression error on both training and the test data. Report 0, training error and test error for both implementation (closed-form vs gradient descent). c) Download the dataset on the course webpage and work with 'dataset2'. Write a code in Python that applies Ridge regression to the dataset to compute 0 for a given A. Implement two cases: using a closed-form solution and using a gradient descent method. Use K-fold cross validation on the training dataset to obtain the best regularization A and apply the optimal 0 to compute the regres- sion error on test samples. Report the optimal 1, 0, test and training set errors for K E {2, 5, N}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
