HDB RESALE PRICE MODEL
A linear regression over 287,196 Singapore HDB resale transactions, built as an honest end-to-end scikit-learn pipeline: correlation and multicollinearity screening, leakage checks, imputation kept inside the pipeline, and a held-out test set measured against a mean-predictor baseline rather than against itself.
SOURCE ON GITHUB
FIT — RESALE PRICE VS FLOOR AREA
BASELINE 103K → TEST 59K MAE
CORRELATION + LEAKAGE SCREEN
PIPELINE + HELD-OUT EVALUATIONA linear regression predicting Singapore HDB resale prices from floor area across 287,196 transactions — built less as a modelling exercise than as a discipline exercise in not fooling yourself.
The problem
A regression will happily report a great score on the data it was fit to. The interesting question is never 'does it fit?' but 'does it beat a trivial baseline on data it has never seen, and is it fitting signal or leakage?' — and answering that takes more care than the model itself does.
Approach
- Screen every column first: null counts, cardinality, and a correlation matrix to catch multicollinearity before it reaches the model.
- Check explicitly for leakage — features that encode the answer or information from the future.
- Keep imputation inside a scikit-learn pipeline (SimpleImputer → LinearRegression) so the transform is fit on training data only and can never leak across the split.
- Benchmark against a mean-predictor baseline, not against the model's own training score.
- Compare training and test MAE side by side as the overfitting check.
Results
Test MAE of S$58,866 against a baseline of S$103,471 — a 43% improvement on unseen data. Training MAE came in at S$58,778, a 0.15% gap from test, so the model generalises rather than memorises. The fitted relationship: resale price ≈ −129,773 + 3,742 × floor_area_sqm, with floor area correlating 0.80 with price.