LIVE APP : https://urban-ride-cast.streamlit.app
This project builds a machine learning solution to optimize the logistics of a city-wide bike-sharing system. By predicting hourly demand with 93.5% accuracy (R^2), the model enables the operational team to move from reactive logistics (fixing empty stations) to proactive inventory management (preventing stockouts), potentially reducing lost revenue and improving user satisfaction.
Champion Model: LightGBM Regressor (Tuned) Key Techniques: Cyclic Feature Encoding, Log-Transformation, SHAP Interpretability.
Context: Public bike-sharing systems suffer from the "rebalancing problem."
- Rush Hour Stockouts: Stations in residential areas empty out at 8 AM, while office stations overflow.
- Revenue Loss: If a user can't find a bike, the company loses money and trust.
- Operational Cost: Moving bikes randomly is expensive.
Goal: Predict the exact Rented Bike Count for any given hour in the future based on weather, time, and calendar data, allowing the logistics team to pre-stock high-demand stations.
- Language: Python
- Data Manipulation: Pandas, NumPy
- Visualization: Seaborn, Matplotlib, Plotly (Interactive)
- Machine Learning: Scikit-Learn, XGBoost, LightGBM
- Interpretability: SHAP (SHapley Additive exPlanations)
- Workflow: Scikit-Learn Pipelines (to prevent data leakage)
- Target Transformation: Applied
Log1ptransformation to handle the right-skewed demand distribution. - Cyclic Feature Encoding: Converted
Hour,Month, andWeekdayinto Sine/Cosine components to preserve temporal relationships (e.g., 23:00 is close to 00:00). - Feature Selection: Removed multicollinear features (e.g.,
Dew_Point_Temp) using Variance Inflation Factor (VIF) analysis. - Experimental Pipeline: Compared 7 algorithms (Linear, Ridge, Lasso, Decision Tree, Random Forest, XGBoost, LightGBM).
- Hyperparameter Tuning: Optimized the top 3 models using
GridSearchCVinside a Pipeline.
After extensive testing, LightGBM emerged as the winner, balancing speed and accuracy.
| Model | Test |
Train |
Observation |
|---|---|---|---|
| LightGBM (Tuned) | 0.9353 | 0.9482 | Best Performance / No Overfitting |
| XGBoost (Tuned) | 0.9250 | 0.9410 | Strong Contender |
| Random Forest | 0.85 | 0.92 | Slight Overfitting |
| Linear Regression | 0.5565 | 0.5735 | Failed to capture non-linear patterns |
The model shows tight alignment with the ideal prediction line, with minor variance only during extreme outlier events (demand > 2500).
Using SHAP analysis, we uncovered the primary drivers of demand:
- The "Commuter Heartbeat": Demand is strictly bimodal. The strongest predictor is
Hour, with sharp peaks at 8:00 AM and 6:00 PM. - The Goldilocks Temperature: Demand rises with temperature but plateaus/drops above 25°C (Too hot to ride).
- Rain is a "Kill Switch": Even minimal rainfall causes demand to plummet near zero, overriding all other factors.
Based on the model's findings, I recommend the following operational strategies:
- Dynamic Rebalancing: Dispatch trucks at 6:00 AM and 4:00 PM (1 hour before peaks) to redistribute bikes from low-demand zones to high-demand commuter hubs.
- Weather-Responsive Maintenance: Schedule fleet repairs during Winter months (Jan-Feb) or Rainy days, as demand is naturally suppressed, minimizing revenue impact.
- Dynamic Pricing: Implement "Mid-Day Discounts" (11 AM - 3 PM) to flatten the curve and encourage leisure usage during the workday lull.
├── data/ │ └── SeoulBikeData.csv # Raw dataset ├── images/ # Plots and SHAP visualizations ├── models/ │ └── final_bike_model.pkl # Saved LightGBM pipeline ├── Urban_Mobility_Optimization.ipynb # Main Jupyter Notebook ├── README.md # Project Documentation └── requirements.txt # Dependencies
- Clone the repository:
git clone [https://github.com/Om-codex/Urban_Mobility_Optimization_Streamlit_App.git](https://github.com/Om-codex/Urban_Mobility_Optimization_Streamlit_App.git)
2.Install dependencies:
pip install -r requirements.txt
Open the Notebook:
Bash
jupyter notebook Urban_Mobility_Optimization.ipynb
Author: Om Mishra LinkedIn: https://www.linkedin.com/in/om-mishra-a55263329?utm_source=share&utm_campaign=share_via&utm_content=profile&utm_medium=android_app
�







