Logo Lanfrica

Aymannel04/Morocco-housing-project

Domain:

socioeconomic

Record type:

project
Creator:
Aym
Host:
# Morocco Housing Price Prediction 🏠 End-to-end ML project predicting apartment prices in Rabat, Morocco β€” from web scraping to deployment. **πŸ”— Live Demo:** (morocco-housing-project.str…) ## Overview This project covers the full data science pipeline: **Scraping (Selenium) β†’ Cleaning (regex/Pandas) β†’ Modeling (Random Forest) β†’ Deployment (Streamlit).** Unlike most student projects that rely on curated Kaggle datasets, the data here was self-collected from Avito.ma β€” making this as much a data engineering project as a machine learning one. ## Problem Statement Real estate pricing in Morocco lacks transparent, data-driven benchmarks. This project builds a baseline price estimator for Rabat apartments using surface area and neighborhood as primary signals β€” designed to be expandable to other Moroccan cities (V2). ## Data Pipeline ### 1. Web Scraping (`src/scraper.py`) - **Tool:** Selenium with WebDriverManager - **Source:** avito.ma β€” apartment sales listings in Rabat - **Robustness:** Explicit waits (`WebDriverWait`), per-ad error handling, randomized delays (2–5s) to mimic human browsing - **Output:** Raw CSV with listing text, extracted price, and source URL ### 2. Data Cleaning (`src/cleaning.py`) - Regex-based extraction of price, surface area, and location from unstructured listing text - Filters applied: - Price β‰₯ 10,000 DH (removes rentals and noise) - Surface > 20 mΒ² (removes obvious errors) - Drops rows with missing price or surface - Custom neighborhood parser with fallback logic for non-standard formats ### 3. Modeling (`src/model.py`) - **Algorithm:** Random Forest Regressor (`n_estimators=100`) - **Pipeline:** `ColumnTransformer` with `OneHotEncoder` for categorical features (`quartier`, `ville`), passthrough for numerical (`surface_final`) - **Evaluation:** Mean Absolute Error on a held-out 20% test set - **Artifact:** Serialized model (`models/price_predictor.pkl`) for the Streamlit app ## Dataset (V1) | Property | Value | …