Skip to content

A Streamlit web app that predicts Singapore HDB resale flat prices using a pre-trained XGBoost model. Includes an interactive transaction map, light/dark theme toggle, and Docker support for easy deployment.

Notifications You must be signed in to change notification settings

seehiong/hdb-price-predictor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏠 HDB Resale Price Predictor App

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.

✨ Features

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

📁 Project Structure

.
├── app.py
├── model.bst
├── scaler.joblib
├── postal_data.json
├── Dockerfile
├── requirements.txt
└── README.md

🚀 Running Locally

1. Clone the repository

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.

2. Install dependencies

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

3. Ensure local required files are present

Verify that app.py, model.bst, scaler.joblib, and postal_data.json are in the current directory.

4. Run the Streamlit app

streamlit run app.py

The application should now be accessible in your web browser, usually at http://localhost:8501.

🐳 Docker Instructions

1. Build the Docker image

From the project's root directory (where the Dockerfile is located):

docker build -t hdb-predictor-app:latest .

2. Run the Docker container

docker run -p 8501:8501 hdb-predictor-app:latest

The app will be accessible at http://localhost:8501 on your host machine.

(Optional) Tag and Push to a Container Registry (e.g. Docker Hub)

docker tag hdb-predictor-app:latest <dockerhub-username>/hdb-predictor-app:latest
docker push <dockerhub-username>/hdb-predictor-app:latest

📈 Data

  • Model Training Data: Based on historical HDB Resale Flat Prices
  • Data Last Updated (Reference in App): 30-06-2025

🛠 Built With

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

📝 Notes

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.

📄 Related Blog Post

👉 Deploy KServe on OKE

About

A Streamlit web app that predicts Singapore HDB resale flat prices using a pre-trained XGBoost model. Includes an interactive transaction map, light/dark theme toggle, and Docker support for easy deployment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published