ML pipeline forecasting 3/5-year future real estate prices in Tunisia — CRISP-DM methodology, dual XGBoost models (villa/apartment), quantile-regression uncertainty intervals, and a Streamlit valuation demo.
# Predicting Future Real Estate Prices in Tunisia
ML pipeline forecasting 3/5-year future real estate prices in Tunisia — CRISP-DM
methodology, dual XGBoost models (villa/apartment), quantile-regression uncertainty
intervals, and a Streamlit valuation demo.
Six-week, internship project. Built with the **CRISP-DM** methodology:
7 raw sources merged into a 42,161-row dataset, cleaned down to 12,971 usable
listings, feature-engineered, and modeled with two specialized XGBoost regressors
plus a quantile-regression uncertainty layer.
## Results
| Segment | R² (test set) | Test set size |
|------------|---------------|----------------|
| Villa | **0.806** | 653 listings |
| Apartment | **0.570** | 1,942 listings |
- 95% prediction intervals cover the true price **93.9%** of the time on unseen data.
- Median interval width ≈ 534,191 TND (wide, reflecting the underlying R²).
## Architecture
```
7 raw sources ──► merge into shared schema (42,161 rows)
│
▼
clean, impute, deduplicate (12,971 rows)
│
▼
feature engineering: postal code, region, tourism-zone flag,
controlled price-trend index (2018 base year)
│
▼
┌────────────────────┴────────────────────┐
▼ ▼
Villa XGBoost model Apartment XGBoost model
(no postal code/region — (+ postal code, region —
too little data to support it) enough data to benefit)
│ │
└────────────────────┬────────────────────┘
▼
quantile-regression models (2.5th/97.5th pct)
│
▼
forecast_price(property_features, years_ahead)
│
▼
Streamlit test interface
```
**Why two separate models instead of one?** Adding richer location features
(postal code, region) to a single combined model helped apartments slightly
(R² 0.536 → 0.550) but hurt villas badly (R² 0.734 → 0.641) — villa listings
are too sparse for fine-grained location categories, so the model overfit.
Splitting into two models, each with a feature set tai …