Spaces:
Sleeping
Sleeping
File size: 2,294 Bytes
cd15c51 e5241ed fc73154 e5241ed cd15c51 fc73154 cd15c51 4350ab2 84357b6 4350ab2 cd15c51 4350ab2 |
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 |
import streamlit as st
import pandas as pd
import pickle
preproses = pickle.load(open("preproses.pkl", "rb"))
# import model
model = pickle.load(open("model.pkl", "rb"))
#title
st.title("Predict Death Event")
st.write("Created by Sihar Pangaribuan")
# User imput
age = st.number_input(label='Age', min_value=40, max_value=95, value=40, step=1)
anaemia = st.selectbox(label='Anemia', options=['0', '1'])
creatinine_phosphokinase = st.number_input(label='Creatinine Phosphokinase', min_value=23, max_value=7861, value=23, step=1)
diabetes = st.selectbox(label='Diabetes', options=['0', '1'])
ejection_fraction = st.number_input(label='Ejection Fraction', min_value=14, max_value=80, value=14, step=1)
high_blood_pressure = st.selectbox(label='High Blood Pressure', options=['0', '1'])
platelets = st.number_input(label='Platelets', min_value=25100.0, max_value=850000.0, value=25100.0, step=1.0)
serum_creatinine = st.number_input(label='Serum Creatinine', min_value=0.5, max_value=9.4, value=0.5, step=0.1)
serum_sodium = st.number_input(label='Serum Sodium', min_value=133, max_value=148, value=133, step=1)
sex = st.selectbox(label='Sex', options=['0', '1'])
smoking = st.selectbox(label='Smoking', options=['0', '1'])
time = st.number_input(label='Time', min_value=4, max_value=285, value=4, step=1)
# Convert ke data frame
data = pd.DataFrame({'age': [age],
'anemia': [anaemia],
'creatinine_phosphokinase': [creatinine_phosphokinase],
'diabetes':[diabetes],
'ejection_fraction': [ejection_fraction],
'high_blood_pressure': [high_blood_pressure],
'platelets': [platelets],
'serum_creatinine': [serum_creatinine],
'serum_sodium': [serum_sodium],
'sex': [sex],
'smoking': [smoking],
'time': [time]})
data = preproses.transform(data)
# model predict
if st.button('Predict'):
prediction = model.predict(data).tolist()[0]
if prediction == 1:
prediction = 'Death'
else:
prediction = 'Live'
st.write('Based on user input, predicted: ')
st.write(prediction)
# interpretation
# st.write('Predition Result: ')
# if death == 0:
# st.text('live')
# else:
# st.text('Death') |