Files
ML-portfolio/docs/Housing-Price-Regression.md
2026-07-11 17:42:47 +03:30

50 lines
2.0 KiB
Markdown

# Housing Price Regression
End-to-end regression pipeline predicting median house value from California census-block data (20,640 rows).
## The question driving the approach
Which features actually predict house value, and can a simple, interpretable pipeline get close to what a more complex model would achieve?
## Exploratory analysis
Before modeling, checking which raw features correlate with the target:
![Correlation with target](images/housing-correlation.png)
`median_income` stood out as by far the strongest predictor (r ≈ 0.69) — every later decision, including the stratified train/test split, was built around that finding.
## Model comparison via cross-validation
Rather than trusting a single train-set score, both baseline models were evaluated with 5-fold cross-validation to get an honest estimate of real-world error:
![Cross-validation MAE comparison](images/housing-cv-comparison.png)
## What the tuned model actually relies on
After `GridSearchCV` tuning, inspecting which engineered features the Decision Tree leaned on most:
![Feature importance](images/housing-feature-importance.png)
The engineered ratio features (rooms-per-house, etc.) pulled real weight here — not just the raw census counts, which justified the extra feature engineering step.
## Final result
Test set touched exactly once, after every modeling decision was locked in:
![Actual vs predicted](images/housing-actual-vs-predicted.png)
| Metric | Value |
|---|---|
| MAE | $40,600 |
| RMSE | $61,901 |
| R² | 0.72 |
| 95% CI on RMSE | [$59,141 — $64,542] |
The scatter shows the model tracks the trend well but underpredicts at the high end — expected, since expensive homes are rarer and harder to fit precisely with limited high-price training examples.
## Notebooks
- [`housing-ml-notebook.ipynb`](../housing-price-regression/housing-ml-notebook.ipynb) — original work
- [`housing_ml_notebook_polished.ipynb`](../housing-price-regression/housing_ml_notebook_polished.ipynb) — AI-assisted documentation pass