Spaces:
Runtime error
Runtime error
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) | |