Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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++

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions