import streamlit as st import pandas as pd import numpy as np import pickle import json import joblib as jb #load models model = jb.load('model.pkl') def run(): with st.form('key=form_prediction') : age = st.number_input('Age', min_value=40, max_value=95, value= 60, step=1, help='Usia anda') anaemia = st.selectbox('Anemia',(0,1), index= 1) creatinine_phosphokinase= st.number_input('creatinine_phosphokinase', min_value=23, max_value=7861) diabetes = st.selectbox('Diabetes',(0,1), index= 1) ejection_fraction = st.number_input('ejection_fraction', min_value=14, max_value=80) high_blood_pressure = st.selectbox('Tekanan Darah',(0,1), index= 1) platelets = st.number_input('platelets', min_value=25100, max_value=850000) serum_creatinine = st.number_input('serum creatinine',min_value=0.5,max_value=9.4) serum_sodium = st.number_input('serum_sodium',min_value=113, max_value=148) sex = st.selectbox('Jenis Kelamin',(0,1), index= 1) smoking = st.selectbox('smoking',(0,1), index= 1) time = st.slider('serum creatinine',4,135,285) submitted = st.form_submit_button('Predict') data_inf = { 'age': age, 'anaemia': 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_inf = pd.DataFrame([data_inf]) st.dataframe(data_inf) if submitted: # Predict using bagging y_pred_inf = model.predict(data_inf) st.write('# Death Prediction : ', str(int(y_pred_inf))) if __name__=='__main__': run()