Astralsparks commited on
Commit
5aea554
1 Parent(s): fd75326

Deploy for milestone 2

Browse files
Files changed (3) hide show
  1. app.py +91 -0
  2. catb_randcv.pkl +3 -0
  3. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import library yang dibutuhkan
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import numpy as np
5
+ import joblib
6
+
7
+
8
+ # load best model
9
+ with open('catb_randcv.pkl','rb') as file_1:
10
+ catb_pipe = joblib.load(file_1)
11
+
12
+ # Construct Data Infer
13
+ # define semua fitur/kolom
14
+ features = ['Gender','Customer Type','Age','Type of Travel','Class','Flight Distance',\
15
+ 'Inflight wifi service','Departure/Arrival time convenient','Ease of Online booking',\
16
+ 'Gate location','Food and drink','Online boarding','Seat comfort','Inflight entertainment',\
17
+ 'On-board service','Leg room service','Baggage handling','Checkin service','Inflight service',\
18
+ 'Cleanliness','Departure Delay in Minutes','Arrival Delay in Minutes']
19
+
20
+ def infer(data_infer):
21
+ # predict result random forest model
22
+ y_pred_rf = catb_pipe.predict(data_infer)
23
+ return y_pred_rf
24
+
25
+ st.header("Prediksi Pasien Penderita Gagal Jantung")
26
+
27
+ # artificial data infer
28
+ gender_options = ["Male", "Female"]
29
+ gender = st.selectbox("Please input your gender: ", gender_options)
30
+ customer_type_options = ['Loyal Customer', 'disloyal Customer']
31
+ customer_type = st.selectbox("Which type of customer are you? ", customer_type_options)
32
+ age = st.slider("Please input your age: ",0,100)
33
+ type_of_travel_options = ['Personal Travel', 'Business travel']
34
+ type_of_travel = st.selectbox("Please input your type of travel: ", type_of_travel_options)
35
+ class_options = ['Eco', 'Eco Plus', 'Business']
36
+ class_ = st.selectbox("Please input your flight class: ", class_options)
37
+ flight_distance = st.slider("Please input your flight distance: ",0,5000)
38
+ wifi_service = st.slider("Please input your wifi experience (0:lowest 5:highest): ",0,5)
39
+ departure_arrival_conv = st.slider("Please input your departure or arrival time convenience experience (0:lowest 5:highest): ",0,5)
40
+ online_booking_exp = st.slider("Please input your online booking experience (0:lowest 5:highest): ",0,5)
41
+ gate_loc_exp = st.slider("Please input your gate location experience (0:lowest 5:highest): ",0,5)
42
+ food_drinks_exp = st.slider("Please input your food & drinks experience (0:lowest 5:highest): ",0,5)
43
+ online_boarding_exp = st.slider("Please input your online boarding experience (0:lowest 5:highest): ",0,5)
44
+ seat_comfort_exp = st.slider("Please input your seat comfort experience (0:lowest 5:highest): ",0,5)
45
+ inflight_entertainment_exp = st.slider("Please input your inflight entertainment experience (0:lowest 5:highest): ",0,5)
46
+ on_board_svc_exp = st.slider("Please input your on-board service experience (0:lowest 5:highest): ",0,5)
47
+ leg_room_svc_exp = st.slider("Please input your leg room service experience (0:lowest 5:highest): ",0,5)
48
+ baggage_handling_exp = st.slider("Please input your baggage handling experience (0:lowest 5:highest): ",0,5)
49
+ checkin_svc_exp = st.slider("Please input your check-in service experience (0:lowest 5:highest): ",0,5)
50
+ inflight_svc_exp = st.slider("Please input your inflight service experience (0:lowest 5:highest): ",0,5)
51
+ cleanliness = st.slider("How do you rate our cleanliness? (0:lowest 5:highest): ",0,5)
52
+ depart_delay = st.slider("Did you experience delay in your departure? if so please specify (in minutes): ",0,1500)
53
+ arriv_delay = st.slider("Did you experience delay in your arrival? if so please specify (in minutes): ",0,1500)
54
+
55
+
56
+ if st.button("Submit"):
57
+ D = {
58
+ 'Gender':gender,
59
+ 'Customer Type':customer_type,
60
+ 'Age':age,
61
+ 'Type of Travel':type_of_travel,
62
+ 'Class':class_,
63
+ 'Flight Distance':flight_distance,
64
+ 'Inflight wifi service':wifi_service,
65
+ 'Departure/Arrival time convenient':departure_arrival_conv,
66
+ 'Ease of Online booking':online_booking_exp,
67
+ 'Gate location':gate_loc_exp,
68
+ 'Food and drink':food_drinks_exp,
69
+ 'Online boarding':online_boarding_exp,
70
+ 'Seat comfort':seat_comfort_exp,
71
+ 'Inflight entertainment':inflight_entertainment_exp,
72
+ 'On-board service':on_board_svc_exp,
73
+ 'Leg room service':leg_room_svc_exp,
74
+ 'Baggage handling':baggage_handling_exp,
75
+ 'Checkin service':checkin_svc_exp,
76
+ 'Inflight service':inflight_svc_exp,
77
+ 'Cleanliness':cleanliness,
78
+ 'Departure Delay in Minutes':depart_delay,
79
+ 'Arrival Delay in Minutes':arriv_delay,
80
+ }
81
+
82
+ # construct data inference dalam dataframe
83
+ data_infer = pd.DataFrame(data=D,columns=features,index=[0])
84
+
85
+ #panggil fungsi inference
86
+ pred = infer(data_infer)
87
+
88
+
89
+ st.header(f"Prediction Result: ")
90
+ st.write("You are most likely " + pred[0] + " with your flight experience")
91
+
catb_randcv.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b752160f474c7529bf305e6bcd840f4b3026434be22e4986877d73bf46bb8d32
3
+ size 3858296
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ joblib==1.1.0
2
+ numpy==1.21.5
3
+ pandas==1.4.4
4
+ scikit-learn==1.1.1
5
+