ardifarizky commited on
Commit
1c58500
1 Parent(s): ef864b3

first commit

Browse files
Files changed (5) hide show
  1. app.py +11 -0
  2. eda.py +43 -0
  3. model.pkl +3 -0
  4. pred.py +64 -0
  5. requirements.txt +8 -0
app.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import eda
3
+ import pred
4
+
5
+ page = st.sidebar.selectbox('Pilih Halaman: ', ('Prediction', 'EDA'))
6
+
7
+ if page == 'EDA':
8
+ eda.run()
9
+ else:
10
+ pred.run()
11
+
eda.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ st.set_page_config(
9
+ page_title= 'FIFA 2022',
10
+ layout='wide',
11
+ initial_sidebar_state='expanded'
12
+ )
13
+
14
+ hide_streamlit_style = """
15
+ <style>
16
+ #MainMenu {visibility: hidden;}
17
+ footer {visibility: hidden;}
18
+ </style>
19
+ """
20
+ st.markdown(hide_streamlit_style, unsafe_allow_html=True)
21
+
22
+
23
+
24
+
25
+ def run():
26
+
27
+ st.title('Heart Failure Prediction')
28
+ # st.subheader('Heart Failure Prediction Exploratory Data Analysis')
29
+ # #Show Dataframe
30
+ # d = pd.read_csv('h8dsft_P1G3_Ardifa-Rizky-Saputra.csv')
31
+ # st.dataframe(d)
32
+
33
+ # st.write('#### scatterplot berdasarkan Input User')
34
+ # pilihan1 = st.selectbox('Pilih column : ', ('age', 'creatinine_phosphokinase','ejection_fraction', 'platelets','serum_creatinine', 'serum_sodium', 'time'),key=1)
35
+ # pilihan2 = st.selectbox('Pilih column : ', ('age', 'creatinine_phosphokinase','ejection_fraction', 'platelets','serum_creatinine', 'serum_sodium', 'time'),key=2)
36
+ # pilihan3 = st.selectbox('Pilih column : ', ('anaemia', 'diabetes','high_blood_pressure', 'sex','smoking', 'DEATH_EVENT'),key=3)
37
+ # fig = plt.figure(figsize=(15, 5))
38
+ # sns.scatterplot(data=d,x=d[pilihan1],y=d[pilihan2],hue=d[pilihan3])
39
+ # st.pyplot(fig)
40
+
41
+
42
+ if __name__ == '__main__':
43
+ run()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:853b83ac1f391f0e7740ce417fb179e18e50ad49dd79e2b70ca06d8bcb32fbee
3
+ size 403252
pred.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import pickle
5
+ import json
6
+
7
+ #Load all files
8
+
9
+ with open('model.pkl', 'rb') as file_1:
10
+ model = pickle.load(file_1)
11
+
12
+ def run():
13
+
14
+ hide_streamlit_style = """
15
+ <style>
16
+ #MainMenu {visibility: hidden;}
17
+ footer {visibility: hidden;}
18
+ </style>
19
+ """
20
+ st.markdown(hide_streamlit_style, unsafe_allow_html=True)
21
+
22
+
23
+ with st.form(key='Form Hotel'):
24
+ hotel = st.selectbox('Select Hotel',('Resort Hotel', 'City Hotel'))
25
+ lead_time = st.slider('Select lead time', 1, 1, 10000,step=1)
26
+ arrival_date_year = st.selectbox('Year',('2015','2016','2017'))
27
+ arrival_date_month = st.selectbox('Month',
28
+ ('January','February','March','April','May','June','July','August','September','October','November','December',))
29
+ arrival_date_day_of_month = st.number_input('Day',1,31,step=1)
30
+ adults = st.number_input('Select Number of Adults',0,100,step=1)
31
+ children = st.number_input('Select Number of Children',0,100,step=1)
32
+ babies = st.number_input('Select Number of Babies',0,100,step=1)
33
+ previous_cancellations = st.number_input('Cancellation Number',0,100,step=1)
34
+ days_in_waiting_list = st.number_input('Days in Waiting List',0,1000,step=1)
35
+
36
+ submitted = st.form_submit_button('Predict')
37
+
38
+ data_inf = {
39
+ 'hotel' : hotel,
40
+ 'lead_time' : lead_time,
41
+ 'arrival_date_year' : arrival_date_year,
42
+ 'arrival_date_month' : arrival_date_month,
43
+ 'arrival_date_day_of_month' : arrival_date_day_of_month,
44
+ 'adults' : adults,
45
+ 'children' : children,
46
+ 'babies' : babies,
47
+ 'previous_cancellations' : previous_cancellations,
48
+ 'days_in_waiting_list' : days_in_waiting_list,
49
+ }
50
+
51
+ data_inf = pd.DataFrame([data_inf])
52
+ st.dataframe(data_inf)
53
+ data_trans = data_inf[['lead_time','adults','children','babies','previous_cancellations','days_in_waiting_list']]
54
+
55
+ if submitted:
56
+ data_pred_inf = model.predict(data_trans)
57
+ if data_pred_inf == 1:
58
+ st.write('likely to be canceled')
59
+ else:
60
+ st.write('likely will not be canceled')
61
+ #st.write(f'# (1 = Yes, 0 = No) : {str(int(data_pred_inf))}')
62
+
63
+ if __name__ == '__main__':
64
+ run()
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ numpy
4
+ seaborn
5
+ matplotlib
6
+ Pillow
7
+ plotly
8
+ scikit-learn==1.2.2