gaspar-avit commited on
Commit
08b0baf
·
1 Parent(s): a98e1fb

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -104,11 +104,12 @@ def get_input_data():
104
  session.input_data.loc[0, 'age'] = st.slider('Age', 18, 75)
105
  # on_change=update_prediction(session.input_data)
106
  with col_sex:
107
- sex = st.radio('Sex', ['Female', 'Male'])
 
108
  st.write('<style>div.row-widget.stRadio > div{flex-direction:row;}\
109
  </style>', unsafe_allow_html=True)
110
- session.input_data.loc[0, 'gender'] = [1 if 'Female' in sex
111
- else 2][0]
112
 
113
  # Row 2
114
  col_height, col_weight = st.columns(2)
@@ -135,11 +136,15 @@ def get_input_data():
135
  with col_chole:
136
  cholest = st.radio(
137
  'Cholesterol', ['Normal', 'Above normal', 'Well above normal'])
 
 
138
  session.input_data.loc[0, 'cholesterol'] = [
139
  1 if 'Normal' in cholest else 2 if 'Above normal' in cholest
140
  else 3][0]
141
- session.input_data["cholesterol"] = session.input_data["cholesterol"].astype(
142
- 'category')
 
 
143
 
144
  with col_gluc:
145
  gluc = st.radio(
@@ -154,19 +159,19 @@ def get_input_data():
154
  col_alco, col_smk = st.columns(2)
155
  with col_alco:
156
  alco = st.radio('Alcohol intake', ['Yes', 'No'])
157
- session.input_data.loc[0, 'alco'] = [1 if 'Yes' in alco else 2][0]
158
  session.input_data["alco"] = session.input_data["alco"].astype(
159
  bool)
160
  with col_smk:
161
  smoke = st.radio('Smoking', ['Yes', 'No'])
162
  session.input_data.loc[0, 'smoke'] = [1 if 'Yes' in smoke
163
- else 2][0]
164
  session.input_data["smoke"] = session.input_data["smoke"].astype(
165
  bool)
166
 
167
  # Row 6
168
  active = st.radio('Physical activity', ['Yes', 'No'])
169
- session.input_data.loc[0, 'active'] = [1 if 'Yes' in active else 2][0]
170
  session.input_data["active"] = session.input_data["active"].astype(
171
  bool)
172
 
@@ -241,7 +246,7 @@ if __name__ == "__main__":
241
  st.text("")
242
  st.text("")
243
 
244
- # Generate poster
245
  if IS_CLICKED:
246
  st.write('Work in progress!')
247
  prediction = generate_prediction(session.input_data)
 
104
  session.input_data.loc[0, 'age'] = st.slider('Age', 18, 75)
105
  # on_change=update_prediction(session.input_data)
106
  with col_sex:
107
+ session.input_data.loc[0, 'gender'] = st.radio(
108
+ 'Sex', ['Female', 'Male'])
109
  st.write('<style>div.row-widget.stRadio > div{flex-direction:row;}\
110
  </style>', unsafe_allow_html=True)
111
+ session.input_data["gender"] = session.input_data["gender"].astype(
112
+ 'category')
113
 
114
  # Row 2
115
  col_height, col_weight = st.columns(2)
 
136
  with col_chole:
137
  cholest = st.radio(
138
  'Cholesterol', ['Normal', 'Above normal', 'Well above normal'])
139
+ st.write('<style>div.row-widget.stRadio > div{flex-direction:\
140
+ column;}</style>', unsafe_allow_html=True)
141
  session.input_data.loc[0, 'cholesterol'] = [
142
  1 if 'Normal' in cholest else 2 if 'Above normal' in cholest
143
  else 3][0]
144
+ session.input_data["cholesterol"] = (session
145
+ .input_data["cholesterol"]
146
+ .astype('category')
147
+ )
148
 
149
  with col_gluc:
150
  gluc = st.radio(
 
159
  col_alco, col_smk = st.columns(2)
160
  with col_alco:
161
  alco = st.radio('Alcohol intake', ['Yes', 'No'])
162
+ session.input_data.loc[0, 'alco'] = [1 if 'Yes' in alco else 0][0]
163
  session.input_data["alco"] = session.input_data["alco"].astype(
164
  bool)
165
  with col_smk:
166
  smoke = st.radio('Smoking', ['Yes', 'No'])
167
  session.input_data.loc[0, 'smoke'] = [1 if 'Yes' in smoke
168
+ else 0][0]
169
  session.input_data["smoke"] = session.input_data["smoke"].astype(
170
  bool)
171
 
172
  # Row 6
173
  active = st.radio('Physical activity', ['Yes', 'No'])
174
+ session.input_data.loc[0, 'active'] = [1 if 'Yes' in active else 0][0]
175
  session.input_data["active"] = session.input_data["active"].astype(
176
  bool)
177
 
 
246
  st.text("")
247
  st.text("")
248
 
249
+ # Generate prediction
250
  if IS_CLICKED:
251
  st.write('Work in progress!')
252
  prediction = generate_prediction(session.input_data)