In [ ]:
 

Download (right-click, save target as ...) this page as a jupyterlab notebook Lab26-TH


Exercise Set 26: Regression Models

LAST NAME, FIRST NAME

R00000000

ENGR 1330 Exercise Set 26 - Homework


Exercise:

In the http://54.243.252.9/engr-1330-webroot/4-Databases/CarsDF.csv file, you will find a dataset with information about cars and motorcycles including their age, kilometers driven (mileage), fuel economy, enginer power, engine volume, and selling price. Follow the steps and answer the questions.

  • Step1: Read the "CarsDF.csv" file as a dataframe. Explore the dataframe and in a markdown cell briefly describe it in your own words.
  • Step2: Calculate and compare the correlation coefficient of the "selling price" with all the other parameters (execpt for "name", of course!). In a markdown cell, explain the results and state which parameters have the strongest and weakest relationship with "selling price" of a vehicle.
  • Step3: Use linear regression modeling in primitive python and VISUALLY assess the quality of a linear fit with Age as the predictor, and selling price as outcome. Explain the result of this analysis in a markdown cell.
  • Step4: Use linear regression modeling with statsmodels and VISUALLY assess the quality of a linear fit with fuel economy as the predictor, and selling price as outcome. Explain the result of this analysis in a markdown cell.
  • Step5: Use linear regression modeling with statsmodels and VISUALLY assess the quality of a linear fit with engine volume as the predictor, and selling price as outcome. Explain the result of this analysis in a markdown cell.
  • Step6: In a markdown cell, explain which of the three predictors in steps 3,4, and 5, was a better predictor (resulted in a better fit ) for selling price?
  • Step7: Use multiple linear regression modeling with scikit-learn and use all the parameters (execpt for "name", of course!) to predict selling price. Then, use this model to predict the selling price of a car that has the following charactristics and decide whether this prediction is reliable in your opinion:
    • 2 years old
    • has gone 17000 km
    • has fuel economy measure of 24.2 kmpl
    • has an engine power of 74 bhp
    • has en engine volume of 1260 CC
In [1]:
# code here
# Step1:
import requests # Module to process http/https requests
remote_url="http://54.243.252.9/engr-1330-webroot/4-Databases/CarsDF.csv"  # set the url
rget = requests.get(remote_url, allow_redirects=True)  # get the remote resource, follow imbedded links
open('CarsDF.csv','wb').write(rget.content); # extract from the remote the contents, assign to a local file same name
# Step1B
# make into a dataframe
# whats in the dataframe

On Step1: [Double-Click to edit]

In [2]:
# Step2:.

On Step2: [Double-Click to edit]

In [3]:
#Step3:

On Step3: [Double-Click to edit]

In [4]:
# Step4:

On Step4: [Double-Click to edit]

In [5]:
# Step5:

On Step5: [Double-Click to edit]

In [6]:
# Step6:

On Step6: [Double-Click to edit]

In [7]:
#Step7:

On Step7: [Double-Click to edit]

In [ ]: