Flight_Delay_Prediction

✈️ Flight Delay Prediction

Python Jupyter scikit-learn XGBoost pandas License

A machine learning project that predicts flight arrival delays using a two-stage pipeline — combining a classifier to detect whether a flight will be delayed, and a regressor to estimate the delay duration in minutes.


📌 Overview

Flight delays are a major disruption in the aviation industry, affecting millions of passengers each year. This project builds a two-stage prediction pipeline using real-world flight data and weather data collected from 15 major US airports across 2016–2017.

Weather conditions at both origin and destination airports are incorporated as features, given weather’s significant impact on flight delays.


🗂️ Project Structure

Notebook Description
Pre-Processing.ipynb Merges raw flight and weather datasets for 2016 & 2017; handles nulls
Sampling.ipynb Addresses class imbalance using SMOTE (oversampling) and NearMiss (undersampling)
Classification.ipynb Trains and evaluates classification models; selects best classifier
Regression .ipynb Trains and evaluates regression models; builds the final pipeline
Project.ipynb End-to-end project notebook

🏗️ Data

The datasets are merged on airport ID and time (departure/arrival) to align weather conditions with each flight record.


⚙️ Methodology

1. Data Preprocessing

2. Handling Class Imbalance

Since non-delayed flights significantly outnumber delayed flights, two sampling strategies were evaluated:

3. Classification Models

| Model | Notes | |—|—| | Decision Tree | Baseline classifier | | XGBoost | Gradient-boosted ensemble | | Random Forest ✅ | Selected — highest recall on delayed class | | Logistic Regression | Linear baseline |

4. Regression Models

| Model | Notes | |—|—| | Gradient Boosting | Robust ensemble regressor | | XGBoost ✅ | Selected — best R² (0.95), lowest RMSE & MAE | | Random Forest | Ensemble regressor | | Decision Tree | Baseline regressor |

5. Pipeline

Input Flight + Weather Features
        │
        ▼
Random Forest Classifier
  ├── Not Delayed → output: 0 min delay
  └── Delayed ──▶ XGBoost Regressor → output: predicted delay (minutes)

📊 Results

Pipeline Performance

Metric Score
RMSE 18.56
MAE 14.15
R² Score 0.94

Scores may vary depending on the train/test split ratio.

Best Standalone Regressor (XGBoost with SMOTE)

Metric Score
R² Score 0.95
RMSE 16.42
MAE 11.45

🛠️ Tech Stack

Python NumPy pandas Matplotlib scikit-learn XGBoost imbalanced-learn


🚀 Getting Started

  1. Clone the repository
    git clone https://github.com/AMVamsi/Flight_Delay_Prediction.git
    cd Flight_Delay_Prediction
    
  2. Install dependencies
    pip install pandas numpy scikit-learn xgboost imbalanced-learn matplotlib seaborn jupyter
    
  3. Run the notebooks in order
    Pre-Processing.ipynb → Sampling.ipynb → Classification.ipynb → Regression .ipynb
    

✅ Conclusion

The two-stage pipeline successfully predicts flight arrival delays. Key findings:


📄 License

This project is licensed under the MIT License.