Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMP2025 Introduction to Data Science

Spring 2022

Assignment 1

Instructions

Download the data sets “kc_house” from the vUWS.

Prepare a report answering the questions and submit the report in PDF format into the Turnitin link. The report should contain the relevant R codes, outputs, and comments.

Preparing report:

Either

Write your report in R-markdown, then knit it into a pdf (or if LaTeX is not available on your computer, knit into Word document and convert to PDF)

Or

Prepare your report as a Word-processed document and save as a PDF document.

Declaration

The following declaration must be included in a clearly visible and readable place on the first page of the report.

——————————————————————

By including this statement, we the authors of this work, verify that:

• I hereby certify that no part of this assignment/product has been copied from any other student’s work or from any other source except where due acknowledgement is made in the assignment.

• No part of this assignment/product has been written/produced for us by another person except where such collaboration has been authorised by the subject lecturer/tutor concerned.

• I am aware that this work may be reproduced and submitted to plagiarism detection software       programs for the purpose of detecting possible plagiarism (which may retain a copy on its database

for future plagiarism checking).

• I hereby certify that we have read and understand what the School of Computer, Data and           Mathematical Sciences defines as minor and substantial breaches of misconduct as outlined in the learning guide for this unit.

——————————————————————

Note: An examiner or lecturer/tutor has the right not to mark this project report if the above declaration has not been added to the cover of the report.

Question 01 - Regression

Use the “kc_house” dataset. The dataset describes the price of 341 houses in King County, Washington State, USA with 10 different attributes about the house described as follows.

id: Unique identifier for a house

price: Price of house in ten thousand dollars

bedrooms: No. of bedrooms

bathrooms: No. of bathrooms

sqft_living: Square footage of the apartments interior living space in thousand sq.ft sqft_lot: Square footage of the land space in thousand sq.ft

floors: Number offloors

waterfront: A dummy variable for whether the apartment was overlooking the waterfront or not (0  No; 1  Yes)

sqft_living15: Square footage of interior housing living space for the nearest 15 neighbours in thousand sq.ft

sqft_lot15: Square footage of the land lots of the nearest 15 neighbours in thousand sq.ft

1)   Construct the matrix plot and correlation matrix (consider only relevant variables). Comment on the relationship among variables. [10 marks]

2)   Simple Linear Regression [20 marks]

i.      Fit a model to predict price in terms of sqft_living.

ii.      Discuss the significance of the slope parameter estimate. (Write down the relevant hypothesis)

iii.      Discuss the accuracy of the parameter estimates. (Standard errors/confidence intervals)

iv.      Discuss the model accuracy. (R-squared, residual standard error etc.)

v.      Check for the model assumptions.

vi.      Write down the model equation.

vii.      Predict the price of a house with 10, 000 sq.ft of the apartments interior living space (sqft_living).

3)   Multiple Linear Regression [25 marks]

i.      Fit a model to predict price in terms of all the other quantitative predictors (numerical predictors).

ii.      Remove the insignificant variables and fit a model including the rest of the variables.

iii.      Add the interaction term bedrooms*floors to the model above. (part ii)

iv.      Comment on the significance of the parameter estimates of the model above. (part iii)

v.      Check for the model assumptions. (model in part iii)

vi.      Compare and comment on the accuracy of the models in part ii and part iii. Suggest the best model.

vii.      Fit a polynomial regression model to predict price using sqft_living of order 2 and test the model significance.

Question 02 - Classification

Use the same data set.

Create a new categorical variable price_cat” by assigning value of High” if price > median(price) else “Low” . Remove the variable price from the dataset.

Divide the dataset into two sets namely training set and test set by assigning 75% of the observations to training set and the rest of the observations to the test set. (Hint: Use set.seed(100) for reproducible results).

1)   Logistic Regression [20 marks]

i.       Construct Logistic regression model for price_cat” in terms of all the other variables (Use training dataset).

ii.       Comment on the significance of the parameter estimates.

iii.       Improve  the  model  based  on  the  output  in  part  i.  (Hint:  Consider  the significance of the parameter estimates).

iv.       Predict the  outputs for the  test  dataset  using the  model  in  part  iii  and construct misclassification table.

v.       Calculate the misclassification rate. (Use test dataset).

2)   Decision Tree [20 marks]

i.       Build a classification tree model for the training dataset.

ii.       Use cross-validation and choose the best size for the tree in part i.

iii.       Build the tree with the best size (pruning) obtained in part ii.

iv.       Predict the  outputs for the  test  dataset  using the  model  in  part  iii  and construct misclassification table.

v.       Calculate the misclassification rate. (Use test dataset).

3)   Compare the models in part 1) and part 2) and suggest the best model. (Give reasons). [5 marks]