mukhlishr commited on
Commit
e0f4c21
1 Parent(s): 455645c

Upload 6 files

Browse files
Files changed (6) hide show
  1. app.py +11 -0
  2. eda.py +76 -0
  3. grid_rfc_best.pkl +3 -0
  4. hotel.jpg +0 -0
  5. prediction.py +64 -0
  6. requirements.txt +8 -0
app.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import eda
3
+ import prediction
4
+
5
+ navigation = st.sidebar.selectbox('pilih halaman : ', ('EDA', 'Predict Cancelation'))
6
+
7
+ if navigation == 'EDA':
8
+ eda.run()
9
+
10
+ else:
11
+ prediction.run()
eda.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import seaborn as sns
4
+ import matplotlib.pyplot as plt
5
+ import plotly.express as px
6
+ from PIL import Image
7
+
8
+ # untuk lebarkan layout setelah import
9
+ st.set_page_config(
10
+ page_title = 'Hotel Reservation',
11
+ layout = 'wide',
12
+ initial_sidebar_state='expanded'
13
+ )
14
+
15
+ def run():
16
+
17
+ # Membuat file
18
+ st.title( 'Hotel Reservation ')
19
+
20
+ # Membuat sub header
21
+ st.subheader('Cancel or No Cancel Reservation')
22
+
23
+ # Menambahkan gambar
24
+ image = Image.open('hotel.jpg')
25
+ st.image(image, caption='Creepy Hotel')
26
+
27
+ # Menambahkan deskripsi
28
+ st.write('Exploratory Data dari dataset Hotel Reservation')
29
+
30
+ # show data frame
31
+ st.write('Menampilkan 10 Data dari dataset')
32
+ df = pd.read_csv('https://raw.githubusercontent.com/mukhlishr/rasyidi/main/h8dsft_P1G3_mukhlish_rasyidi.csv')
33
+ st.dataframe(df.head(10))
34
+
35
+ # Barplot booking status
36
+ st.write('###### Status Cancel Reservation')
37
+ fig=plt.figure(figsize=(15,5))
38
+ sns.barplot(x=df['booking_status'].value_counts().index, y=df['booking_status'].value_counts())
39
+ st.pyplot(fig)
40
+
41
+ # Barplot segmented market
42
+ st.write('###### Source of reservation')
43
+ fig=plt.figure(figsize=(15,5))
44
+ sns.barplot(x=df['market_segment_type'].value_counts().index, y=df['market_segment_type'].value_counts())
45
+ st.pyplot(fig)
46
+
47
+ # Barplot price room
48
+ st.write('###### Price room categories (1 = low, 2 = medium, 3 = high)')
49
+ bins = [-1, 100,200,1000]
50
+ labels =[1,2,3]
51
+ df['binned_price'] = pd.cut(df['avg_price_per_room'], bins,labels=labels).astype(int)
52
+ fig=plt.figure(figsize=(15,5))
53
+ sns.barplot(x=df['binned_price'].value_counts().index, y=df['binned_price'].value_counts())
54
+ st.pyplot(fig)
55
+
56
+ # Barplot type room
57
+ st.write('###### Room type reserved')
58
+ fig=plt.figure(figsize=(15,5))
59
+ sns.barplot(x=df['room_type_reserved'].value_counts().index, y=df['room_type_reserved'].value_counts())
60
+ st.pyplot(fig)
61
+
62
+ # Barplot lead time
63
+ st.write('###### lead time date reservation to date stay (1 = low, 2 = medium, 3 = high)')
64
+ st.write('###### 1 = < 3 days, 2 = 3-7 days, 3 = 7-14 days, 4 = 14 -30 days, 5 = 30 - 90 days, 6 = > 90 days)')
65
+ bins = [-1, 3, 7, 14,30,90,500]
66
+ labels =[1,2,3,4,5,6]
67
+ df['binned_lead_time'] = pd.cut(df['lead_time'], bins,labels=labels).astype(int)
68
+ fig=plt.figure(figsize=(15,5))
69
+ sns.barplot(x=df['binned_lead_time'].value_counts().index, y=df['binned_lead_time'].value_counts())
70
+ st.pyplot(fig)
71
+
72
+
73
+
74
+
75
+ if __name__ == '__main__':
76
+ run()
grid_rfc_best.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b7d5fd666a9858a977e3ee8c1a7d0d80e0a49e3bf80083f80abda498e9a66d8
3
+ size 472064636
hotel.jpg ADDED
prediction.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import pickle
4
+
5
+
6
+
7
+ # Load All Files
8
+
9
+ with open('grid_rfc_best.pkl', 'rb') as file_1:
10
+ grid_rfc_best = pickle.load(file_1)
11
+
12
+
13
+
14
+
15
+ # bikin fungsi
16
+ def run():
17
+
18
+ with st.form(key='Reserved_data'):
19
+ no_of_adults = st.selectbox('adult(s)', (1,2,3,4,5,6,7,8), index=1, help='How many adults will stay')
20
+ no_of_children = st.selectbox('children', (0,1,2,3,4), index=0, help='How many adults will stay')
21
+ no_of_weekend_nights = st.selectbox('Weekend Night', (0,1,2,3,4,5,6,7,8,9,10), index=1, help='How many Night will stay at weekend')
22
+ no_of_week_nights = st.number_input('Weekdays Night', min_value=0, max_value=20, value=1, help='How many Night will stay at weekdays')
23
+ type_of_meal_plan = st.selectbox('Type of Meal', (1,2,3,4), index=1, help='1 = type 1 \n 2 = type 2 \n 3 = type 3 \n 4 = Not Selected')
24
+ required_car_parking_space = st.radio('Car Parking', (0, 1), index=1, help='0 = No \n 1 = Yes')
25
+ room_type_reserved = st.selectbox('Room Type', (1,2,3,4,5,6,7), index=1)
26
+ arrival_month = st.selectbox('Arrival Month', (1,2,3,4,5,6,7,8,9,10,11,12), index=1)
27
+ market_segment_type = st.radio('Source order', (1, 2, 3, 4, 5), index=1, help='1=online \n 2=offline \n 3=corporate \n 4=complementary \n 5=aviation')
28
+ no_of_previous_cancellations = st.selectbox('History Cancel', (0,1,2,3,4,5,6,7,8,9,10), index=0)
29
+ no_of_special_requests = st.selectbox(' Special Request', (0,1,2,3,4,5), index=0)
30
+ binned_lead_time = st.radio('Lead time', (1, 2, 3, 4, 5,6), index=1, help='1= <3 days \n 2= 3-7 days \n 3= 7-14 days \n 4= 14-30 days \n 5=30-90 days \n 6= >90 days')
31
+ binned_no_cancel = st.radio('History not Cancel', (0,1), index=1)
32
+ binned_price = st.radio('Type of Price', (1, 2, 3), index=1, help='1 = low \n 2 = medium \n 3 = high')
33
+ st.markdown('---')
34
+
35
+ submitted = st.form_submit_button('Predict')
36
+
37
+ data_inf = {
38
+ 'no_of_adults': no_of_adults,
39
+ 'no_of_children':no_of_children,
40
+ 'no_of_weekend_nights' :no_of_weekend_nights,
41
+ 'no_of_week_nights':no_of_week_nights,
42
+ 'type_of_meal_plan':type_of_meal_plan,
43
+ 'required_car_parking_space': required_car_parking_space,
44
+ 'room_type_reserved': room_type_reserved,
45
+ 'arrival_month': arrival_month,
46
+ 'market_segment_type' : market_segment_type,
47
+ 'no_of_previous_cancellations' : no_of_previous_cancellations,
48
+ 'no_of_special_requests' : no_of_special_requests,
49
+ 'binned_lead_time' : binned_lead_time,
50
+ 'binned_no_cancel' : binned_no_cancel,
51
+ 'binned_price': binned_price
52
+ }
53
+
54
+ data_inf = pd.DataFrame([data_inf])
55
+ st.dataframe(data_inf)
56
+
57
+ if submitted:
58
+
59
+ # Predict using grid_rfc
60
+ y_pred_inf = grid_rfc_best.predict(data_inf)
61
+ st.write('# Rating: ', str(int(y_pred_inf)))
62
+
63
+ if __name__ == '__main__':
64
+ run()
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # daftar library yang dibutuhkan semua
2
+ streamlit
3
+ pandas
4
+ seaborn
5
+ matplotlib
6
+ numpy
7
+ scikit-learn==1.2.1
8
+ plotly