Question: I need answer for Question 3 4. [44 points] Write a program to find the coefficients for a linear regression model for the dataset provided

I need answer for Question 3

I need answer for Question 3 4. [44 points] Write a program

4. [44 points] Write a program to find the coefficients for a linear regression model for the dataset provided (data2.txt). Assume a linear model: y=w0+w1x. You need to 1) Plot the data (i.e., x-axis for the 1st column, y-axis for the 2nd column), and use Python to implement the following methods to find the coefficients: 2) Normal equation, and 3) Gradient Descent using batch AND stochastic modes respectively: a) Split dataset into 80% for training and 20% for testing. b) Plot MSE vs. iteration of each mode for both training set and testing set; compare batch and stochastic modes in terms of accuracy (of testing set) and speed of convergence. (You need to determine an appropriate termination condition, e.g., when cost function is less than a threshold, and/or after a given number of iterations.) c) Plot MSE vs. learning rate (using 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1) and determine the best learning rate. Please implement the algorithms by yourself and do NOT use the fit() function of the library

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!