File size: 1,640 Bytes
0dd2f2a
 
0ef800d
0dd2f2a
0ef800d
59234c3
 
0dd2f2a
 
 
 
0ef800d
0dd2f2a
59234c3
 
 
 
 
 
 
0dd2f2a
 
 
 
59234c3
 
 
 
 
67b989e
59234c3
0dd2f2a
59234c3
 
 
 
67b989e
 
 
0ef800d
0dd2f2a
 
 
 
 
0ef800d
0dd2f2a
 
 
 
 
59234c3
0dd2f2a
59234c3
0dd2f2a
 
0ef800d
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
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)