Lab 7: Linear Regression Big Lab DS
Date: July 14
Time: 1:00-5:00 PM
TA: Jianhao Huang / Shanmu Wang
Overview
Today we will work through an end-to-end dataset workflow. The goal is not just to call LinearRegression, but to practice the full process:
- load a real dataset;
- inspect rows, columns, missing values, and summary statistics;
- make exploratory visualizations;
- clean and prepare features;
- handle non-numeric columns and missing values;
- split data into training and testing sets;
- fit a linear regression model;
- evaluate prediction quality with an error metric such as MSE.
Materials
Download the Lab 7 notebook folder from the password-protected Box materials folder:
Open notebook lab materials on Box
Ask Eric for the password.
Open the folder:
Lab_07_Linear_Regression_Big_Lab
The folder should include:
| File | Purpose |
|---|---|
Lab7_big_lab_practice.ipynb |
Practice notebook. Run this first to review the end-to-end regression workflow. |
Lab07_Linear_Regression_Big_Lab.ipynb |
Main lab notebook. This is the notebook you will complete after the practice notebook. |
housing.csv |
Practice dataset used by the practice notebook. |
AB_NYC_2019.csv |
Main NYC Airbnb dataset used by the big lab. |
california.png |
Image used by the practice notebook. |
nyc.png |
Image used by the main lab notebook. |
Notebook Order
Start with the practice notebook:
Lab7_big_lab_practice.ipynb
Run it from top to bottom before opening the main lab. This notebook is meant to refresh the full regression pipeline and help you remember the common steps before you work more independently.
Then open the main notebook:
Lab07_Linear_Regression_Big_Lab.ipynb
In the main lab, you will apply the same end-to-end machine learning steps to the NYC Airbnb dataset. The prediction task is to use listing features to predict Airbnb rental price.
Main Lab Tasks
In the main notebook, you should complete these parts:
- Load
AB_NYC_2019.csv. - Inspect the data and drop columns that are not useful for the model.
- Visualize room type, borough, reviews, location, and price patterns.
- Create a binned
price_catfeature for stratified splitting. - Handle missing values.
- Convert non-numeric features into numeric features.
- Split the data into training and testing sets.
- Fit a linear regression model to predict
price. - Evaluate the model using MSE and explain what the result means.
Checkoff
Show the TA:
- The practice notebook ran successfully.
- The main notebook loads the NYC Airbnb dataset.
- At least two completed visualizations.
- The cleaned/prepared feature table.
- The trained linear regression model and MSE result.