Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

2.11 LAB: Importing packages Import the necessary modules and read in a csv file. The homes dataset contains 18 features giving the characteristics of

student submitted image, transcription available below


student submitted image, transcription available below


 

2.11 LAB: Importing packages Import the necessary modules and read in a csv file. The homes dataset contains 18 features giving the characteristics of 76 homes being sold. The modules will be used with the homes.csv file to perform a linear regression. Linear regression will be covered in a different chapter. Import the NumPy and pandas packages with the aliases used in this material 13 Import the function Linear Regression from the sklearn.linear_model package Read in the csv file homes.csv Ex: If the csv file homes_small.csv is used instead of homes.csv, the output is: The intercept of the regression is 249.522 The slope of the regression is 36.758 498020 2296122 Stay? LAB ACTIVITY 2.11.1: Importing packages main.py 1 = Import NumPy and pandos 2 # Your code here 3 4 # Import the Linear Regression function from sklearn. Linear model 5 # Your code here 6 7 # Read in the csv file homes.csv 8 homes pd.# Your code here 9 10 # Store relevant columns as variables 11 y homes['Price'] = 12 y = np.reshape(y.values, (-1,1)) 13X=> homes ['Floor'] 14 x = np.reshape(X. values, (-1,1)) 15 16 # Fit a Least squares regression model 17 linModel = Linear Regression() 18 linModel.fit(x,y) 19 20 # Print the intercept and stope of the regression 21 print('The intercept of the regression is, end-"") 22 print('%. 3f % linModel. Intercept_) 23 24 print("The slope of the regression is, end-"") 25 print('%.3f % 11nModel.coef 0/1 Load default template... LAB ACTIVITY 2.11.1: Importing packages 0/1 main.py Load default template... 1 # Import NumPy and pandas 2 # Your code here 3 4 # Import the Linear Regression function from sklearn. Linear_model 5 # Your code here 6 7 # Read in the csv file homes.csv 8 homes = pd.# Your code here 9 10 # Store relevant columns as variables 11 y = homes['Price'] 12 y = np.reshape(y.values, (-1,1)) 13 X = homes['Floor'] 14 X = np.reshape(X.values, (-1,1)) 15 16 # Fit a Least squares regression model 17 linModel = LinearRegression() 18 linModel.fit(x,y) 19 20 # Print the intercept and slope of the regression 21 print('The intercept of the regression is ', end="") 22 print('%.3F' % linModel.intercept_) 23 24 print('The slope of the regression is ', end="") 25 print('%.3f' % linModel.coef)] Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

To complete the given exercise you need to follow specific instructions on importing necessary packages and performing a linear regression using Pytho... 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_2

Step: 3

blur-text-image_3

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students explore these related Programming questions