Skip to content

About

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.

Resources

Stars

7 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš‡ Smart Delay Prediction in Hyderabad Metro Systems

Using Hybrid Machine Learning and Operational Insights

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

πŸ“Œ Overview

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.


🎯 Objectives

  • 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.

πŸ—‚ Datasets

1. Hyderabad Metro GTFS Dataset

Structured transit schedule data containing:

  • agency.txt, routes.txt, trips.txt
  • stop_times.txt, stops.txt, calendar.txt
  • shapes.txt, fare_rules.txt, fare_attributes.txt, feed_info.txt

2. Indian Railways Delay Dataset

Used for external validation to test the generalization of models on real-world delay behavior.


βš™οΈ Hybrid Prediction Framework

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.

Framework Components

  1. GTFS-based metro schedule processing
  2. Realistic delay simulation engine
  3. Advanced feature engineering
  4. Hybrid ensemble prediction model
  5. SHAP-based explainability analysis
  6. Interactive operational dashboard
  7. External validation using Indian Railways data

πŸ€– Hybrid Ensemble Model

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.

Why Hybrid Modeling?

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 Performance

πŸ“Š Metro Dataset Results

Model RMSE MAE $R^2$
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

πŸš† Indian Railways Validation

Model RMSE MAE $R^2$
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

🧠 Explainable AI using SHAP

To improve transparency and interpretability, SHAP (SHapley Additive exPlanations) analysis was used to understand how features influence delay predictions.

SHAP Insights

The explainability analysis revealed:

  • Previous Delay is the dominant contributor to downstream delays
  • Peak Hours strongly increase delay probability
  • Congestion Level significantly affects station dwell time
  • Stop Sequence captures propagation behavior across routes

Why SHAP Matters

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.


πŸ” Key Research Findings

Operational Findings

  • 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

Machine Learning Findings

  • 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

Validation Findings

  • Models trained on simulated metro logic successfully generalized to real Indian Railways operational data
  • Tree-based ensemble models remained robust across structurally different datasets

πŸ’» Dashboard Features

🌐 Try the Live App

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.

image

image


πŸ“„ Research Contributions

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.


πŸ›  Tech Stack

Machine Learning & AI

  • Scikit-learn
  • XGBoost
  • TensorFlow / Keras
  • SHAP

Data Engineering

  • Pandas
  • NumPy

Visualization & Analytics

  • Matplotlib
  • Seaborn

Dashboard & Deployment

  • Streamlit
  • Joblib

Development

  • Python
  • Jupyter Notebook
  • VS Code
  • Git & GitHub

πŸ“ Project Structure

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

πŸš€ Local Setup

  1. Clone the Repo

    git clone https://github.com/ahana4banerjee/metro-delay-prediction.git
    cd metro-delay-prediction
  2. Install Dependencies

    pip install -r requirements.txt
  3. Run the Dashboard

    streamlit run src/app.py

🏁 Conclusion

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.


πŸ‘©β€πŸ’» Author

Ahana Banerjee

3rd Year, ECE IDP, JNTUH

LinkedIn Gmail Portfolio

About

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.

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages