File size: 2,245 Bytes
e0f4c21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b7573df
e0f4c21
 
 
 
b7573df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7634909
 
b7573df
 
 
 
 
 
 
e0f4c21
 
 
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
65
66
67
68
69
70
71
72
73
74
75
import streamlit as st
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import plotly.express as px
from PIL import Image

# untuk lebarkan layout setelah import
st.set_page_config(
    page_title = 'Hotel Reservation',
    layout = 'wide',
    initial_sidebar_state='expanded'
)

def run():

    # Membuat file
    st.title( 'Hotel Reservation ')

    # Membuat sub header
    st.subheader('Cancel or No Cancel Reservation')

    # Menambahkan gambar
    image = Image.open('hotel.jpg')
    st.image(image, caption='Creepy Hotel')

    # Menambahkan deskripsi
    st.write('Exploratory Data dari dataset Hotel Reservation')

    # show data frame
    st.write('Menampilkan 10 Data dari dataset')
    df = pd.read_csv('https://raw.githubusercontent.com/mukhlishr/rasyidi/main/Hotel%20Reservations.csv')
    st.dataframe(df.head(10))

    # Barplot booking status
    st.write('###### Status Cancel Reservation')
    fig=plt.figure(figsize=(15,5))
    sns.countplot(x='booking_status', data = df)
    st.pyplot(fig)


    # Barplot segmented market 
    st.write('###### Source of reservation')
    fig=plt.figure(figsize=(15,5))
    sns.countplot(x='market_segment_type', data = df)
    st.pyplot(fig)

    # Barplot price room 
    st.write('###### Price room categories (1 = low, 2 = medium, 3 = high)')
    bins = [-1, 100,200,1000]
    labels =[1,2,3]
    df['binned_price'] = pd.cut(df['avg_price_per_room'], bins,labels=labels).astype(int)
    fig=plt.figure(figsize=(15,5))
    sns.countplot(x='binned_price', data = df)
    st.pyplot(fig)

    # Barplot type room 
    st.write('###### Room type reserved')
    fig=plt.figure(figsize=(15,5))
    sns.countplot(x='room_type_reserved', data = df)
    st.pyplot(fig)    

    # Barplot lead time 
    st.write('###### lead time date reservation to date stay')
    st.write('###### 1 = < 3 days; 2 = 3-7 days; 3 = 7-14 days; 4 = 14 -30 days; 5 = 30 - 90 days; 6 = > 90 days')
    bins = [-1, 3, 7, 14,30,90,500]
    labels =[1,2,3,4,5,6]
    df['binned_lead_time'] = pd.cut(df['lead_time'], bins,labels=labels).astype(int)
    fig=plt.figure(figsize=(15,5))
    sns.countplot(x='binned_lead_time', data = df)
    st.pyplot(fig)


if __name__ == '__main__':
    run()