deploy / app.py
WSYAM806's picture
Update app.py
67b989e
raw
history blame contribute delete
No virus
1.64 kB
import streamlit as st
import pandas as pd
import joblib
st.sidebar.header('Grade Challange 3')
st.sidebar.write("""
Created by Wawan Setiawan S
Use the sidebar to select input features.
""")
@st.cache
def fetch_data():
df = pd.read_csv('h8dsft_P1G3_Wawan_Setiawan.csv')
df['anaemia'] = df['anaemia'].replace({0: 'no', 1 : 'yes'})
df['diabetes'] = df['diabetes'].replace({0 : 'no', 1: 'yes'})
df['high_blood_pressure'] = df['high_blood_pressure'].replace({0 : 'no', 1: 'yes'})
df['smoking'] = df['smoking'].replace({0 : 'no', 1: 'yes'})
df['sex'] = df['sex'].replace({0 : 'female', 1: 'male'})
df['DEATH_EVENT'] = df['DEATH_EVENT'].astype(float)
return df
df = fetch_data()
creatinine_phosphokinase = st.sidebar.slider('creatinine_phosphokinase', 30,8000)
serum_creatinine = st.sidebar.slider('serum_creatinine', 0.0,10.0)
serum_sodium = st.sidebar.slider('serum_sodium', 100., 150.)
age = st.sidebar.slider('age', 1,100)
time = st.sidebar.slider('time', 1.0, 300.0)
smoking = st.sidebar.selectbox('smoking',['yes','no'])
data = {
'creatinine_phosphokinase': creatinine_phosphokinase,
'serum_creatinine': serum_creatinine,
'serum_sodium': serum_sodium,
'age': age,
'time': time,
'smoking':smoking
}
input = pd.DataFrame(data, index=[0])
st.subheader('User Input')
st.write(input)
load_model = joblib.load("all_process.pkl")
if st.button('Predict'):
prediction = load_model.predict(input)
if prediction == 1:
prediction = 'Yes'
else:
prediction = 'No'
st.write('Based on user input, the placement model predicted: ')
st.write(prediction)