Question: 4a. (5 pts) From the brfss DataFrame created in Q2a, use the height column as Y, and weight column as X to perform a simple
4a. (5 pts) From the brfss DataFrame created in Q2a, use the height column as Y, and weight column as X to perform a simple linear regression (See 6-regression.ppt slide #23, lr.fit). Print out the equation that is obtained by the linear regression in the form of "height = a + b * weight" (replace a and b with the values obtained from the linear regression, lr.intercept_ and lr.coef_.) (Note: you need to either make X a DataFrame or reshape X to be a n x 1 numpy array using reshape(-1, 1); see simpleRegression.ipynb.)lr = lm.LinearRegression() X = df['weight'] Y = df['height'] x = X.values.reshape(-1, 1) lr.fit(x,Y) print(f"height = {lr.intercept_} + {lr.coef_[0]} * weight")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
