Housing Price Prediction (Regression)
Given housing data, you will:
- Explore price drivers
- Prepare features (missing values, encoding)
- Build a baseline regression pipeline
Analysis pipeline
Section titled “Analysis pipeline”flowchart LR A["Raw housing data"] --> B["Explore
(price distribution)"] B --> C["Preprocess
(impute, encode, scale)"] C --> D["Train
(baseline regressor)"] D --> E["Evaluate
(MAE / RMSE)"]
Step 1: Load
Section titled “Step 1: Load”import pandas as pd
df = pd.read_csv("data/housing.csv")
print(df.shape)
print(df.head())Step 2: EDA: price distribution
Section titled “Step 2: EDA: 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()Visualize it
Section titled “Visualize it”Step 3: Baseline preprocessing
Section titled “Step 3: Baseline preprocessing”- Identify numeric/categorical
- Impute missing values
- One-hot encode
- Scale numeric (optional)
Use the Phase 4 pipeline approach.
Step 4: Train baseline model
Section titled “Step 4: Train baseline model”# Use scikit-learn Pipeline + ColumnTransformer
# Choose a baseline model like LinearRegression or RandomForestRegressor
# Evaluate using MAE/RMSE on a held-out test setDeliverable
Section titled “Deliverable”- Key drivers (most correlated features)
- Data quality issues
- Baseline model performance
🧪 Try It Yourself
Section titled “🧪 Try It Yourself”Exercise 1 – Check missing values
Section titled “Exercise 1 – Check missing values”Exercise 2 – Correlation with price
Section titled “Exercise 2 – Correlation with price”Exercise 3 – One-hot encode a categorical column
Section titled “Exercise 3 – One-hot encode a categorical column”pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading