Question: Below is the code to be modify. MODIFY THE ABOVE CODE TO MAKE IT IMPLEMENT THE STOCHASTIC GRADIENT DESCENT ALGORITHM SOLVING THE SAME PROBLEM (ALL

 Below is the code to be modify. MODIFY THE ABOVE CODE

Below is the code to be modify.

TO MAKE IT IMPLEMENT THE STOCHASTIC GRADIENT DESCENT ALGORITHM SOLVING THE SAME

MODIFY THE ABOVE CODE TO MAKE IT IMPLEMENT THE STOCHASTIC GRADIENT DESCENT ALGORITHM SOLVING THE SAME PROBLEM (ALL CODES MUST BE IN "r")?

1. In the lecture, we wrote an R function to apply the batch gradient descent algorithm to fit a linear regression model describing the relationship between the variables dist and speed in the cars data. Modify that function to make it implement the stochastic gradient descent algorithm to solve the same probem. Compare the results and computing time for the two algorithms (batch versus stochastic gradient descent). To ensure a fair comparison, make sure to use the same inputs for both algorithms (initial values, learning rate, convergence threshhold, and maximum number of iterations). For these paramters, use the samee inputs we used in the lecture. In your comparison, include the following: gd. lreg max.iter) { converged = TRUE return (cat("Intercept at last iter:", bo, ' ', "Slope at last iter:", bi,' ', "MSE at last iter values:", MSE_new)) #Run the function on the cars data gd.lreg (speed, dist, 0.001, le-10, 1000000) 1. In the lecture, we wrote an R function to apply the batch gradient descent algorithm to fit a linear regression model describing the relationship between the variables dist and speed in the cars data. Modify that function to make it implement the stochastic gradient descent algorithm to solve the same probem. Compare the results and computing time for the two algorithms (batch versus stochastic gradient descent). To ensure a fair comparison, make sure to use the same inputs for both algorithms (initial values, learning rate, convergence threshhold, and maximum number of iterations). For these paramters, use the samee inputs we used in the lecture. In your comparison, include the following: gd. lreg max.iter) { converged = TRUE return (cat("Intercept at last iter:", bo, ' ', "Slope at last iter:", bi,' ', "MSE at last iter values:", MSE_new)) #Run the function on the cars data gd.lreg (speed, dist, 0.001, le-10, 1000000)

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!