Waraporn commited on
Commit
a754bc9
1 Parent(s): e8b6dfa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -14
app.py CHANGED
@@ -2,33 +2,31 @@ import joblib
2
  import pandas as pd
3
  import streamlit as st
4
 
5
-
6
  model = joblib.load('model.joblib')
7
  unique_values = joblib.load('unique_values.joblib')
8
-
9
  unique_anaemia = unique_values["anaemia"]
10
  unique_diabetes = unique_values["diabetes"]
11
  unique_high_blood_pressure = unique_values["high_blood_pressure"]
12
  unique_sex = unique_values["sex"]
13
  unique_smoking = unique_values["smoking"]
14
 
15
-
16
  def main():
17
  st.title("Predict death rates from heart failure")
18
 
19
  with st.form("questionaire"):
20
  age = st.slider("Age", min_value=10, max_value=100)
21
- anaemia = st.selectbox("anaemia", options= unique_anaemia)
22
- creatinine_phosphokinase = st.slider("creatinine_phosphokinase (mcg/L)", min_value=20, max_value=8000)
23
  diabetes = st.selectbox("diabetes", options=unique_diabetes)
24
- ejection_fraction = st.slider("ejection_fraction (percentage)", min_value=10, max_value=100)
25
- high_blood_pressure = st.selectbox("high_blood_pressure", options= unique_high_blood_pressure)
26
  platelets = st.slider("platelets (kiloplatelets/mL)", min_value=150000, max_value=300000)
27
- serum_creatinine = st.slider("serum_creatinine (mg/dL)", min_value=0, max_value=3, step='float')
28
- serum_sodium = st.slider("serum_sodium (mEq/L)", min_value=0, max_value=200)
29
- sex = st.selectbox("sex", options= unique_sex)
30
- smoking = st.selectbox("smoking",options= unique_smoking)
31
- time= st.slider("time", min_value=0, max_value=300)
32
 
33
  # clicked==True only when the button is clicked
34
  clicked = st.form_submit_button("Predict death rates")
@@ -41,13 +39,13 @@ def main():
41
  "high_blood_pressure": [high_blood_pressure],
42
  "platelets": [platelets],
43
  "serum_creatinine": [serum_creatinine],
44
- "serum_sodium ": [serum_sodium ],
45
  "sex": [sex],
46
  "smoking": [smoking],
47
  "time": [time]}))
48
  # Show prediction
49
  result = 'DEATH' if result[0] == 1 else 'NO DEATH'
50
- st.success("Your prediction death is ", result)
51
 
52
  # Run main()
53
  if __name__ == "__main__":
 
2
  import pandas as pd
3
  import streamlit as st
4
 
 
5
  model = joblib.load('model.joblib')
6
  unique_values = joblib.load('unique_values.joblib')
7
+
8
  unique_anaemia = unique_values["anaemia"]
9
  unique_diabetes = unique_values["diabetes"]
10
  unique_high_blood_pressure = unique_values["high_blood_pressure"]
11
  unique_sex = unique_values["sex"]
12
  unique_smoking = unique_values["smoking"]
13
 
 
14
  def main():
15
  st.title("Predict death rates from heart failure")
16
 
17
  with st.form("questionaire"):
18
  age = st.slider("Age", min_value=10, max_value=100)
19
+ anaemia = st.selectbox("anaemia", options=unique_anaemia)
20
+ creatinine_phosphokinase = st.slider("creatinine_phosphokinase (mcg/L)", min_value=10, max_value=120)
21
  diabetes = st.selectbox("diabetes", options=unique_diabetes)
22
+ ejection_fraction = st.slider("ejection_fraction (percentage)", min_value=0, max_value=100)
23
+ high_blood_pressure = st.selectbox("high_blood_pressure", options=unique_high_blood_pressure)
24
  platelets = st.slider("platelets (kiloplatelets/mL)", min_value=150000, max_value=300000)
25
+ serum_creatinine = st.slider("serum_creatinine (mg/dL)", min_value=0, max_value=3, step=float)
26
+ serum_sodium = st.slider("serum_sodium (mEq/L)", min_value=100, max_value=150)
27
+ sex = st.selectbox("sex", options=unique_sex)
28
+ smoking = st.selectbox("smoking", options=unique_smoking)
29
+ time = st.slider("time: follow-up period (days)", min_value=0, max_value=300)
30
 
31
  # clicked==True only when the button is clicked
32
  clicked = st.form_submit_button("Predict death rates")
 
39
  "high_blood_pressure": [high_blood_pressure],
40
  "platelets": [platelets],
41
  "serum_creatinine": [serum_creatinine],
42
+ "serum_sodium": [serum_sodium],
43
  "sex": [sex],
44
  "smoking": [smoking],
45
  "time": [time]}))
46
  # Show prediction
47
  result = 'DEATH' if result[0] == 1 else 'NO DEATH'
48
+ st.success("Your prediction death rates is ", result)
49
 
50
  # Run main()
51
  if __name__ == "__main__":