Gansol commited on
Commit
76ddd0e
1 Parent(s): e6d8a20

Upload 6 files

Browse files
Files changed (6) hide show
  1. app.py +10 -0
  2. best_param.pkl +3 -0
  3. eda.py +85 -0
  4. hotel_reservations.csv +0 -0
  5. prediction.py +77 -0
  6. preprocessing_pipeline.pkl +3 -0
app.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import eda
3
+ import prediction
4
+ import seaborn
5
+
6
+ Navigation = st.sidebar.selectbox('Pilih Halaman:', ('EDA','Predict Visitors Hotel Reservation'))
7
+ if Navigation == 'EDA':
8
+ eda.run()
9
+ else:
10
+ prediction.run()
best_param.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e119733908fd32e92d4116a265f26104c7b8ca893b0d30ee7147fb2f534881ec
3
+ size 484040
eda.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # Set page config
9
+ st.set_page_config(
10
+ page_title= 'Hotel_Reservation_EDA',
11
+ layout= 'wide',
12
+ initial_sidebar_state= 'expanded'
13
+ )
14
+
15
+ # Create Function for EDA
16
+ def run():
17
+ #Create title
18
+ st.title('Hotel Reservation Visitors')
19
+
20
+ # Create Sub Header atau Sub Judul
21
+ st.subheader('EDA untuk Analisis Dataset ')
22
+
23
+ # Add Image
24
+ st.image('https://www.hotellinksolutions.com/images/blog/avt.jpg', caption= 'Hotel Reservation')
25
+
26
+ # Create a Description
27
+ st.write('Page Made by Allen')
28
+
29
+
30
+ # Magic Syntax
31
+ '''
32
+ Pada page kali ini, penulis akan melakukan eksplorasi sederhana,
33
+ Dataset yang digunakan adalah Credit Card Default.
34
+ Dataset ini berasal dari Big Query Google
35
+
36
+ '''
37
+
38
+ # Create Straight Line
39
+ st.markdown('---')
40
+
41
+ # Show Dataframe
42
+ df = pd.read_csv('hotel_reservations.csv')
43
+ st.dataframe(df)
44
+
45
+ # Booking Status
46
+ st.write('### Plot Booking Status Customer')
47
+ fig= plt.figure(figsize=(20,5))
48
+ sns.countplot(x='booking_status', data=df)
49
+ st.pyplot(fig)
50
+ st.write('From information above we can take an information that visitors that not canceled their booking is bigger than canceled their booking `67.2%` to `32.8%`.')
51
+
52
+ st.write('### Plot Room Type Customer')
53
+ fig= plt.figure(figsize=(20,5))
54
+ sns.countplot(x='room_type_reserved', data=df)
55
+ st.pyplot(fig)
56
+ st.write('From the information above `Room type 1` is the highest room type reserved by booking status and then the second popular is `Room type 4`')
57
+
58
+ st.write('### Plot Market Segment')
59
+ fig= plt.figure(figsize=(20,5))
60
+ sns.countplot(x='market_segment_type', data=df)
61
+ st.pyplot(fig)
62
+ st.write('Market segment of booking status majority from online')
63
+
64
+ st.write('### Plot Type of Meal Plan')
65
+ fig= plt.figure(figsize=(20,5))
66
+ sns.countplot(x='type_of_meal_plan', data=df)
67
+ st.pyplot(fig)
68
+ st.write('Visitors that not canceled and canceled in how they chose meal plan, the meal plan 1 is occupied the first place')
69
+
70
+ st.write('### Plot Arrival Year')
71
+ fig= plt.figure(figsize=(20,5))
72
+ sns.countplot(x='arrival_year', data=df)
73
+ st.pyplot(fig)
74
+
75
+ st.write('### Plot Arrival Month')
76
+ fig= plt.figure(figsize=(20,5))
77
+ sns.countplot(x='arrival_month', data=df)
78
+ st.pyplot(fig)
79
+ st.write('The Conclusion Based on Arrival Year and Arrival Month is visitors activity in reservation hotel, crowded in October 2018')
80
+
81
+
82
+
83
+
84
+ if __name__ == '__main__':
85
+ run()
hotel_reservations.csv ADDED
The diff for this file is too large to render. See raw diff
 
