← ALL PROJECTS
P-042026Modelling

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
S$58.9k
TEST MAE
-43%
VS BASELINE
0.15%
TRAIN↔TEST GAP
/ CAPTURES
The fitted model: 287,196 training points of resale price against floor area, with the linear model drawn through them in red, rising from roughly zero at 30 sqm to just over one million SGD at 300 sqm.FIT — RESALE PRICE VS FLOOR AREA
Notebook output printing a baseline MAE of 103,471.41 against a test MAE of 58,866.31, and the fitted equation: resale price SGD = -129,773.39 + (3,742.47 × floor_area_sqm).BASELINE 103K → TEST 59K MAE
Null-value check across all ten columns and a correlation heatmap between floor area, lease commence date and resale price.CORRELATION + LEAKAGE SCREEN
The scikit-learn pipeline of SimpleImputer into LinearRegression, and the evaluation cell printing training MAE 58,778 against test MAE 58,866.PIPELINE + HELD-OUT EVALUATION

A 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.

/ STACK
Pythonscikit-learnpandasseabornJupyter