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()