File size: 1,520 Bytes
4406fb8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 numpy as np
import pickle
import json

# Load All Files

with open('model_bagging.pkl', 'rb') as file_1:
  bagging_model_final = pickle.load(file_1)

with open('model_scaler-2.pkl', 'rb') as file_2:
  model_scaler = pickle.load(file_2)

with open('list_num_cols-2.txt', 'r') as file_3:
  list_num_cols = json.load(file_3)

def run():
  with st.form(key='from_patient'):
      age = st.number_input('Age', min_value=0, max_value=100, value=0, step=1, help='Usia Pasien')
      time = st.number_input('Time', min_value=0, max_value=300, value=0, step=1)
      serum_creatinine = st.number_input('Serum Creatinine', min_value=0.0, max_value=20.0, value=0.0, step=0.5)
      ejection_fraction = st.slider('Ejection Fraction', min_value=0, max_value=100, value=0, step=1)
      serum_sodium = st.number_input('Serum Sodium', min_value=0, max_value=150, value=0)
      st.markdown('---')


      submitted = st.form_submit_button('Predict')

  data_inf = {
      'Age': age,
      'Time': time,
      'Serum Creatinine': serum_creatinine,
      'Ejection Fraction': ejection_fraction,
      'Serum Sodium': serum_sodium
  }

  data_inf = pd.DataFrame([data_inf])
  st.dataframe(data_inf)

  if submitted:
    # Feature Scaling
    data_inf_scaled = model_scaler.transform(data_inf)


    # Predict using Bagging Classifier
    y_pred_inf = bagging_model_final.predict(data_inf_scaled)

    st.write('# Death Event : ', str(int(y_pred_inf)))

if __name__=='__main__':
    run()