Air-India-Flight-Delay-Predictor
- Stars
- 7
- Language
- Python
- Updated
Air India Flight Delay Predictor
A production-grade flight delay prediction system for Air India, covering all routes using machine learning.
Features
- Predicts probability of delay >15 minutes
- Predicts expected arrival delay in minutes
- Works for all Air India routes
- Explainable predictions using SHAP
- Python Streamlit frontend
Project Structure
airindia-delay-predictor/
├── data/
│ ├── raw/
│ ├── processed/
│ └── external/
├── notebooks/
│ ├── 01_data_collection.ipynb
│ ├── 02_feature_engineering.ipynb
│ ├── 03_model_training.ipynb
│ ├── 04_evaluation.ipynb
│ └── 05_shap_explainability.ipynb
├── src/
│ ├── data_ingestion.py
│ ├── feature_engineering.py
│ ├── train_classifier.py
│ ├── train_regressor.py
│ ├── evaluate.py
│ ├── predict.py
│ └── utils.py
├── frontend/
│ └── app.py
├── models/
│ ├── delay_classifier.pkl
│ └── delay_regressor.pkl
├── requirements.txt
└── README.md
Installation
- Clone or download the project.
- Install dependencies:
pip install -r requirements.txt
Data Preparation
- Run data ingestion:
python src/data_ingestion.py
This generates sample flight data. In production, replace with real data sources.
- Run feature engineering:
python src/feature_engineering.py
Model Training
- Train classifier:
python src/train_classifier.py
- Train regressor:
python src/train_regressor.py
Evaluation
Run evaluation:
python src/evaluate.py
Running Notebooks
Open the notebooks in Jupyter:
jupyter notebook notebooks/
The notebooks provide detailed walkthroughs of each step.
Launch Frontend
- Start the API server:
python api.py
- In a new terminal, start the Astro frontend:
cd frontend
npm install
npm run dev
- Open http://localhost:4321 in your browser
The API runs on http://localhost:8000 and serves predictions to the Astro frontend.
Enter flight details and get predictions.
Retraining Strategy
- Update rolling statistics daily
- Full model retrain monthly
- Models versioned with timestamps
Data Sources
Primary Data Sources (Real)
-
Actual Flight Times (ADS-B): OpenSky Network
- Source: https://opensky-network.org/data/impala
- Data: Actual departure/arrival timestamps, callsigns (AIC for Air India)
- Access: Free signup required, academic/research use allowed
- Tables: flights_data4, flightlist, states
- Example Query:
SELECT callsign, origin, destination, firstseen, lastseen FROM flights_data4 WHERE callsign LIKE 'AIC%' AND year = 2023;
-
Flight Schedules: Air India Timetables or OpenFlights
- Source: Air India website or https://openflights.org/data.html
- Data: Scheduled departure/arrival, routes, distances
- Files: routes.dat, airports.dat
-
Airport Delay Statistics: DGCA (India)
- Source: https://www.dgca.gov.in/digigov-portal/?page=4264/4206/sericename
- Data: Monthly on-time performance, airline/airport delay stats
- Use: Validation, congestion priors, baseline rates
Current Implementation
- Simulated data for demonstration
- Real airport metadata included
- Weather: Simulated (Meteostat ready)
- Replace with real sources for production
Setup for Real Data
1. OpenSky Network (Flight Times)
- Sign up at https://opensky-network.org/data/impala
- Get Impala credentials
- Install Impala client:
pip install impyla - Update
data_ingestion.pywith credentials
2. Flight Schedules
- OpenFlights data is automatically downloaded
- For Air India specific schedules, scrape from airline website
3. DGCA Statistics
- Download monthly reports from DGCA website
- Parse PDFs or CSVs for delay statistics
4. Weather (Meteostat)
- Sign up at https://meteostat.net/
- Update weather fetching code with API key if needed
Running with Real Data
# Fetch real schedules
python -c "from src.data_ingestion import fetch_flight_schedules; print(fetch_flight_schedules())"
# For OpenSky: Update credentials and run custom query
Production Deployment
- Use real data APIs for flight schedules and weather
- Deploy models on cloud (AWS SageMaker, etc.)
- Schedule daily updates for features
- Monitor model performance
✅ FINAL GOAL
At the end, I should be able to:
pip install -r requirements.txt
python api.py &
cd frontend && npm install && npm run dev
And get accurate Air India delay predictions for any route in a modern web interface!