Upload 6 files
Browse files- .gitattributes +1 -0
- airline_passenger_satisfaction.csv +3 -0
- app.py +11 -0
- best_model.pkl +3 -0
- eda.py +117 -0
- prediction.py +77 -0
- requirements.txt +6 -0
.gitattributes
CHANGED
|
@@ -53,3 +53,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
airline_passenger_satisfaction.csv filter=lfs diff=lfs merge=lfs -text
|
airline_passenger_satisfaction.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b92fa53b0aa2f6ebb7e7785e7122585794dfb8f6178565f4f03255ddb5367831
|
| 3 |
+
size 14339544
|
app.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import eda as eda
|
| 2 |
+
import prediction
|
| 3 |
+
import streamlit as st
|
| 4 |
+
PAGES = {
|
| 5 |
+
"Exploratory Data Analysis": eda,
|
| 6 |
+
"Model Prediction": prediction
|
| 7 |
+
}
|
| 8 |
+
st.sidebar.title('Navigation')
|
| 9 |
+
selection = st.sidebar.radio("Go to", list(PAGES.keys()))
|
| 10 |
+
page = PAGES[selection]
|
| 11 |
+
page.app()
|
best_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:acde1554f9bcde5bdb1ade2e3a39575ffee006b0ca72ac1da42ee5d8baf6f368
|
| 3 |
+
size 346280
|
eda.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import seaborn as sns
|
| 4 |
+
import matplotlib.pyplot as plt
|
| 5 |
+
|
| 6 |
+
def app():
|
| 7 |
+
st.header('Model Deployment')
|
| 8 |
+
st.write("""
|
| 9 |
+
Created by Maria Melisa Gunawan""")
|
| 10 |
+
st.subheader("""Airline Passenger Satisfaction Exploratory Data Analysis
|
| 11 |
+
""")
|
| 12 |
+
|
| 13 |
+
@st.cache_data
|
| 14 |
+
def fetch_data():
|
| 15 |
+
df = pd.read_csv('airline_passenger_satisfaction.csv')
|
| 16 |
+
return df
|
| 17 |
+
|
| 18 |
+
df = fetch_data()
|
| 19 |
+
df.drop_duplicates(inplace=True)
|
| 20 |
+
st.write(df)
|
| 21 |
+
|
| 22 |
+
fig, ax = plt.subplots()
|
| 23 |
+
df['Gender'].value_counts().plot(kind='bar', ax=ax)
|
| 24 |
+
plt.tight_layout()
|
| 25 |
+
st.header('Distribusi Jenis Kelamin Pelanggan')
|
| 26 |
+
st.pyplot(fig)
|
| 27 |
+
st.write("Berdasarkan jenis kelamin, dengan angka 0 menunjukkan Female dan angka 1 menunjukkan Male, didapatkan bahwa gender Female dan Male memiliki angka yang hampir sama yaitu Female 50.7% dan Male 49.3%")
|
| 28 |
+
|
| 29 |
+
for feature in ['inflight_entertainment', 'seat_comfort', 'onboard_service',
|
| 30 |
+
'leg_room_service', 'inflight_wifi_service', 'baggage_handling',
|
| 31 |
+
'inflight_service', 'checkin_service', 'online_boarding',
|
| 32 |
+
'cleanliness']:
|
| 33 |
+
fig, ax = plt.subplots()
|
| 34 |
+
df[feature].value_counts().plot(kind='bar', ax=ax)
|
| 35 |
+
plt.tight_layout()
|
| 36 |
+
st.header(f'{feature.capitalize()} Counts')
|
| 37 |
+
st.pyplot(fig)
|
| 38 |
+
st.write(""" Berdasarkan data diatas, dapat disimpulkan bahwa rata-rata service yang diberikan memiliki tingkat kepuasan yang cukup tinggi
|
| 39 |
+
""")
|
| 40 |
+
|
| 41 |
+
fig, ax = plt.subplots()
|
| 42 |
+
df['customer_type'].value_counts().plot(kind='bar', ax=ax)
|
| 43 |
+
plt.tight_layout()
|
| 44 |
+
st.header('Jumlah Pelanggan Berdasarkan Tipe Pelanggan')
|
| 45 |
+
st.pyplot(fig)
|
| 46 |
+
st.write("Loyal customer jauh lebih tinggi dibandingkan dengan disloyal customer, yang berarti banyak pelanggan yang loyal.")
|
| 47 |
+
|
| 48 |
+
fig, ax = plt.subplots()
|
| 49 |
+
df['age'].plot(kind='hist', ax=ax, bins=20, edgecolor='black', alpha=0.7)
|
| 50 |
+
plt.tight_layout()
|
| 51 |
+
st.header('Distribusi Usia Pelanggan')
|
| 52 |
+
st.pyplot(fig)
|
| 53 |
+
st.write("Mayoritas pelanggan berumur dari 10 hingga 85 tahun dan pelanggan terbanyak berada di usia kisaran 20 hingga 60 tahun dengan pelanggan yang paling banyak pada usia 40 tahun.")
|
| 54 |
+
|
| 55 |
+
fig, ax = plt.subplots()
|
| 56 |
+
df['type_of_travel'].value_counts().plot(kind='bar', ax=ax)
|
| 57 |
+
plt.tight_layout()
|
| 58 |
+
st.header('Jumlah Pelanggan Berdasarkan Jenis Perjalanan')
|
| 59 |
+
st.pyplot(fig)
|
| 60 |
+
st.write("Mayoritas pelanggan melakukan perjalanan business travel dibandingkan dengan personal travel.")
|
| 61 |
+
|
| 62 |
+
fig, ax = plt.subplots()
|
| 63 |
+
df['customer_class'].value_counts().plot(kind='bar', ax=ax)
|
| 64 |
+
plt.tight_layout()
|
| 65 |
+
st.header('Jumlah Pelanggan Berdasarkan Kelas Perjalanan')
|
| 66 |
+
st.pyplot(fig)
|
| 67 |
+
st.write("Mayoritas pelanggan berada di kelas business diikuti dengan kelas eco dan paling sedikit pelanggan yang menaiki kelas eco plus.")
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
fig, ax = plt.subplots()
|
| 71 |
+
df['flight_distance'].plot(kind='hist', ax=ax, bins=20, edgecolor='black', alpha=0.7)
|
| 72 |
+
plt.tight_layout()
|
| 73 |
+
st.header('Distribusi Jarak Penerbangan')
|
| 74 |
+
st.pyplot(fig)
|
| 75 |
+
st.write("Mayoritas pelanggan berumur dari 10 hingga 85 tahun dan pelanggan terbanyak berada di usia kisaran 20 hingga 60 tahun dengan pelanggan yang paling banyak pada usia 40 tahun.")
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
st.header('KDE of Flight Distance by Satisfaction')
|
| 79 |
+
fig = sns.displot(data=df, x="flight_distance", kind='kde', hue='satisfaction')
|
| 80 |
+
st.pyplot(fig)
|
| 81 |
+
st.write("Lebih banyak orang yang merasa puas pada perjalanan yang jauh daripada perjalanan yang pendek.")
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
fig, ax = plt.subplots()
|
| 85 |
+
df['satisfaction'].value_counts().plot(kind='bar', ax=ax)
|
| 86 |
+
plt.tight_layout()
|
| 87 |
+
st.header('Jumlah Pelanggan Berdasarkan Kepuasan')
|
| 88 |
+
st.pyplot(fig)
|
| 89 |
+
st.write("Lebih banyak pelanggan yang merasa netral/tidak puas daripada yang merasa puas.")
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
st.header('KDE of Age by Satisfaction')
|
| 93 |
+
fig = sns.displot(data=df, x="age", kind='kde', hue='satisfaction')
|
| 94 |
+
st.pyplot(fig)
|
| 95 |
+
st.write("Orang dengan umur 40 keatas atau yang lebih tua cenderung lebih puas dari umur yang masih muda.")
|
| 96 |
+
|
| 97 |
+
st.header('Skewness of Flight Distance')
|
| 98 |
+
skew = round(df["flight_distance"].skew(), 2)
|
| 99 |
+
st.write("Skewness:", skew)
|
| 100 |
+
fig, ax = plt.subplots()
|
| 101 |
+
sns.histplot(df["flight_distance"], bins=60, ax=ax)
|
| 102 |
+
plt.tight_layout()
|
| 103 |
+
st.pyplot(fig)
|
| 104 |
+
st.write(" Dari gambar diatas menunjukkan flight distance memiliki skewness positif.")
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
st.header('Box Plot of Flight Distance')
|
| 108 |
+
plt.figure(figsize=(8, 6))
|
| 109 |
+
sns.boxplot(x=df["flight_distance"])
|
| 110 |
+
plt.title('Box Plot Jarak Penerbangan')
|
| 111 |
+
plt.xlabel('Jarak Penerbangan')
|
| 112 |
+
plt.grid(True)
|
| 113 |
+
st.pyplot(plt)
|
| 114 |
+
st.write("Tidak ada outliers yang besar pada flight distance.")
|
| 115 |
+
|
| 116 |
+
if __name__ == '__main__':
|
| 117 |
+
app()
|
prediction.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import pickle
|
| 4 |
+
|
| 5 |
+
def app():
|
| 6 |
+
st.header('Model Prediction')
|
| 7 |
+
st.write("""
|
| 8 |
+
Created by Maria Melisa Gunawan
|
| 9 |
+
|
| 10 |
+
Airline Passenger Satisfaction Prediction
|
| 11 |
+
""")
|
| 12 |
+
|
| 13 |
+
@st.cache_data
|
| 14 |
+
def fetch_data():
|
| 15 |
+
# Ganti path file CSV sesuai dengan lokasi file Anda
|
| 16 |
+
df = pd.read_csv('airline_passenger_satisfaction.csv')
|
| 17 |
+
return df
|
| 18 |
+
|
| 19 |
+
df = fetch_data()
|
| 20 |
+
|
| 21 |
+
st.header('User Input Features')
|
| 22 |
+
|
| 23 |
+
def user_input():
|
| 24 |
+
online_boarding = st.slider("Online Boarding", 0, 5, 3)
|
| 25 |
+
type_of_travel = st.slider("Type of Travel", 0, 1)
|
| 26 |
+
inflight_entertainment = st.slider("Inflight Entertainment", 0, 5, 3)
|
| 27 |
+
customer_class = st.slider("Customer Class", 0, 1, 2)
|
| 28 |
+
seat_comfort = st.slider("Seat Comfort", 0, 5, 3)
|
| 29 |
+
onboard_service = st.slider("Onboard Service", 0, 5, 3)
|
| 30 |
+
leg_room_service = st.slider("Leg Room Service", 0, 5, 3)
|
| 31 |
+
cleanliness = st.slider("Cleanliness", 0, 5, 3)
|
| 32 |
+
inflight_wifi_service = st.slider("Inflight Wifi Service", 0, 5, 3)
|
| 33 |
+
baggage_handling = st.slider("Baggage Handling", 0, 5, 3)
|
| 34 |
+
inflight_service = st.slider("Inflight Service", 0, 5, 3)
|
| 35 |
+
flight_distance = st.number_input("Flight Distance", min_value=0)
|
| 36 |
+
checkin_service = st.slider("Checkin Service", 0, 5, 3)
|
| 37 |
+
|
| 38 |
+
data = {
|
| 39 |
+
'online_boarding': [online_boarding],
|
| 40 |
+
'type_of_travel': [type_of_travel],
|
| 41 |
+
'inflight_entertainment': [inflight_entertainment],
|
| 42 |
+
'customer_class' : [customer_class],
|
| 43 |
+
'seat_comfort': [seat_comfort],
|
| 44 |
+
'onboard_service': [onboard_service],
|
| 45 |
+
'leg_room_service': [leg_room_service],
|
| 46 |
+
'cleanliness': [cleanliness],
|
| 47 |
+
'inflight_wifi_service': [inflight_wifi_service],
|
| 48 |
+
'baggage_handling': [baggage_handling],
|
| 49 |
+
'inflight_service': [inflight_service],
|
| 50 |
+
'flight_distance': [flight_distance],
|
| 51 |
+
'checkin_service': [checkin_service]
|
| 52 |
+
}
|
| 53 |
+
features = pd.DataFrame(data)
|
| 54 |
+
return features
|
| 55 |
+
|
| 56 |
+
input_df = user_input()
|
| 57 |
+
|
| 58 |
+
st.subheader('User Input')
|
| 59 |
+
st.write(input_df)
|
| 60 |
+
|
| 61 |
+
# Load trained model
|
| 62 |
+
filename = 'best_model.pkl'
|
| 63 |
+
loaded_model = pickle.load(open(filename, 'rb'))
|
| 64 |
+
|
| 65 |
+
# Predict
|
| 66 |
+
prediction = loaded_model.predict(input_df)
|
| 67 |
+
|
| 68 |
+
if prediction == 1:
|
| 69 |
+
result = 'Satisfied'
|
| 70 |
+
else:
|
| 71 |
+
result = 'Dissatisfied'
|
| 72 |
+
|
| 73 |
+
st.write('Predicted Passenger Satisfaction:')
|
| 74 |
+
st.write(result)
|
| 75 |
+
|
| 76 |
+
if __name__ == '__main__':
|
| 77 |
+
app()
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
pandas
|
| 3 |
+
seaborn
|
| 4 |
+
matplotlib
|
| 5 |
+
numpy
|
| 6 |
+
scikit-learn == 1.2.2
|