Back to Case Studies
Machine Learning
Transit Delay Prediction
Using machine learning to predict bus delays before they happen, enabling proactive passenger notifications and route optimization.
15min
Advance Warning
XGBoost
Model
GTFS-RT
Data Source
Python
Stack
The Problem
Passengers waiting at bus stops have no way to know if their bus will be delayed until it's already late. This leads to:
- •Frustrated passengers standing in the rain
- •Missed connections and appointments
- •Lack of trust in public transit
Question: Can we predict delays before they happen using historical patterns and real-time data?
ML Approach
Feature Engineering
Time of day
Day of week
Route ID
Direction
Current position
Recent delays
Stop sequence
Distance to stop
Historical avg
Model Architecture
Input Features (9)
│
▼
┌─────────────────────┐
│ Gradient Boosting │ XGBoost / LightGBM
│ Regressor │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Predicted Delay │ (minutes)
│ + Confidence Score │
└─────────────────────┘Why Gradient Boosting?
- Handles mixed feature types (categorical + numerical)
- Captures non-linear relationships
- Fast inference for real-time predictions
- Interpretable feature importance
Results
Feature Importance
Recent delays (last 3 stops)34%
Time of day22%
Route historical avg18%
Day of week12%
Distance to stop8%
Other6%
This is an exploratory model: with more data it can be validated properly and improved.
Technologies Used
PythonScikit-learnXGBoostPandasNumPyGTFS-RT APISQLitePlotlyJupyter
Explore the Code
Full implementation including feature engineering, model training, and evaluation notebooks.
View on GitHub