A machine learning framework to predict Hyderabad Metro train delays using GTFS schedule data, realistic delay simulation, operational insights, and cross-validation on Indian Railways data.
Live Demo: https://metro-delay-prediction.streamlit.app
Metro systems depend heavily on punctuality. Even small delays can propagate across downstream stations, impacting schedules, passenger trust, and operational efficiency.
This project builds a delay prediction system for Hyderabad Metro using:
- GTFS schedule data as the foundation
- Delay simulation (modeling realistic scenarios where public data is unavailable)
- Machine Learning models (Regression and Time-Series)
- Hybrid operational logic for propagation tracking
- Interactive Streamlit dashboard for real-time visualization
- External validation using Indian Railways dataset
The project demonstrates how data-driven methods can support smarter urban transit systems.
- Predict train delays at station/time level.
- Identify and understand key factors causing delays (Peak hours, Congestion).
- Compare performance across multiple ML models (XGBoost, Random Forest, LSTM).
- Validate model robustness on real-world Indian Railways data.
- Provide a user-friendly dashboard for operational decision support.
Structured transit schedule data containing:
agency.txt,routes.txt,trips.txtstop_times.txt,stops.txt,calendar.txtshapes.txt,fare_rules.txt,fare_attributes.txt,feed_info.txt
Used for external validation to test the generalization of models on real-world delay behavior.
The proposed framework combines:
- Statistical delay simulation
- Ensemble machine learning
- Sequential operational logic
- Explainable AI analysis
- Real-world validation
The system is designed as a hybrid operational intelligence pipeline rather than a standalone prediction model.
- GTFS-based metro schedule processing
- Realistic delay simulation engine
- Advanced feature engineering
- Hybrid ensemble prediction model
- SHAP-based explainability analysis
- Interactive operational dashboard
- External validation using Indian Railways data
Instead of relying on a single prediction algorithm, the project uses a hybrid ensemble strategy combining:
- XGBoost
- Random Forest
- Sequential operational features
- Propagation-aware logic
The hybrid architecture combines machine learning outputs with operational intelligence factors such as:
- Peak-hour congestion
- Station crowding
- Delay propagation
- Sequential station dependency
This improves both prediction robustness and interpretability.
Traditional ML models focus only on statistical relationships.
This framework additionally incorporates transportation-domain operational behavior, making predictions more realistic and practically usable for metro systems.
| Model | RMSE | MAE | |
|---|---|---|---|
| XGBoost | 1.144 | 0.829 | 0.940 |
| Hybrid (XGB+OAS) | 0.945 | 0.703 | 0.964 |
| Random Forest | 1.159 | 0.841 | 0.938 |
| Linear Regression | 1.325 | 0.976 | 0.913 |
| LSTM | 1.352 | 1.025 | 0.920 |
| Model | RMSE | MAE | |
|---|---|---|---|
| Random Forest | 7.16 | 3.21 | 0.97 |
| XGBoost | 8.13 | 2.97 | 0.95 |
| Hybrid (XGB+OAS) | 8.14 | 4.68 | 0.96 |
| LSTM | 13.86 | 6.86 | 0.88 |
| Linear Regression | 15.66 | 7.81 | 0.85 |
To improve transparency and interpretability, SHAP (SHapley Additive exPlanations) analysis was used to understand how features influence delay predictions.
The explainability analysis revealed:
Previous Delayis the dominant contributor to downstream delaysPeak Hoursstrongly increase delay probabilityCongestion Levelsignificantly affects station dwell timeStop Sequencecaptures propagation behavior across routes
Instead of treating the model as a black box, SHAP provides operational interpretability by showing:
- Why a delay was predicted
- Which features contributed most
- How operational conditions influence predictions
This makes the framework more suitable for real-world transportation decision support systems.
- Delay propagation is the strongest behavioral characteristic in metro systems
- Interchange stations show consistently higher delay accumulation
- Peak-hour congestion significantly amplifies downstream delays
- Delay behaves as a sequential path-dependent process
- Ensemble models outperform standalone regression approaches
- XGBoost and Random Forest achieved strongest generalization capability
- Hybrid operational modeling improves realism compared to pure statistical prediction
- Explainable AI methods improve interpretability of transportation ML systems
- Models trained on simulated metro logic successfully generalized to real Indian Railways operational data
- Tree-based ensemble models remained robust across structurally different datasets
https://metro-delay-prediction.streamlit.app/
Built using Streamlit, the dashboard provides:
- User Inputs: Source station, Destination, Day, and Time.
- Real-time Predictions: Predicted delay and estimated arrival time.
- Operational Alerts: Peak-hour warnings and delay severity levels.
This work contributes toward:
- Simulation-driven delay prediction for data-scarce metro systems
- Hybrid operational + machine learning modeling
- Explainable AI applications in smart transportation
- Delay propagation analytics in urban transit systems
- Generalizable transit prediction frameworks
The project bridges the gap between academic ML modeling and practical transportation operations.
- Scikit-learn
- XGBoost
- TensorFlow / Keras
- SHAP
- Pandas
- NumPy
- Matplotlib
- Seaborn
- Streamlit
- Joblib
- Python
- Jupyter Notebook
- VS Code
- Git & GitHub
metro-delay-prediction/
βββ data/
β βββ raw/ # Original GTFS files
β βββ processed/ # Cleaned features
β βββ validation/ # Indian Railways data
βββ notebooks/ # EDA & Model Training
βββ src/ # Python scripts for logic
βββ models/ # Saved .pkl and .h5 files
βββ app.py # Streamlit dashboard
βββ requirements.txt # Dependencies
βββ README.md
-
Clone the Repo
git clone https://github.com/ahana4banerjee/metro-delay-prediction.git cd metro-delay-prediction -
Install Dependencies
pip install -r requirements.txt
-
Run the Dashboard
streamlit run src/app.py
This project successfully combines data engineering, delay simulation, and ensemble learning to create a scalable metro delay prediction framework. It proves that even in the absence of public historical data, reliable predictions can be built using operational insights and smart simulation.
Ahana Banerjee
3rd Year, ECE IDP, JNTUH

