Spaces:
Runtime error
Runtime error
File size: 2,317 Bytes
1c58500 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import streamlit as st
import pandas as pd
import numpy as np
import pickle
import json
#Load all files
with open('model.pkl', 'rb') as file_1:
model = pickle.load(file_1)
def run():
hide_streamlit_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
with st.form(key='Form Hotel'):
hotel = st.selectbox('Select Hotel',('Resort Hotel', 'City Hotel'))
lead_time = st.slider('Select lead time', 1, 1, 10000,step=1)
arrival_date_year = st.selectbox('Year',('2015','2016','2017'))
arrival_date_month = st.selectbox('Month',
('January','February','March','April','May','June','July','August','September','October','November','December',))
arrival_date_day_of_month = st.number_input('Day',1,31,step=1)
adults = st.number_input('Select Number of Adults',0,100,step=1)
children = st.number_input('Select Number of Children',0,100,step=1)
babies = st.number_input('Select Number of Babies',0,100,step=1)
previous_cancellations = st.number_input('Cancellation Number',0,100,step=1)
days_in_waiting_list = st.number_input('Days in Waiting List',0,1000,step=1)
submitted = st.form_submit_button('Predict')
data_inf = {
'hotel' : hotel,
'lead_time' : lead_time,
'arrival_date_year' : arrival_date_year,
'arrival_date_month' : arrival_date_month,
'arrival_date_day_of_month' : arrival_date_day_of_month,
'adults' : adults,
'children' : children,
'babies' : babies,
'previous_cancellations' : previous_cancellations,
'days_in_waiting_list' : days_in_waiting_list,
}
data_inf = pd.DataFrame([data_inf])
st.dataframe(data_inf)
data_trans = data_inf[['lead_time','adults','children','babies','previous_cancellations','days_in_waiting_list']]
if submitted:
data_pred_inf = model.predict(data_trans)
if data_pred_inf == 1:
st.write('likely to be canceled')
else:
st.write('likely will not be canceled')
#st.write(f'# (1 = Yes, 0 = No) : {str(int(data_pred_inf))}')
if __name__ == '__main__':
run() |