Spaces:
Sleeping
Sleeping
make table pretty
Browse files
app.py
CHANGED
@@ -394,17 +394,27 @@ if st.button('π€ Run it'):
|
|
394 |
# Calc green and red probas
|
395 |
green_proba = seq_proba[0]
|
396 |
red_proba = 1 - green_proba
|
|
|
397 |
stdev = 0.01
|
398 |
score = None
|
399 |
num_obs = None
|
400 |
cond = None
|
401 |
historical_proba = None
|
|
|
|
|
402 |
|
403 |
-
if
|
|
|
|
|
|
|
|
|
|
|
404 |
# If the day is predicted to be green, say so
|
|
|
|
|
405 |
score = green_proba
|
406 |
# How many with this score?
|
407 |
-
cond = (res1['Predicted']
|
408 |
num_obs = len(res1.loc[cond])
|
409 |
# How often green?
|
410 |
historical_proba = res1.loc[cond, 'True'].mean()
|
@@ -413,21 +423,23 @@ if st.button('π€ Run it'):
|
|
413 |
|
414 |
elif green_proba <= red_proba:
|
415 |
# If the day is predicted to be green, say so
|
|
|
|
|
416 |
score = red_proba
|
417 |
# How many with this score?
|
418 |
-
cond = (res1['Predicted'] <=
|
419 |
num_obs = len(res1.loc[cond])
|
420 |
# How often green?
|
421 |
historical_proba = 1 - res1.loc[cond, 'True'].mean()
|
422 |
# print(cond)
|
423 |
|
424 |
-
|
425 |
|
426 |
results = pd.DataFrame(index=[
|
427 |
'ModelScore',
|
428 |
-
f'NumInRange ({score - stdev:.1%} - {score + stdev:.1%})',
|
429 |
'HistoricalRate'
|
430 |
-
|
|
|
431 |
|
432 |
results.columns = ['Outputs']
|
433 |
|
|
|
394 |
# Calc green and red probas
|
395 |
green_proba = seq_proba[0]
|
396 |
red_proba = 1 - green_proba
|
397 |
+
do_not_play = (seq_proba[0] > 0.4) and (seq_proba[0] <= 0.6)
|
398 |
stdev = 0.01
|
399 |
score = None
|
400 |
num_obs = None
|
401 |
cond = None
|
402 |
historical_proba = None
|
403 |
+
text_cond = None
|
404 |
+
operator = None
|
405 |
|
406 |
+
if do_not_play:
|
407 |
+
text_cond = 'β '
|
408 |
+
operator = ''
|
409 |
+
score = seq_proba[0]
|
410 |
+
|
411 |
+
elif green_proba > red_proba:
|
412 |
# If the day is predicted to be green, say so
|
413 |
+
text_cond = 'π©'
|
414 |
+
operator = '>='
|
415 |
score = green_proba
|
416 |
# How many with this score?
|
417 |
+
cond = (res1['Predicted'] >= green_proba)
|
418 |
num_obs = len(res1.loc[cond])
|
419 |
# How often green?
|
420 |
historical_proba = res1.loc[cond, 'True'].mean()
|
|
|
423 |
|
424 |
elif green_proba <= red_proba:
|
425 |
# If the day is predicted to be green, say so
|
426 |
+
text_cond = 'π₯'
|
427 |
+
operator = '<='
|
428 |
score = red_proba
|
429 |
# How many with this score?
|
430 |
+
cond = (res1['Predicted'] <= red_proba)
|
431 |
num_obs = len(res1.loc[cond])
|
432 |
# How often green?
|
433 |
historical_proba = 1 - res1.loc[cond, 'True'].mean()
|
434 |
# print(cond)
|
435 |
|
436 |
+
score_fmt = f'{score:.1%}'
|
437 |
|
438 |
results = pd.DataFrame(index=[
|
439 |
'ModelScore',
|
|
|
440 |
'HistoricalRate'
|
441 |
+
f'Num {operator} {"" if do_not_play else score_fmt}',
|
442 |
+
], data = [f'{text_cond} {score:.1%}', f'{text_cond} {historical_proba:.1%}', num_obs])
|
443 |
|
444 |
results.columns = ['Outputs']
|
445 |
|