ashok2216 commited on
Commit
3aca0ee
1 Parent(s): d90af26

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +117 -0
  2. model.pkl +3 -0
  3. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # pickling the model
2
+ import pandas as pd
3
+ import numpy as np
4
+ import pickle
5
+ import streamlit as st
6
+ from PIL import Image
7
+
8
+ # loading in the model to predict on the data
9
+ pickle_in = open('model.pkl', 'rb')
10
+ model = pickle.load(pickle_in)
11
+
12
+ def welcome():
13
+ return 'welcome all'
14
+
15
+
16
+ def prediction(no_of_adults, no_of_children, no_of_weekend_nights,
17
+ no_of_week_nights, type_of_meal_plan, required_car_parking_space,
18
+ room_type_reserved, lead_time, arrival_year, arrival_month, arrival_date,
19
+ market_segment_type, repeated_guest, no_of_previous_cancellations, no_of_previous_bookings_not_canceled,
20
+ avg_price_per_room, no_of_special_requests):
21
+
22
+ prediction = model.predict(
23
+ [[no_of_adults, no_of_children, no_of_weekend_nights,
24
+ no_of_week_nights, type_of_meal_plan, required_car_parking_space,
25
+ room_type_reserved, lead_time, arrival_year, arrival_month, arrival_date,
26
+ market_segment_type, repeated_guest, no_of_previous_cancellations, no_of_previous_bookings_not_canceled,
27
+ avg_price_per_room, no_of_special_requests]])
28
+ print(prediction)
29
+ return prediction
30
+
31
+
32
+ def main():
33
+
34
+ st.title("Hotel Reservation Prediction")
35
+ html_temp = """
36
+ <div style ="background-color:gry;padding:13px">
37
+ <h1 style ="color:gray;text-align:center;">Streamlit Hotel Reservation Prediction ML App </h1>
38
+ </div>
39
+ """
40
+ st.markdown(html_temp, unsafe_allow_html = True)
41
+ result =""
42
+
43
+
44
+ no_of_adults = st.slider('No of Adults', 0, 4, 0)
45
+ st.write("You Selected", no_of_adults, 'Adults')
46
+
47
+ no_of_children = st.slider('no_of_children', 0, 10, 0)
48
+ st.write("You Selected", no_of_children, 'no_of_children')
49
+
50
+ no_of_weekend_nights = st.slider('no_of_weekend_nights', 0, 7, 0)
51
+ st.write("You Selected", no_of_weekend_nights, 'Adults')
52
+
53
+ no_of_week_nights = st.slider('no_of_week_nights', 0, 17, 0)
54
+ st.write("You Selected", no_of_week_nights, 'Adults')
55
+
56
+ type_of_meal_plan = st.slider('type_of_meal_plan', 0, 3, 0)
57
+ st.write("You Selected", type_of_meal_plan, 'Adults')
58
+
59
+ required_car_parking_space = st.slider('required_car_parking_space', 0, 1, 0)
60
+ if required_car_parking_space == 0:
61
+ parking = 'Yes'
62
+ else:
63
+ parking ='No'
64
+ st.write("You Selected", parking, 'Adults')
65
+
66
+ room_type_reserved = st.slider('room_type_reserved', 0, 6, 0)
67
+ st.write("You Selected", room_type_reserved, 'Adults')
68
+
69
+ lead_time = st.slider('lead_time', 0, 450, 0)
70
+ st.write("You Selected", lead_time, 'Adults')
71
+
72
+ arrival_year = st.selectbox(
73
+ '2017', '2018')
74
+
75
+ st.write("You Selected", arrival_year, 'Adults')
76
+
77
+ arrival_month = st.slider('arrival_month', 1, 12, 0)
78
+ st.write("You Selected", arrival_month, 'Adults')
79
+
80
+ arrival_date = st.slider('arrival_date', 1, 31, 0)
81
+ st.write("You Selected", arrival_date, 'Adults')
82
+
83
+ market_segment_type = st.slider('market_segment_type', 0, 4, 0)
84
+ st.write("You Selected", market_segment_type, 'Adults')
85
+
86
+ repeated_guest = st.slider('repeated_guest', 0, 1, 0)
87
+ st.write("You Selected", repeated_guest, 'Adults')
88
+
89
+ no_of_previous_cancellations = st.slider('no_of_previous_cancellations', 0, 13, 0)
90
+ st.write("You Selected", no_of_previous_cancellations, 'Adults')
91
+
92
+ no_of_previous_bookings_not_canceled = st.slider('no_of_previous_bookings_not_canceled', 0, 60, 0)
93
+ st.write("You Selected", no_of_previous_bookings_not_canceled, 'Adults')
94
+
95
+ avg_price_per_room = st.slider('avg_price_per_room', 0, 540, 0)
96
+ st.write("You Selected", avg_price_per_room, 'Adults')
97
+
98
+ no_of_special_requests = st.slider('no_of_special_requests', 0, 5, 0)
99
+ st.write("You Selected", no_of_special_requests, 'Adults')
100
+ if st.button("Predict"):
101
+ result = prediction(no_of_adults, no_of_children, no_of_weekend_nights,
102
+ no_of_week_nights, type_of_meal_plan, required_car_parking_space,
103
+ room_type_reserved, lead_time, arrival_year, arrival_month, arrival_date,
104
+ market_segment_type, repeated_guest, no_of_previous_cancellations, no_of_previous_bookings_not_canceled,
105
+ avg_price_per_room, no_of_special_requests)
106
+
107
+ # st.success('The output is {0}'.format(result))
108
+ if result == 0:
109
+ result = 'Not Cancelled'
110
+ elif result == 1:
111
+ result = 'Cancelled'
112
+
113
+ st.success('The Reservation is {0}'.format(result))
114
+
115
+
116
+ if __name__=='__main__':
117
+ main()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bbd11e44c7aff6b8935f7c643c7b07480fee9b79514d53d377fc8650c672e179
3
+ size 457070
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ pickle5
4
+ streamlit
5
+ scikit-learn