Methodology¶
Dataset¶
The Ames Housing dataset contains 1,460 training observations of residential property sales in Ames, Iowa, with 79 features covering structural characteristics, quality assessments, and sale conditions.
This project uses a subset of 12 features selected for their predictive relevance and interpretability. Feature selection was guided by correlation analysis against the target variable (SalePrice) and domain reasoning about which characteristics most directly drive buyer valuation.
Selected Features¶
| Feature | Description | Type |
|---|---|---|
OverallQual |
Overall material and finish quality (1–10) | Ordinal |
FullBath |
Bathrooms above grade | Integer |
YearBuilt |
Year of construction | Integer |
YearRemodAdd |
Year of most recent remodel | Integer |
MasVnrArea |
Masonry veneer area (sq ft) | Continuous |
GrLivArea |
Above-ground living area (sq ft) | Continuous |
TotalBsmtSF |
Total basement area (sq ft) | Continuous |
1stFlrSF |
First floor area (sq ft) | Continuous |
TotRmsAbvGrd |
Total rooms above grade | Integer |
Fireplaces |
Number of fireplaces | Integer |
GarageCars |
Garage capacity (number of cars) | Integer |
GarageArea |
Garage size (sq ft) | Continuous |
Why these 12?
OverallQual is the single strongest predictor of sale price in the Ames dataset — it captures a subjective but powerful signal that square footage alone misses. The area features (GrLivArea, TotalBsmtSF, 1stFlrSF, GarageArea) capture size from multiple angles. Year features capture depreciation and renovation value. Fireplaces and GarageCars are discrete amenity signals that consistently show up in feature importance rankings.
Models¶
Three regression models were trained to compare performance across different assumptions about the data.
Linear Regression¶
The baseline. Assumes a linear relationship between features and sale price — that each additional square foot of living area contributes a fixed dollar amount regardless of the property's other characteristics.
Strengths: Fast, interpretable, easy to diagnose.
Weakness: Real estate pricing is not linear. A 500 sq ft increase in a 4,000 sq ft luxury home contributes differently to price than the same increase in a 1,000 sq ft starter home. Linear regression cannot capture this interaction.
Ridge Regression¶
A regularised extension of linear regression. Ridge adds an L2 penalty term to the loss function that shrinks coefficient magnitudes toward zero, which reduces overfitting when features are correlated with each other.
In housing data, features like GrLivArea, 1stFlrSF, and TotalBsmtSF are positively correlated — larger homes tend to have larger everything. Ridge handles this multicollinearity more gracefully than standard linear regression.
Strengths: More robust than OLS when features are correlated.
Weakness: Still linear. The ceiling on predictive power is lower than non-linear methods.
Random Forest¶
An ensemble of decision trees trained on random subsets of the data and features. Each tree makes an independent prediction; the forest averages them. This approach captures non-linear interactions between features without requiring manual feature engineering.
Strengths: Handles non-linearity and feature interactions naturally. Robust to outliers. Provides feature importance scores.
Weakness: Less interpretable than linear models. Slower to train on large datasets.
Training Procedure¶
The notebook follows a standard supervised learning workflow:
- Load and inspect the dataset
- Handle missing values
- Encode categorical features where necessary
- Select the 12 features listed above
- Split into training and test sets (80/20)
- Fit each model on the training set
- Evaluate on the held-out test set
- Serialise all three models to
.pklfiles
The Random Forest model was selected for the production Streamlit app based on test set performance. See Results for the comparison.