Analysis & Passenger Satisfaction Prediction on US Airline : Classification Method
By: Anugrah Nurhamid
Tags: Data Analysis, Classification Models, Data Science, Data Visualization, Machine Learning

Exploratory Data Analysis

Next step, after data preprocessing. I have a clean data set and ready for analsysis and predict with the features and target. First, I wanna present about distribution from customers located at the airport.

Customer Count by Class & Age

Travel class in the airport of the passengers divided by 3 class that is Business, Economy Plus & Economy. Range of age in this data start from 7 to 85 years. Travel class dominated by business class (47%) & economy class (45%), and the rest are economy class from the data of the passengers.

This graph present travel class in economy class dominated by passengers in range 20–27 years.

This graph present travel class in economy plus class dominated by passengers in range 22–39 years. But this class fewest than other class.

This graph present travel class in business class dominated by passengers in range 39–49 years.

From all graph we can conclude each class has its own market share based on the age of the passengers. We can give a promote, discount package or probably free ticket with some aviation that has been done for each class with its own market share. It can be share and discuss with marketing department.

What travel class is used by the loyal customer?

Customer type in this airport divided by 2 type that is loyal customer & disloyal customer. From the data customer type dominated by loyal customer (82%), and for disloyal customer (18%).

Almost 90% Loyal customer using business class and economy class

Count Type of Travel by Class

Type of travel in this airport meaning purpose of the flight of the passengers. Type of travel divided by 2 type that called business travel & personal travel. From the data Type of travel dominated by business travel (69%), whereas personal travel (31%).

Purpose business travel dominated by business class.

Purpose personal travel dominated by business class.

Correlation for each Column

For better present the correlation for each column. I used heatmap graph, “heatmap is a graphical representation of data that uses a system of color-coding to represent different values.” — optimizely.com. The stronger the color, the fewest the correlation magnitude, in this graph is dark violet. Whereas The brighter the color, is the larger the correlation magnitude, in this graph is light cream.

From this heatmap, I wanna used features with correlation more than 0.1 with this target is satisfaction from the passengers.

From this graph, present most correlation is one and for fewest correlation is zero.

Modeling

The last step, for making the model in this data set, I will trying use several classification models namely Logistic Regression, Decision Tree Classifier, Random Forest Classifier and Gradient Boosting Classifier.The step for modeling.

Find best algorithm for predict satisfaction of the passengers. Prediction for the best model with hyperparameter. Evaluation with recall and precision.

Target and Features

This is the target (y) and features (x) for this modelling. I got features from heatmap that I made in exploratory data analysis.

Target is satisfaction of passengers. Features (Gender, Customer Type, Age, Type of Travel, Class,

Seat comfort, Food and drink, In flight wifi service, In flight entertainment, Online support, Ease of Online booking,

On-board service, Leg room service, Baggage handling,

Check in service, Cleanliness, Online boarding).

Feature Engineering

Meaning for feature engineering in generally is change categorical value (in column categorical) to numerical value.

Find Best Algorithm

After the data processing with feature engineering, the data ready to be used for modeling. I’ll try compare four algorithm, to find who the best for predict this data.

The result for Random Forest Classifier

From all algorithm that I used, the best recall and precision is Random Forest Classifier. I try to compare data test and data train, to detect whether this model is underfitting or overfitting. Finally the result is very good, we have a good score on both. Before, I explain about hyperparameter for this algorithm. I will discuss little bit about recall and precision.

image source : https://towardsdatascience.com/precision-vs-recall-386cf9f89488

True positives: data points labeled as positive that are actually positive.

data points labeled as positive that are actually positive. False positives: data points labeled as positive that are actually negative.

data points labeled as positive that are actually negative. True negatives: data points labeled as negative that are actually negative.

data points labeled as negative that are actually negative. False negatives: data points labeled as negative that are actually positive.

Recall and Precision Metrics

Recall: ability of a classification model to identify all relevant instances.

ability of a classification model to identify all relevant instances. Precision: ability of a classification model to return only relevant instances.

ability of a classification model to return only relevant instances. F1 score: single metric that combines recall and precision using the harmonic mean.

So, we can conclude the algorithm have score to predict (actually right predict) this data with 93% to detect “neutral or dissatisfied” & 96% to detect “satisfied”. Precision and recall it’s extremely important for classification method. While precision refers to the percentage of our results which are relevant, recall refers to the percentage of total relevant results correctly classified by our algorithm. Unfortunately, some times we can’t maximize the score of them. For the other case, probably trade-off is needed. For make a decision whether to maximize recall score or precision.

Find Best Hyperparamter

Next step for the modelling is find the best hyperparameter. “ In machine learning, a hyperparameter is a parameter whose value is set before the learning process begins”- wikipedia.

So, I will try find the best hyperparameter for Random Forest Classifier (the best algorithm to modeling) using GridSearchCV. The result hyperparameter for the model (RandomForestClassifier) with max_depth : 25, min_samples_leaf : 0.000001, min_samples_split : 0.000001.

Final Modeling

Next step after find best hyperparameter, input best hyperparamter to the model for optimization the prediction of passengers satisfied. So, let’s start making model with best hyperparameter.

The results of the model are better than the default parameters

Conclusion from the modeling with this data it’s very good with precision, recall & f1-score almost 100% compare with the actual data. Some parameters not included on this model, you can find for more better score with another parameters.