Spaces:
Runtime error
Runtime error
gaspar-avit
commited on
Commit
•
270b631
1
Parent(s):
801630b
Upload app.py
Browse files
app.py
CHANGED
@@ -106,8 +106,9 @@ def get_input_data():
|
|
106 |
with col_sex:
|
107 |
session.input_data.loc[0, 'gender'] = st.radio(
|
108 |
'Sex', ['Female', 'Male'])
|
109 |
-
st.write('<style>div
|
110 |
-
</style>',
|
|
|
111 |
session.input_data["gender"] = session.input_data["gender"].astype(
|
112 |
'category')
|
113 |
|
@@ -140,8 +141,6 @@ def get_input_data():
|
|
140 |
with col_chole:
|
141 |
cholest = st.radio(
|
142 |
'Cholesterol', ['Normal', 'Above normal', 'Well above normal'])
|
143 |
-
st.write('<style>div.row-widget.stRadio > div{flex-direction:\
|
144 |
-
column;}</style>', unsafe_allow_html=True)
|
145 |
session.input_data.loc[0, 'cholesterol'] = [
|
146 |
1 if 'Normal' in cholest else 2 if 'Above normal' in cholest
|
147 |
else 3][0]
|
@@ -165,12 +164,12 @@ def get_input_data():
|
|
165 |
# Row 5
|
166 |
col_alco, col_smk = st.columns(2)
|
167 |
with col_alco:
|
168 |
-
alco = st.radio('Alcohol intake', ['Yes', 'No'])
|
169 |
session.input_data.loc[0, 'alco'] = [1 if 'Yes' in alco else 0][0]
|
170 |
session.input_data["alco"] = session.input_data["alco"].astype(
|
171 |
bool)
|
172 |
with col_smk:
|
173 |
-
smoke = st.radio('Smoking', ['Yes', 'No'])
|
174 |
session.input_data.loc[0, 'smoke'] = [1 if 'Yes' in smoke
|
175 |
else 0][0]
|
176 |
session.input_data["smoke"] = session.input_data["smoke"].astype(
|
@@ -200,18 +199,17 @@ def generate_prediction(input_data):
|
|
200 |
|
201 |
-param input_data: DataFrame with input data
|
202 |
|
203 |
-
-return:
|
204 |
"""
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
st.
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
return prediction
|
215 |
|
216 |
|
217 |
###############################
|
@@ -245,7 +243,6 @@ if __name__ == "__main__":
|
|
245 |
|
246 |
# Get inputs
|
247 |
session.input_data = get_input_data()
|
248 |
-
st.write(session.input_data)
|
249 |
|
250 |
# Create button to trigger poster generation
|
251 |
buffer1, col1, buffer2 = st.columns([1.3, 1, 1])
|
@@ -258,9 +255,6 @@ if __name__ == "__main__":
|
|
258 |
if IS_CLICKED:
|
259 |
st.write('Work in progress!')
|
260 |
prediction = generate_prediction(session.input_data)
|
261 |
-
# current_time = datetime.now().strftime("%H:%M:%S")
|
262 |
-
# st.write("Current Time =", current_time)
|
263 |
-
# st.write(session.input_data)
|
264 |
|
265 |
st.text("")
|
266 |
st.text("")
|
|
|
106 |
with col_sex:
|
107 |
session.input_data.loc[0, 'gender'] = st.radio(
|
108 |
'Sex', ['Female', 'Male'])
|
109 |
+
st.write('<style> div[data-testid=column] > div > div > div > \
|
110 |
+
div.stRadio > div{flex-direction: row;}</style>',
|
111 |
+
unsafe_allow_html=True)
|
112 |
session.input_data["gender"] = session.input_data["gender"].astype(
|
113 |
'category')
|
114 |
|
|
|
141 |
with col_chole:
|
142 |
cholest = st.radio(
|
143 |
'Cholesterol', ['Normal', 'Above normal', 'Well above normal'])
|
|
|
|
|
144 |
session.input_data.loc[0, 'cholesterol'] = [
|
145 |
1 if 'Normal' in cholest else 2 if 'Above normal' in cholest
|
146 |
else 3][0]
|
|
|
164 |
# Row 5
|
165 |
col_alco, col_smk = st.columns(2)
|
166 |
with col_alco:
|
167 |
+
alco = st.radio('Alcohol intake', ['Yes', 'No'], 'No')
|
168 |
session.input_data.loc[0, 'alco'] = [1 if 'Yes' in alco else 0][0]
|
169 |
session.input_data["alco"] = session.input_data["alco"].astype(
|
170 |
bool)
|
171 |
with col_smk:
|
172 |
+
smoke = st.radio('Smoking', ['Yes', 'No'], 'No')
|
173 |
session.input_data.loc[0, 'smoke'] = [1 if 'Yes' in smoke
|
174 |
else 0][0]
|
175 |
session.input_data["smoke"] = session.input_data["smoke"].astype(
|
|
|
199 |
|
200 |
-param input_data: DataFrame with input data
|
201 |
|
202 |
+
-return: predicted probability of having a cardiovascular disease
|
203 |
"""
|
204 |
+
# prediction = MODEL.predict(input_data)
|
205 |
+
proba = MODEL.predict_proba(input_data)
|
206 |
+
positive_proba = round(proba[1]*100)
|
207 |
+
st.markdown(f"<h1 style='text-align: center; color: grey;'>\
|
208 |
+
{positive_proba}</h1>",
|
209 |
+
unsafe_allow_html=True)
|
210 |
+
st.progress(positive_proba,
|
211 |
+
text='predicted cardiovascular disease probability.')
|
212 |
+
return proba
|
|
|
213 |
|
214 |
|
215 |
###############################
|
|
|
243 |
|
244 |
# Get inputs
|
245 |
session.input_data = get_input_data()
|
|
|
246 |
|
247 |
# Create button to trigger poster generation
|
248 |
buffer1, col1, buffer2 = st.columns([1.3, 1, 1])
|
|
|
255 |
if IS_CLICKED:
|
256 |
st.write('Work in progress!')
|
257 |
prediction = generate_prediction(session.input_data)
|
|
|
|
|
|
|
258 |
|
259 |
st.text("")
|
260 |
st.text("")
|