A machine learning web application that predicts whether an airline passenger is satisfied or neutral/dissatisfied based on their flight experience and service ratings.
- Overview
- Demo
- Project Structure
- Dataset
- Exploratory Data Analysis
- Model
- Features
- Installation
- Usage
- Model Performance
- Tech Stack
- Author
This project builds an end-to-end machine learning pipeline to predict customer satisfaction for airline passengers. It covers the full workflow — from raw data exploration and preprocessing to model training, evaluation, and deployment as an interactive Streamlit web application.
The trained model takes 22 passenger-related features (demographics, travel type, flight class, service ratings, and delays) and outputs a binary prediction: Satisfied 😆 or Neutral / Dissatisfied 😒.
Run locally using the instructions in the Usage section.
| Sidebar Inputs | Prediction Output |
|---|---|
| Demographics, travel class, service ratings | ✅ Satisfied / ❌ Neutral or Dissatisfied |
├── data_preprocessing_and_model_training.ipynb # Full EDA, preprocessing & model training notebook
├── app.py # Streamlit web application
├── model.pkl # Serialized trained Random Forest model
├── customer_satisfication_dataset.csv # Raw dataset (not included — see Dataset section)
├── requirements.txt # Python dependencies
└── README.md # Project documentation
The dataset used is the Airline Passenger Satisfaction dataset, containing survey responses and flight details for thousands of passengers.
Key columns include:
| Column | Type | Description |
|---|---|---|
Gender |
Categorical | Male / Female |
Customer Type |
Categorical | Loyal / Disloyal Customer |
Age |
Numeric | Passenger age |
Type of Travel |
Categorical | Business / Personal Travel |
Class |
Categorical | Business, Eco, Eco Plus |
Flight Distance |
Numeric | Distance of the flight (miles) |
Inflight wifi service |
Numeric | Rating 0–5 |
Seat comfort |
Numeric | Rating 0–5 |
Departure Delay in Minutes |
Numeric | Departure delay duration |
Arrival Delay in Minutes |
Numeric | Arrival delay duration |
satisfaction |
Target | Satisfied / Neutral or Dissatisfied |
Note: The dataset file (
customer_satisfication_dataset.csv) is not included in this repository. You can find a compatible dataset on Kaggle — Airline Passenger Satisfaction.
The notebook covers a thorough EDA including:
- ✅ Shape, dtypes, and column inventory
- ✅ Missing value analysis (
Arrival Delay in Minutes— filled with median) - ✅ Duplicate detection
- ✅ Satisfaction distribution (count plot)
- ✅ Satisfied vs. Dissatisfied breakdown by Gender, Class, and Type of Travel
- ✅ Correlation heatmap across all numeric features
A Random Forest Classifier was trained with the following configuration:
RandomForestClassifier(n_estimators=350, min_samples_split=11)Preprocessing steps applied before training:
- Dropped irrelevant columns:
Unnamed: 0,id - Imputed missing values in
Arrival Delay in Minuteswith the column median - Label-encoded all categorical features:
Gender: Male → 1, Female → 0Customer Type: Loyal → 1, Disloyal → 0Type of Travel: Business → 1, Personal → 0Class: Business → 1, Eco → 2, Eco Plus → 3satisfaction: Satisfied → 1, Neutral/Dissatisfied → 0
- 80/20 train-test split (
random_state=42)
The trained model is serialized and saved as model.pkl using Python's pickle module.
The Streamlit app accepts the following 22 input features via the sidebar:
| # | Feature | Input Type | Range / Options |
|---|---|---|---|
| 1 | Gender | Selectbox | Male, Female |
| 2 | Customer Type | Selectbox | Loyal, Disloyal |
| 3 | Age | Number Input | 7 – 85 |
| 4 | Type of Travel | Selectbox | Business, Personal |
| 5 | Class | Selectbox | Business, Eco, Eco Plus |
| 6 | Flight Distance | Number Input | 31 – 4983 |
| 7 | Inflight wifi service | Number Input | 0 – 5 |
| 8 | Departure/Arrival time convenient | Number Input | 0 – 5 |
| 9 | Ease of Online booking | Number Input | 0 – 5 |
| 10 | Gate location | Number Input | 1 – 5 |
| 11 | Food and drink | Number Input | 0 – 5 |
| 12 | Online boarding | Number Input | 0 – 5 |
| 13 | Seat comfort | Number Input | 0 – 5 |
| 14 | Inflight entertainment | Number Input | 0 – 5 |
| 15 | On-board service | Number Input | 0 – 5 |
| 16 | Leg room service | Number Input | 0 – 5 |
| 17 | Baggage handling | Number Input | 1 – 5 |
| 18 | Checkin service | Number Input | 0 – 5 |
| 19 | Inflight service | Number Input | 0 – 5 |
| 20 | Cleanliness | Number Input | 0 – 5 |
| 21 | Departure Delay in Minutes | Number Input | 0 – 1592 |
| 22 | Arrival Delay in Minutes | Number Input | 0 – 1584 |
git clone https://github.com/zakir-maswani/airline-satisfication-prediction.git
cd customer-satisfaction-predictionpython -m venv venv
source venv/bin/activate # On macOS/Linux
venv\Scripts\activate # On Windowspip install -r requirements.txtstreamlit run app.pyThen open http://localhost:8501 in your browser.
Open and run the Jupyter notebook:
jupyter notebook data_preprocessing_and_model_training.ipynbThis will regenerate model.pkl with the latest data.
| Metric | Score |
|---|---|
| Accuracy | 96% |
| Precision | 95% |
| Recall | 98% |
Evaluated on a held-out 20% test set.
| Category | Library / Tool |
|---|---|
| Language | Python 3.x |
| Data Manipulation | pandas |
| Visualization | matplotlib, seaborn |
| Machine Learning | scikit-learn |
| Model Serialization | pickle |
| Web App | Streamlit |
| Notebook | Jupyter |
Built by Zakir Ali — Machine Learning Engineer
⭐ If you found this project helpful, feel free to star the repository!