Data Science & Analysis · 2025
Predicting Bus Trip Performance with Machine Learning
Background
Bus reliability shapes whether people choose public transport — yet operators often only learn a line is unreliable after the fact. Built with Bar-Ilan University's Data Science programme and Tamir Edelstein of Elia Transportation Engineering, this project predicts — before or during a trip — whether a bus will arrive early, on time, or delayed.
Methodology
- Merged SIRI real-time vehicle data with GTFS timetables, passenger counts, weather and route-network GIS layers into one trip-level dataset.
- Engineered temporal, spatial and historical-performance features for each line and segment.
- Trained and compared Logistic Regression, Random Forest, LightGBM and XGBoost, balancing classes with SMOTE and tuning with Optuna.
- Used SHAP values to explain predictions feature-by-feature.
Results
XGBoost (red) and LightGBM (orange) outperform the simpler baselines, reaching AUC scores of 0.83 (early), 0.90 (delay) and 0.90 (on-time).
SHAP summary for the "delay" class — line identity, historical on-time probability by hour, and arrival hour are the strongest predictors.
- XGBoost reached roughly 83% accuracy — above the ~74% baseline — with strong performance on the operationally critical delay class (precision 0.86, recall 0.94).
- Distinguishing "early" from "on-time" trips remained the hardest part — both are rare and easy to confuse, a limitation noted as a direction for further work.
Code
The full notebooks, data pipeline and write-up are available on GitHub.
View repository on GitHub →