gaspar-avit commited on
Commit
6e63bb7
·
1 Parent(s): 861f354

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -4
app.py CHANGED
@@ -90,7 +90,7 @@ def update_prediction(input_data):
90
  def get_input_data():
91
  """
92
  Generate input layout and get input values.
93
-
94
  -return: DataFrame with input data.
95
  """
96
  session.input_data = pd.DataFrame()
@@ -103,7 +103,7 @@ def get_input_data():
103
  session.input_data['age'] = st.slider(
104
  'Age', 18, 75, on_change=update_prediction(session.input_data))
105
  with col_sex:
106
- session.input_data['sex'] = st.radio(
107
  'Sex', ['Female', 'Male'],
108
  on_change=update_prediction(session.input_data))
109
 
@@ -129,8 +129,41 @@ def get_input_data():
129
  'Diastolic blood pressure', 50, 120,
130
  on_change=update_prediction(session.input_data))
131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  st.write("")
133
 
 
 
 
 
 
 
134
  return session.input_data
135
 
136
 
@@ -138,9 +171,9 @@ def generate_prediction(input_data):
138
  """
139
  Generate prediction of cardiovascular disease probability based on input
140
  data.
141
-
142
  -param input_data: DataFrame with input data
143
-
144
  -return: prediction of cardiovascular disease probability
145
  """
146
  return MODEL.predict(input_data)
 
90
  def get_input_data():
91
  """
92
  Generate input layout and get input values.
93
+
94
  -return: DataFrame with input data.
95
  """
96
  session.input_data = pd.DataFrame()
 
103
  session.input_data['age'] = st.slider(
104
  'Age', 18, 75, on_change=update_prediction(session.input_data))
105
  with col_sex:
106
+ session.input_data['gender'] = st.radio(
107
  'Sex', ['Female', 'Male'],
108
  on_change=update_prediction(session.input_data))
109
 
 
129
  'Diastolic blood pressure', 50, 120,
130
  on_change=update_prediction(session.input_data))
131
 
132
+ # Row 4
133
+ col_chole, col_gluc = st.columns(2)
134
+ with col_chole:
135
+ session.input_data['cholesterol'] = st.radio(
136
+ 'Cholesterol', ['Normal', 'Above normal', 'Well above normal'],
137
+ on_change=update_prediction(session.input_data))
138
+ with col_gluc:
139
+ session.input_data['gluc'] = st.radio(
140
+ 'Glucose', ['Normal', 'Above normal', 'Well above normal'],
141
+ on_change=update_prediction(session.input_data))
142
+
143
+ # Row 5
144
+ col_alco, col_smk = st.columns(2)
145
+ with col_alco:
146
+ session.input_data['alco'] = st.radio(
147
+ 'Alcohol intake', ['Yes', 'No'],
148
+ on_change=update_prediction(session.input_data))
149
+ with col_smk:
150
+ session.input_data['smoke'] = st.radio(
151
+ 'Smoking', ['Yes', 'No'],
152
+ on_change=update_prediction(session.input_data))
153
+
154
+ # Row 6
155
+ session.input_data['active'] = st.radio(
156
+ 'Physical activity', ['Yes', 'No'],
157
+ on_change=update_prediction(session.input_data))
158
+
159
  st.write("")
160
 
161
+ # Compute extra features
162
+ session.input_data["bmi"] = session.input_data["weight"] \
163
+ / (session.input_data["height"]/100)**2
164
+ session.input_data["bad_habits"] = session.input_data["smoke"] \
165
+ & session.input_data["alco"]
166
+
167
  return session.input_data
168
 
169
 
 
171
  """
172
  Generate prediction of cardiovascular disease probability based on input
173
  data.
174
+
175
  -param input_data: DataFrame with input data
176
+
177
  -return: prediction of cardiovascular disease probability
178
  """
179
  return MODEL.predict(input_data)