maxspad commited on
Commit
709650d
Β·
1 Parent(s): 3d4b0bc

finally got the layout right

Browse files
Files changed (1) hide show
  1. app.py +42 -39
app.py CHANGED
@@ -28,8 +28,8 @@ def run_models(model_names, models, c):
28
  return results
29
 
30
 
31
- st.title('How *great* is your feedback?')
32
- st.markdown(
33
  """Medical education *requires* high-quality feedback, but evaluating feedback
34
  is difficult and time-consuming. This tool uses NLP/ML to predict a validated
35
  feedback quality metric known as the QuAL Score. *Try it for yourself!*
@@ -58,6 +58,7 @@ examples = load_pickle('test.pkl')
58
 
59
  ### Process input
60
  ex = examples['comment'].sample(1).tolist()[0]
 
61
  if 'comment' not in st.session_state:
62
  st.session_state['comment'] = ex
63
  with st.form('comment_form'):
@@ -77,13 +78,10 @@ with st.form('comment_form'):
77
 
78
  results = run_models(models_to_load, models, st.session_state['comment'])
79
 
80
- tab_titles = ['Overview', 'Q1 - Level of Detail', 'Q2 - Suggestion Given', 'Q3 - Suggestion Linked']
81
  tabs = st.tabs(tab_titles)
82
 
83
-
84
  with tabs[0]:
85
- with st.expander('About the QuAL score?'):
86
- st.markdown('**The best thing ever**!')
87
  cmap = cm.get_cmap('RdYlGn')
88
  color = cmap(results['qual']['label'] / 6.0)
89
  color = f'rgba({int(color[0]*256)}, {int(color[1]*256)}, {int(color[2]*256)}, {int(color[3]*256)})'
@@ -98,39 +96,44 @@ with tabs[0]:
98
  'bar': {'color': color, 'thickness': 1.0},
99
 
100
  }
101
- ), layout=go.Layout(width=750, height=375))# layout={'paper_bgcolor': 'rgb(245,245,245)'})#,
102
-
103
- st.plotly_chart(fig)
104
-
105
- cols = st.columns(3)
106
- cols[0].markdown('#### Level of Detail')
107
- q1lab = results['q1']['label']
108
- if q1lab == 0:
109
- md_str = '# πŸ˜₯ None'
110
- elif q1lab == 1:
111
- md_str = '# 😐 Low'
112
- elif q1lab == 2:
113
- md_str = '# 😊 Medium'
114
- elif q1lab == 3:
115
- md_str = '# 😁 High'
116
- cols[0].markdown(md_str)
117
-
118
- cols[1].markdown('#### Suggestion Given')
119
- q2lab = results['q2i']['label']
120
- if q2lab == 0:
121
- md_str = '# βœ… Yes'
122
- else:
123
- md_str = '# ❌ No'
124
- cols[1].markdown(md_str)
125
- # cols[1].markdown('# βœ… Yes', unsafe_allow_html=True)
126
-
127
- cols[2].markdown('#### Suggestion Linked')
128
- q3lab = results['q3i']['label']
129
- if q3lab == 0:
130
- md_str = '# βœ… Yes'
131
- else:
132
- md_str = '# ❌ No'
133
- cols[2].markdown(md_str)
 
 
 
 
 
134
 
135
  with tabs[1]:
136
  st.write('hello')
 
28
  return results
29
 
30
 
31
+ st.header('How *great* is your feedback?')
32
+ st.caption(
33
  """Medical education *requires* high-quality feedback, but evaluating feedback
34
  is difficult and time-consuming. This tool uses NLP/ML to predict a validated
35
  feedback quality metric known as the QuAL Score. *Try it for yourself!*
 
58
 
59
  ### Process input
60
  ex = examples['comment'].sample(1).tolist()[0]
61
+ ex = ex.strip().replace('_x000D_', '').replace('nan', 'blank')
62
  if 'comment' not in st.session_state:
63
  st.session_state['comment'] = ex
64
  with st.form('comment_form'):
 
78
 
79
  results = run_models(models_to_load, models, st.session_state['comment'])
80
 
81
+ tab_titles = ['Overview', 'Q1 - Level of Detail', 'Q2 - Suggestion Given', 'Q3 - Suggestion Linked', 'About']
82
  tabs = st.tabs(tab_titles)
83
 
 
84
  with tabs[0]:
 
 
85
  cmap = cm.get_cmap('RdYlGn')
86
  color = cmap(results['qual']['label'] / 6.0)
87
  color = f'rgba({int(color[0]*256)}, {int(color[1]*256)}, {int(color[2]*256)}, {int(color[3]*256)})'
 
96
  'bar': {'color': color, 'thickness': 1.0},
97
 
98
  }
99
+ ))#, layout=go.Layout(width=750, height=300))# layout={'paper_bgcolor': 'rgb(245,245,245)'})#,
100
+
101
+ cols = st.columns([7, 3])
102
+ with cols[0]:
103
+ st.plotly_chart(fig, use_container_width=True)
104
+ with cols[1]:
105
+
106
+
107
+ # cols = st.columns(3)
108
+ # cols[0].markdown('#### Level of Detail')
109
+ q1lab = results['q1']['label']
110
+ if q1lab == 0:
111
+ md_str = 'πŸ˜₯ None'
112
+ elif q1lab == 1:
113
+ md_str = '😐 Low'
114
+ elif q1lab == 2:
115
+ md_str = '😊 Medium'
116
+ elif q1lab == 3:
117
+ md_str = '😁 High'
118
+ # cols[0].markdown(md_str)
119
+ cols[1].metric('Level of Detail', md_str,
120
+ help='How specific was the evaluator in describing the behavior?')
121
+
122
+ q2lab = results['q2i']['label']
123
+ if q2lab == 0:
124
+ md_str = 'βœ… Yes'
125
+ else:
126
+ md_str = '❌ No'
127
+ cols[1].metric('Suggestion Given', (md_str),
128
+ help='Did the evaluator give a suggestion for improvement?')
129
+
130
+ q3lab = results['q3i']['label']
131
+ if q3lab == 0:
132
+ md_str = 'βœ… Yes'
133
+ else:
134
+ md_str = '❌ No'
135
+ cols[1].metric('Suggestion Linked', md_str,
136
+ help='Is the suggestion for improvement linked to the described behavior?')
137
 
138
  with tabs[1]:
139
  st.write('hello')