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

  1. Clone or download the project.
  2. Install dependencies:
pip install -r requirements.txt

Data Preparation

  1. Run data ingestion:
python src/data_ingestion.py

This generates sample flight data. In production, replace with real data sources.

  1. Run feature engineering:
python src/feature_engineering.py

Model Training

  1. Train classifier:
python src/train_classifier.py
  1. 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

  1. Start the API server:
python api.py
  1. In a new terminal, start the Astro frontend:
cd frontend
npm install
npm run dev
  1. 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)

  1. 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;
      
  2. Flight Schedules: Air India Timetables or OpenFlights

  3. Airport Delay Statistics: DGCA (India)

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)

  1. Sign up at https://opensky-network.org/data/impala
  2. Get Impala credentials
  3. Install Impala client: pip install impyla
  4. Update data_ingestion.py with 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)

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!