prediction.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import json
3
+ import pandas as pd
4
+ import numpy as np
5
+ import streamlit as st
6
+
7
+ # Load All Files
8
+ with open('best_param.pkl', 'rb') as file_1:
9
+ best_params = pickle.load(file_1)
10
+
11
+ with open('preprocessing_pipeline.pkl', 'rb') as file_2:
12
+ preprocessing_pipeline= pickle.load(file_2)
13
+
14
+ def run ():
15
+ with st.form(key ='PREDICT VISITORS FORM'): #Nulis nama sendiri menggunakan name= st.text_input('')
16
+ Booking_ID= st.text_input('Booking_ID', 'Input ID Here')
17
+ no_of_adults = st.number_input('Number of Adults')
18
+ no_of_children= st.number_input('Number of Children')
19
+ no_of_weekend_nights= st.number_input('Number of Weekend Nights', min_value=0, max_value=7)
20
+ no_of_week_nights= st.number_input('Number of Week Nights', min_value=0, max_value=17)
21
+ type_of_meal_plan= st.selectbox(
22
+ 'Choose your Meal Plan',
23
+ ('Meal Plan 1', 'Not Selected', 'Meal Plan 2', 'Meal Plan 3'))
24
+ required_car_parking_space= st.number_input('Required Car Parking Space')
25
+ room_type_reserved= st.selectbox(
26
+ 'Choose your Room Type',
27
+ ('Room_Type 1', 'Room_Type 4', 'Room_Type 2', 'Room_Type 6',
28
+ 'Room_Type 5', 'Room_Type 7', 'Room_Type 3'))
29
+ lead_time= st.number_input('The number of days between booking and arrival')
30
+ arrival_year= st.number_input('The year of arrival')
31
+ arrival_month= st.number_input('The month of arrival', min_value=1, max_value=12)
32
+ arrival_date= st.number_input('The date of arrival', min_value=1, max_value=31)
33
+ market_segment_type= st.selectbox(
34
+ 'What Segment Type of Customer',
35
+ ('Offline', 'Online', 'Corporate', 'Aviation', 'Complementary'))
36
+ repeated_guest= st.number_input('Repeated Guest')
37
+ no_of_previous_cancellations= st.number_input('The number of previous cancellations by the guest')
38
+ no_of_previous_bookings_not_canceled= st.number_input('The number of previous bookings not canceled by the guest')
39
+ avg_price_per_room= st.number_input('The average price per room')
40
+ no_of_special_requests= st.number_input('The number of special requests made by the guest', min_value=0, max_value=5)
41
+ submitted = st.form_submit_button('Predict')
42
+
43
+ # Create New Data
44
+ df_inf={
45
+ 'Booking_ID': Booking_ID,
46
+ 'no_of_adults': no_of_adults,
47
+ 'no_of_children': no_of_children,
48
+ 'no_of_weekend_nights':no_of_weekend_nights,
49
+ 'no_of_week_nights':no_of_week_nights,
50
+ 'type_of_meal_plan':type_of_meal_plan,
51
+ 'required_car_parking_space': required_car_parking_space,
52
+ 'room_type_reserved':room_type_reserved,
53
+ 'lead_time':lead_time,
54
+ 'arrival_year': arrival_year,
55
+ 'arrival_month':arrival_month,
56
+ 'arrival_date':arrival_date,
57
+ 'market_segment_type':market_segment_type,
58
+ 'repeated_guest':repeated_guest,
59
+ 'no_of_previous_cancellations':no_of_previous_cancellations,
60
+ 'no_of_previous_bookings_not_canceled':no_of_previous_bookings_not_canceled,
61
+ 'avg_price_per_room':avg_price_per_room,
62
+ 'no_of_special_requests':no_of_special_requests,
63
+ }
64
+ df_inf = pd.DataFrame([df_inf])
65
+
66
+ if submitted:
67
+ prediction = best_params.predict(df_inf)
68
+ st.write('This Visitor Predicted:', round(prediction[0],2))
69
+ # df_inf_best_params = df_inf[best_params]
70
+ # df_inf_classifier= df_inf[preprocessing_pipeline]
71
+ # df_inf_final = np.concatenate([preprocessing_pipeline], axis=1)
72
+ # y_pred_inf = best_params.predict(df_inf_final)
73
+ # st.write(f'# Rating {best_params}:', int(y_pred_inf))
74
+
75
+
76
+ if best_params == '__main__':
77
+ run()
preprocessing_pipeline.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b20647fc0cb2061834ad51b08d3c948d7ac212fbf99c80caf2e9349896603014
3
+ size 2709