A Streamlit web application that predicts Singapore HDB resale flat prices. This app loads an XGBoost model and necessary data files (scaler, postal code data) directly from its local directory and displays an interactive transaction map hosted externally.
- Interactive UI: User-friendly input for property details via Streamlit.
- Local Model & Data:
- Pre-trained XGBoost model (
model.bst
) loaded locally. - Data scaler (
scaler.joblib
) applied for consistent feature scaling. - Postal code data (
postal_data.json
) for location-based information.
- Pre-trained XGBoost model (
- Integrated Transaction Map:
- Displays HDB resale transactions on an interactive map via an iframe to an externally hosted HTML file.
- Clickable markers show recent transaction details for each block.
- Responsive Design: Includes CSS adjustments for better viewing on mobile devices.
- Theme Toggle: Light and Dark mode options.
- Dockerized: Ready for containerization.
.
├── app.py
├── model.bst
├── scaler.joblib
├── postal_data.json
├── Dockerfile
├── requirements.txt
└── README.md
If you are setting this up from a Git repository:
git clone https://github.com/seehiong/hdb-price-predictor-app.git
cd hdb-price-predictor-app
If you have the files directly, ensure all files listed in the "Project Structure" (excluding the map HTML itself from the local app directory) are in your working directory.
It's recommended to use a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
Then install the required packages:
pip install -r requirements.txt
Verify that app.py
, model.bst
, scaler.joblib
, and postal_data.json
are in the current directory.
streamlit run app.py
The application should now be accessible in your web browser, usually at http://localhost:8501.
From the project's root directory (where the Dockerfile is located):
docker build -t hdb-predictor-app:latest .
docker run -p 8501:8501 hdb-predictor-app:latest
The app will be accessible at http://localhost:8501 on your host machine.
docker tag hdb-predictor-app:latest <dockerhub-username>/hdb-predictor-app:latest
docker push <dockerhub-username>/hdb-predictor-app:latest
- Model Training Data: Based on historical HDB Resale Flat Prices
- Data Last Updated (Reference in App): 30-06-2025
- Streamlit: For the web application framework.
- XGBoost: For the prediction model.
- scikit-learn: For data scaling (StandardScaler).
- Joblib: For saving/loading the scaler.
- Pandas & GeoPandas: Used in the notebook/script that generates the map data.
- Folium: For generating the interactive HTML map (which is then hosted externally).
- Docker: For containerization.
The prediction model (model.bst) and scaler (scaler.joblib) must be compatible with the feature engineering implemented in app.py. The hdb_resale_price_map_clickable.html file is generated by a separate process (e.g., a Jupyter Notebook using Folium) and hosted externally (e.g., on GitHub Pages). The URL to this live map must be correctly configured in app.py.