2.11 LAB: Importing packages Import the necessary modules and read in a csv file. The homes...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
What is wrong with the following variable declarations? If wrong, explain. If correct (nothing wrong), write "correct". double 1st_var = 10; int var2; int var3 = var2; string name="var3"; double...
-
The financial statements of Jean Coutu are presented in Appendix B following the financial statements for Shoppers Drug Mart in Appendix A. Instructions (a) For each company, calculate or find the...
-
What does the term system mean in environmental science?
-
Jason Cannon purchased a defective tractor for which Cannon brought numerous causes of action against Bodensteiner Implement Company (Bodensteiner). One of the claims was breach of express...
-
The following transactions were completed by Simmons Inc., whose fiscal year is the calendar year: 2012 July 1. Issued $64,000,000 of 10-year, 12% callable bonds dated July 1, 2012, at a market...
-
Let U={1,2,3,...,10}, A={1,3,5,7}, B={1,2,3,4}, and C={3,4,6,7,9}. Find BC'
-
Jarrett Company issued 600 shares of no-par common stock for $8,800. Which of the following journal entries would be made if the stock has no stated value? Select one: . Cash 8,800 Common Stock 600...
-
What are the prospective remedies available to mitigate the causes of greenhouse gas emissions?
-
Relevant Financial Policies and Procedures: Analyze whether the information in financial policies and processes is sufficient and appropriate. Determine that these documents are up-to-date...
-
Why is Haiti suffering from supply and demand issues
-
For a certain run, the following data is obtained: Mass of cart = 250 g, hanging mass = 23 g, distance traveled by the cart = 41 cm, initial speed of the cart = 0.33 m/s, Final speed of the cart =...
-
Sean is planning to go on a Europe vacation to celebrate Leanne's retirement 6 years from now. The estimated expense for the couple is $100,000. If he can earn 4% compounded quarterly, how much will...
-
In this exercise, molecular model kits will be used to give the student a better visual understanding of the three-dimensional nature and spatial relationships that occur in organic molecules. These...
-
What is the role of business risk analysis in the audit planning process?
-
In 2012, Margaret and John Murphy are married taxpayers who file a joint tax return with AGl of $25,000. During the year they incurred the following expenses: Hospitalization insurance...
-
Mark owns his home and has a $250,000 mortgage related to his purchase of the residence. When his daughter went to college in the fall of 2012, he borrowed $20,000 through a home equity loan on his...
-
Van makes an investment in a partnership in 2012. Van's capital contributions to the partnership consisted of $30,000 cash and a building with an adjusted basis of$70,000, subject to a nonrecourse...
-
The order of payments for unsecured priority claims in a Chapter 7 bankruptcy case is such that a. Tax claims of governmental units are paid before claims for administrative expenses incurred by the...
-
Narco is in serious financial difficulty and is unable to meet current unsecured obligations of $30,000 to some 14 creditors who are demanding immediate payment. Narco owes Johnson $5,000, and...
-
Your client is insolvent under the federal bankruptcy law. Under the circumstances a. So long as the client can meet current debts or claims by its most aggressive creditors, a bankruptcy proceeding...
Study smarter with the SolutionInn App