File size: 1,888 Bytes
7ff9d99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100fb96
7ff9d99
 
 
 
d536865
7ff9d99
bfc7a1e
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
import streamlit as st
import pandas as pd
import pickle

st.title("predict patient will death or not")

#import 
rf = 'rf_pred.pkl'
rfc = pickle.load(open(rf, 'rb'))

st.write('Insert feature to predict')
age = st.slider(label='age', min_value=0, max_value=200, value=42, step=1)
ane = st.selectbox(label='anemia', options=['0', '1'])
cp = st.slider(label='creatinine_phosphokinase', min_value=0, max_value=1000, value=420, step=1)
dia = st.selectbox(label='diabetes', options=['0', '1'])
ejt = st.slider(label='ejection_fraction', min_value=0, max_value=200, value=42, step=1)
hbp = st.selectbox(label='high_blood_pressure', options=['0', '1'])
pla = st.slider(label='platelets', min_value=100000.0, max_value=999999.0, value=420000.0, step=0.01)
sc = st.slider(label='serum_creatinine', min_value=0.0, max_value=99.9, value=42.0, step=0.1)
ss = st.slider(label='serum_sodium', min_value=0, max_value=999, value=42, step=1)
sex = st.selectbox(label='sex', options=['0', '1'])
smk = st.selectbox(label='smoking', options=['0', '1'])
tym = st.slider(label='time', min_value=0, max_value=999, value=42, step=1)


# color = st.number_input(label='Colour', min_value=240, max_value=255, value=245, step=1)

# convert into dataframe

data = pd.DataFrame({'age': [age],
                'anemia': [ane],
                'creatinine_phosphokinase': [cp],
                'diabetes':[dia],
                'ejection_fraction': [ejt],
                'high_blood_pressure': [hbp],
                'platelets': [pla],
                'serum_creatinine': [sc],
                'serum_sodium': [ss],
                'sex': [sex],
                'smoking': [smk],
                'time': [tym]})

# model predict
death = rfc.predict(data).tolist()[0]

# interpretation
st.write('Predition Result: ')
if death == 0:
    st.text('yeh masih hidup')
else:
    st.text('innalilahi wa inna ilaihi rajiun')