Question: Linear regression coding problem. USE C++ Given a dataset D= {(Ii, yi), i = 1, 2, ...,N} where both X; and yi are scalars. We
Linear regression coding problem. USE C++


Given a dataset D= {(Ii, yi), i = 1, 2, ...,N} where both X; and yi are scalars. We define the line as y = Bo + B,x. Thus, in order to find the best 'line', we only need to find the best Bo and B, that explain our data well. To calculate the best B1, which is denoted by B1, we use Bi 2 (zi - X)(1 ) (1) -X) where X = avg(X) = and Y = avg(Y) = N =1 Yi (2) N To calculate the best Bo, which is denoted by Bo, we use Bo = Y - X (3) Simple dataset: D = [(5, 43.1), (7.1, 32.1), (34.5, 40.3), (13,39.3), (1.5, 47.7)] Xnew = [1, 2, 3, 4, 5] 1. Write a function called train to find the best and by using the simple dataset D above. (15 pts) 2. Write a function called predict to make predictions on the Xnew above. (10 pts) 3. Write a main function to call the two functions defined above. Print out the parameters Bo and , as well as the predictions (a vector new) for Xnew: (15 pts) 4. Remember to use the three-file structure' to arrange all your codes. (10 pts)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
