Skip to content

Housing Price Prediction (Regression)

Given housing data, you will:

  • Explore price drivers
  • Prepare features (missing values, encoding)
  • Build a baseline regression pipeline
diagram Housing regression pipeline mermaid
From raw listings to a baseline price-prediction model.
Load housing
import pandas as pd
 
df = pd.read_csv("data/housing.csv")
print(df.shape)
print(df.head())
Price distribution
import seaborn as sns
import matplotlib.pyplot as plt
 
plt.figure(figsize=(7, 4))
sns.histplot(df["price"], bins=30, kde=True)
plt.title("House price distribution")
plt.tight_layout()
plt.show()
sketch House price distribution (right-skewed) p5.js
Most homes cluster on the left; a long tail of expensive homes stretches right.
  • Identify numeric/categorical
  • Impute missing values
  • One-hot encode
  • Scale numeric (optional)

Use the Phase 4 pipeline approach.

Baseline regression (concept)
# Use scikit-learn Pipeline + ColumnTransformer
# Choose a baseline model like LinearRegression or RandomForestRegressor
# Evaluate using MAE/RMSE on a held-out test set
  • Key drivers (most correlated features)
  • Data quality issues
  • Baseline model performance

Exercise 3 – One-hot encode a categorical column

Section titled “Exercise 3 – One-hot encode a categorical column”

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading