Spaces:
Runtime error
Runtime error
gaspar-avit
commited on
Commit
•
83c060a
1
Parent(s):
8ca3cad
Upload app.py
Browse files
app.py
CHANGED
@@ -102,20 +102,24 @@ def get_input_data():
|
|
102 |
col_age, col_sex = st.columns(2)
|
103 |
with col_age:
|
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)
|
115 |
with col_height:
|
116 |
session.input_data.loc[0, 'height'] = st.slider('Height', 140, 200)
|
|
|
|
|
117 |
with col_weight:
|
118 |
session.input_data.loc[0, 'weight'] = st.slider('Weight', 40, 140)
|
|
|
|
|
119 |
|
120 |
# Row 3
|
121 |
col_ap_hi, col_ap_lo = st.columns(2)
|
@@ -134,26 +138,37 @@ def get_input_data():
|
|
134 |
session.input_data.loc[0, 'cholesterol'] = [
|
135 |
1 if 'Normal' in cholest else 2 if 'Above normal' in cholest
|
136 |
else 3][0]
|
|
|
|
|
|
|
137 |
with col_gluc:
|
138 |
gluc = st.radio(
|
139 |
'Glucose', ['Normal', 'Above normal', 'Well above normal'])
|
140 |
session.input_data.loc[0, 'gluc'] = [
|
141 |
1 if 'Normal' in gluc else 2 if 'Above normal' in gluc
|
142 |
else 3][0]
|
|
|
|
|
143 |
|
144 |
# Row 5
|
145 |
col_alco, col_smk = st.columns(2)
|
146 |
with col_alco:
|
147 |
alco = st.radio('Alcohol intake', ['Yes', 'No'])
|
148 |
session.input_data.loc[0, 'alco'] = [1 if 'Yes' in alco else 2][0]
|
|
|
|
|
149 |
with col_smk:
|
150 |
smoke = st.radio('Smoking', ['Yes', 'No'])
|
151 |
-
session.input_data.loc[0, 'smoke'] = [1 if 'Yes' in smoke
|
152 |
else 2][0]
|
|
|
|
|
153 |
|
154 |
# Row 6
|
155 |
active = st.radio('Physical activity', ['Yes', 'No'])
|
156 |
session.input_data.loc[0, 'active'] = [1 if 'Yes' in active else 2][0]
|
|
|
|
|
157 |
|
158 |
st.write("")
|
159 |
|
@@ -179,10 +194,10 @@ def generate_prediction(input_data):
|
|
179 |
current_time = datetime.now().strftime("%H:%M:%S")
|
180 |
st.write("Current Time =", current_time)
|
181 |
st.write(input_data)
|
182 |
-
|
183 |
prediction = MODEL.predict(input_data)
|
184 |
st.write(prediction)
|
185 |
-
|
186 |
return prediction
|
187 |
|
188 |
|
@@ -233,7 +248,6 @@ if __name__ == "__main__":
|
|
233 |
# current_time = datetime.now().strftime("%H:%M:%S")
|
234 |
# st.write("Current Time =", current_time)
|
235 |
# st.write(session.input_data)
|
236 |
-
|
237 |
|
238 |
st.text("")
|
239 |
st.text("")
|
|
|
102 |
col_age, col_sex = st.columns(2)
|
103 |
with col_age:
|
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)
|
115 |
with col_height:
|
116 |
session.input_data.loc[0, 'height'] = st.slider('Height', 140, 200)
|
117 |
+
session.input_data["height"] = session.input_data["height"].astype(
|
118 |
+
int)
|
119 |
with col_weight:
|
120 |
session.input_data.loc[0, 'weight'] = st.slider('Weight', 40, 140)
|
121 |
+
session.input_data["weight"] = session.input_data["weight"].astype(
|
122 |
+
int)
|
123 |
|
124 |
# Row 3
|
125 |
col_ap_hi, col_ap_lo = st.columns(2)
|
|
|
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(
|
146 |
'Glucose', ['Normal', 'Above normal', 'Well above normal'])
|
147 |
session.input_data.loc[0, 'gluc'] = [
|
148 |
1 if 'Normal' in gluc else 2 if 'Above normal' in gluc
|
149 |
else 3][0]
|
150 |
+
session.input_data["gluc"] = session.input_data["gluc"].astype(
|
151 |
+
'category')
|
152 |
|
153 |
# Row 5
|
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 |
|
173 |
st.write("")
|
174 |
|
|
|
194 |
current_time = datetime.now().strftime("%H:%M:%S")
|
195 |
st.write("Current Time =", current_time)
|
196 |
st.write(input_data)
|
197 |
+
|
198 |
prediction = MODEL.predict(input_data)
|
199 |
st.write(prediction)
|
200 |
+
|
201 |
return prediction
|
202 |
|
203 |
|
|
|
248 |
# current_time = datetime.now().strftime("%H:%M:%S")
|
249 |
# st.write("Current Time =", current_time)
|
250 |
# st.write(session.input_data)
|
|
|
251 |
|
252 |
st.text("")
|
253 |
st.text("")
|