Skip to content

Latest commit

 

History

History
115 lines (73 loc) · 3.66 KB

File metadata and controls

115 lines (73 loc) · 3.66 KB

2.18 Homework

Solution: homework.ipynb

Dataset

In this homework, we will use the New York City Airbnb Open Data. You can take it from Kaggle or download from here if you don't want to sign up to Kaggle.

The goal of this homework is to create a regression model for prediction apartment prices (column 'price').

EDA

  • Load the data.
  • Look at the price variable. Does it have a long tail?

Features

For the rest of the homework, you'll need to use only these columns:

  • 'latitude',
  • 'longitude',
  • 'price',
  • 'minimum_nights',
  • 'number_of_reviews',
  • 'reviews_per_month',
  • 'calculated_host_listings_count',
  • 'availability_365'

Select only them.

Question 1

Find a feature with missing values. How many missing values does it have?

Question 2

What's the median (50% percentile) for variable 'minimum_nights'?

Split the data

  • Shuffle the initial dataset, use seed 42.
  • Split your data in train/val/test sets, with 60%/20%/20% distribution.
  • Make sure that the target value ('price') is not in your dataframe.
  • Apply the log transformation to the price variable using the np.log1p() function.

Question 3

  • We need to deal with missing values for the column from Q1.
  • We have two options: fill it with 0 or with the mean of this variable.
  • Try both options. For each, train a linear regression model without regularization using the code from the lessons.
  • For computing the mean, use the training only!
  • Use the validation dataset to evaluate the models and compare the RMSE of each option.
  • Round the RMSE scores to 2 decimal digits using round(score, 2)
  • Which option gives better RMSE?

Question 4

  • Now let's train a regularized linear regression.
  • For this question, fill the NAs with 0.
  • Try different values of r from this list: [0, 0.000001, 0.0001, 0.001, 0.01, 0.1, 1, 5, 10].
  • Use RMSE to evaluate the model on the validation dataset.
  • Round the RMSE scores to 2 decimal digits.
  • Which r gives the best RMSE?

If there are multiple options, select the smallest r.

Question 5

  • We used seed 42 for splitting the data. Let's find out how selecting the seed influences our score.
  • Try different seed values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].
  • For each seed, do the train/validation/test split with 60%/20%/20% distribution.
  • Fill the missing values with 0 and train a model without regularization.
  • For each seed, evaluate the model on the validation dataset and collect the RMSE scores.
  • What's the standard deviation of all the scores? To compute the standard deviation, use np.std.
  • Round the result to 3 decimal digits (round(std, 3))

Note: Standard deviation shows how different the values are. If it's low, then all values are approximately the same. If it's high, the values are different. If standard deviation of scores is low, then our model is stable.

Question 6

  • Split the dataset like previously, use seed 9.
  • Combine train and validation datasets.
  • Fill the missing values with 0 and train a model with r=0.001.
  • What's the RMSE on the test dataset?

Submit the results

Submit your results here: https://forms.gle/2N9GkTr1AgNeZ8hD7.

If your answer doesn't match options exactly, select the closest one.

Deadline

The deadline for submitting is 20 September 2021, 17:00 CET. After that, the form will be closed.

Nagivation