File size: 2,780 Bytes
fbba9c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from joblib import load

# Load the trained Random Forest model
model = load('random_forest_pipeline.joblib')

# Create the UI for input
st.title("Clinical Outcome Predictor")
st.write("Enter the clinical parameters to predict 1-year mortality.")

age = st.number_input("Age", min_value=0, max_value=120, step=1)
sex = st.selectbox("Sex", ["male", "female"])
race = st.selectbox("Race", ["black", "white", "other"])
etiology = st.selectbox("Etiology", ["alcohol", "alcohol+hcv", "hcv", "other"])
hepatorenal_syndrome = st.selectbox("Hepatorenal Syndrome", ["yes", "no"])
omeprazole = st.selectbox("Omeprazole", ["yes", "no"])
spironolactone = st.selectbox("Spironolactone", ["yes", "no"])
furosemide = st.selectbox("Furosemide", ["yes", "no"])
propanolol = st.selectbox("Propanolol", ["yes", "no"])
dialisis = st.selectbox("Dialisis", ["yes", "no"])
portal_vein_thrombosis = st.selectbox("Portal Vein Thrombosis", ["yes", "no"])
ascitis = st.selectbox("Ascitis", ["yes", "no"])
hepatocellular_carcinoma = st.selectbox("Hepatocellular Carcinoma", ["yes", "no"])
albumin = st.number_input("Albumin", format="%.2f")
total_bilirrubin = st.number_input("Total Bilirrubin", format="%.2f")
direct_bilirrubina = st.number_input("Direct Bilirrubin", format="%.2f")
inr = st.number_input("INR", format="%.2f")
creatinine = st.number_input("Creatinine", format="%.2f")
platelets = st.number_input("Platelets", format="%.2f")
ast = st.number_input("AST", format="%.2f")
alt = st.number_input("ALT", format="%.2f")
hemoglobin = st.number_input("Hemoglobin", format="%.2f")
hematocrit = st.number_input("Hematocrit", format="%.2f")
leucocytes = st.number_input("Leucocytes", format="%.2f")
sodium = st.number_input("Sodium", format="%.2f")
potassium = st.number_input("Potassium", format="%.2f")
varices = st.selectbox("Varices", ["yes", "no"])
red_wale_marks = st.selectbox("Red Wale Marks", ["yes", "no"])
rupture_point = st.selectbox("Rupture Point", ["yes", "no"])
active_bleeding = st.selectbox("Active Bleeding", ["yes", "no"])
therapy = st.selectbox("Therapy", ["Banding", "no therapy", "Other"])
terlipressin_dose = st.number_input("Terlipressin Dose", min_value=0, step=1)

# Button to predict
if st.button('Predict'):
    inputs = [age, sex, race, etiology, hepatorenal_syndrome, omeprazole, spironolactone, furosemide, propanolol, dialisis, portal_vein_thrombosis, ascitis, hepatocellular_carcinoma, albumin, total_bilirrubin, direct_bilirrubina, inr, creatinine, platelets, ast, alt, hemoglobin, hematocrit, leucocytes, sodium, potassium, varices, red_wale_marks, rupture_point, active_bleeding, therapy, terlipressin_dose]
    prediction = model.predict([inputs])[0]
    st.write('1-Year Death Risk: {}'.format('High Risk' if prediction == 1 else 'No Risk'))