Question

Part 4 (40 points) Implement a gradient descent function for linear regression: W₁+1 = Wi - ai The function will take trainData (RDD of Labeled Point) as an argument and return

a tuple of weights and training errors. Reuse the code that you have written in Part 1 and 2. Initialize the elements of vector w = 0 and a = 1. Update the value of a in ith iteration using the formula: α₂ = Σ(w.x; - u;)x; Test the function on and example RDD. Run it for 5 iterations and print the results. Q

Fig: 1