File size: 2,718 Bytes
c5fe76d
 
 
 
 
 
 
5c4c155
0cf2636
edd1f24
0cf2636
c5fe76d
0cf2636
 
c5fe76d
 
0cf2636
c5fe76d
 
0cf2636
 
04cf245
0cf2636
04cf245
0cf2636
04cf245
 
 
0cf2636
bab820b
a9680e5
c5fe76d
 
0cf2636
c5fe76d
 
0cf2636
 
 
 
 
 
 
 
c5fe76d
0cf2636
 
c5fe76d
efec75f
0cf2636
c5fe76d
 
 
 
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
import joblib
import pandas as pd
import streamlit as st


model = joblib.load('model.joblib')
unique_values = joblib.load('unique_values.joblib')
   
unique_anaemia =  unique_values["anaemia"]
unique_diabetes =  unique_values["diabetes"]
unique_high_blood_pressure =  unique_values["high_blood_pressure"]
unique_sex =  unique_values["sex"]
unique_smoking =  unique_values["smoking"]


def main():
    st.title("Predict death rates from heart failure")

    with st.form("questionaire"):
        age = st.slider("Age", min_value=0, max_value=100)
        anaemia = st.selectbox("anaemia", options= unique_anaemia)
        creatinine_phosphokinase = st.slider("creatinine_phosphokinase (mcg/L)", min_value=0, max_value=3000)
        diabetes = st.selectbox("diabetes", options=unique_diabetes)
        ejection_fraction = st.slider("ejection_fraction (percentage)", min_value=0, max_value=100)
        high_blood_pressure = st.selectbox("high_blood_pressure", options= unique_high_blood_pressure)
        platelets = st.slider("platelets (kiloplatelets/mL)", min_value=20000, max_value=900000)
        serum_creatinine = st.slider("serum_creatinine (mg/dL)", min_value=0, max_value=3)
        serum_sodium = st.slider("serum_sodium (mEq/L)", min_value=0, max_value=200)
        sex = st.selectbox("sex", options= unique_sex)
        smoking = st.selectbox("smoking",options= unique_smoking)
        time= st.slider("time", min_value=0, max_value=1000)

        # clicked==True only when the button is clicked
        clicked = st.form_submit_button("Predict death rates")
        if clicked:
            result=model.predict(pd.DataFrame({"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]}))
            # Show prediction
            result = 'DEATH' if result[0] == 1 else 'NO DEATH'
            st.success("Your prediction death is ", result)

# Run main()
if __name__ == "__main__":
    main()