GulShair/bike-rental-demand-prediction
๐ฒ Bike Rental Demand Prediction
Predict daily bike rental demand from weather and seasonal conditions using a Decision Tree Regressor โ served through a clean, interactive Streamlit dashboard.
Overview
Urban bike-sharing systems are sensitive to weather and time-of-year. This project builds a Decision Tree Regression model that estimates how many bikes will be rented on a given day based on four inputs: temperature, humidity, wind speed, and season.
The entire workflow โ data exploration, model training, evaluation, and live prediction โ is available through a multi-page Streamlit application.
Features
- Dataset Explorer โ preview rows, inspect data types, check for missing values and duplicates, view statistical summary
- Visualizations โ histograms, box plots, scatter plots with trend line, and an annotated correlation heatmap
- Model Training โ one-click training with MAE / RMSE / Rยฒ metrics, feature importance chart, and actual-vs-predicted scatter plot
- Live Prediction โ number input form with instant demand forecast displayed in a styled card
- Download Results โ export any prediction as a timestamped CSV
- Assignment Example Loader โ pre-fills the required test case (
temp=0.5, humidity=0.6, windspeed=0.2, season=3) in one click - Clean, responsive UI โ sidebar navigation, wide layout, consistent seaborn theme
Tech Stack
Project Structure
bike-rental-demand-prediction/
โโโ dataset/
โ โโโ bike_rental_100_rows.csv # 100-record sample dataset
โโโ app.py # Streamlit UI (6 pages)
โโโ train_model.py # ML pipeline (train, evaluate, predict)
โโโ utils.py # Data utilities (load, clean, info)
โโโ model.pkl # Saved model (generated at runtime, git-ignored)
โโโ requirements.txt
โโโ README.mdInstallation & Setup
# 1. Clone the repository
git clone https://github.com/your-username/bike-rental-demand-prediction.git
cd bike-rental-demand-prediction
# 2. Create and activate a virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. (Optional) Train the model from the command line first
python train_model.py
# 5. Launch the Streamlit app
streamlit run app.pyThe app will open at http://localhost:8501.
Dataset
Column notes:
tempandhumidityare normalised floats in[0, 1]windspeedis normalised in[0, 1]seasonis an integer:1=Spring, 2=Summer, 3=Fall, 4=Wintercountis an integer representing total rentals for that record
This is a sample dataset (100 rows). It is sufficient for demonstrating the workflow but too small for production-grade predictions.
Model
Algorithm: DecisionTreeRegressor (scikit-learn)
Hyperparameters:
The tree is regularised because an unconstrained tree on 100 rows would perfectly overfit the training data and generalise poorly.
Results
Evaluated on 20 held-out test records (20 % of 100).
Custom prediction (temp=0.5, humidity=0.6, windspeed=0.2, season=3): ~206 rentals
Screenshots
Screenshots will be added after deployment.
Future Improvements
- Collect a significantly larger dataset (thousands of records) for reliable generalisation
- Compare against Random Forest and XGBoost to quantify the benefit of ensemble methods
- Hyperparameter tuning via
GridSearchCVorRandomizedSearchCV - Add time-series features (hour of day, day of week, holiday flag)
- Cross-validation instead of a single train/test split
- Deploy to Streamlit Cloud or Hugging Face Spaces
