Part I: Linear regression using closed-form solution (10 points)
[5 pts] Write a function [w] = lr_solve_closed(X_train, y_train) that computes the closed-form least-squares solution to linear regression, using the Moore-Penrose inverse, as derived in class. Use the Matlab function pinv. The body of this function only requires one line of code.
[5 pts] Also write a function [y_pred] = lr_predict(X_test, w) that uses the weights computed above, to predict a label for a new test sample.
Part II: Linear regression using gradient descent (20 points)
Now implement the gradient descent solution, in a function [w] = lr_solve_gd(X_train, y_train, iters, eta).
Inputs: same as for lr_solve_closed, plus:
Outputs: same as for lr_solve_closed.
Part III: Testing on the Wine Quality dataset (20 points)
You will use the Wine Quality dataset. Use only the red wine data. The goal is to find the quality score of some wine based on its attributes. Include your code in a script regression.m. In a file report.pdf or report.docx, report the L2 error (described below) for the closed-form and gradient descent solutions.
Submission: Please include the following files: