Home /
Expert Answers /
Computer Science /
2-linear-regression-with-closed-form-solution-bookmark-this-page-project-due-oct-18-2023-06-5-pa170
(Solved): 2. Linear Regression with Closed Form Solution Bookmark this page Project due Oct 18, 2023 06:5 ...
2. Linear Regression with Closed Form Solution ? Bookmark this page Project due Oct 18, 2023 06:59 CDT After seeing the problem, your classmate Alice immediately argues that we can apply a linear regression model, as the labels are numbers from 0-9, very similar to the example we learned from Unit 1 . Though being a little doubtful, you decide to have a try and start simple by using the raw pixel values of each image as features. Alice wrote a skeleton code run_linear_regression_on_MNIST in main.py, but she needs your help to complete the code and make the model work. Closed Form Solution of Linear Regression 0.0/5.0 points (graded) To solve the linear regression problem, you recall the linear regression has a closed form solution: ?=(XTX+?I)?1XTY where I is the identity matrix. Write a function parameter ?. that computes this closed form solution given the features X, labels Y and the regularization Available Functions: You have access to the NumPy python library as No need to import anything. 1 def closed_form( X,Y, lambda_factor): "in Computes the closed form solution of linear regression with L2 regularization Args: x?(n,d+1) Numpy array (n datapoints each with d features plus the bias feature in the first dimension) ? - (n, ) Numpy array containing the labels (a number from 0-9) for each data point lambda_factor - the regularization constant (scalar) Returns: theta - (d+1,)Numpyarraycontainingtheweightsoflinearregression.Notethattheta[?] represents the y-axis intercept of the model and therefore x[?]=1 "n " \# YOUR CODE HERE raise NotImplementedError