maxspad commited on
Commit
5cc9296
β€’
1 Parent(s): 9be5a22

splitting out modules

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +4 -54
  3. overview.py +68 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ __pycache__/
app.py CHANGED
@@ -1,9 +1,9 @@
1
  import streamlit as st
2
  import transformers as tf
3
- import plotly.graph_objects as go
4
- import matplotlib.cm as cm
5
  import pandas as pd
6
 
 
 
7
 
8
  # Function to load and cache models
9
  @st.experimental_singleton(show_spinner=False)
@@ -85,55 +85,5 @@ tab_titles = ['Overview', 'Q1 - Level of Detail', 'Q2 - Suggestion Given', 'Q3 -
85
  tabs = st.tabs(tab_titles)
86
 
87
  with tabs[0]:
88
- cmap = cm.get_cmap('RdYlGn')
89
- color = cmap(results['qual']['label'] / 6.0)
90
- color = f'rgba({int(color[0]*256)}, {int(color[1]*256)}, {int(color[2]*256)}, {int(color[3]*256)})'
91
-
92
- fig = go.Figure(go.Indicator(
93
- domain = {'x': [0, 1], 'y': [0, 1]},
94
- value = results['qual']['label'],
95
- mode = "gauge+number",
96
- title = {'text': "QuAL"},
97
- gauge = {'axis': {'range': [None, 5]},
98
- 'bgcolor': 'lightgray',
99
- 'bar': {'color': color, 'thickness': 1.0},
100
-
101
- }
102
- ), layout=go.Layout(margin=dict(t=0, b=135)))#, layout=go.Layout(width=750, height=300))# layout={'paper_bgcolor': 'rgb(245,245,245)'})#,
103
-
104
- cols = st.columns([7, 3])
105
- with cols[0]:
106
- st.plotly_chart(fig, use_container_width=True)
107
- with cols[1]:
108
-
109
-
110
- # cols = st.columns(3)
111
- # cols[0].markdown('#### Level of Detail')
112
- q1lab = results['q1']['label']
113
- if q1lab == 0:
114
- md_str = 'πŸ˜₯ None'
115
- elif q1lab == 1:
116
- md_str = '😐 Low'
117
- elif q1lab == 2:
118
- md_str = '😊 Medium'
119
- elif q1lab == 3:
120
- md_str = '😁 High'
121
- # cols[0].markdown(md_str)
122
- cols[1].metric('Level of Detail', md_str,
123
- help='How specific was the evaluator in describing the behavior?')
124
-
125
- q2lab = results['q2i']['label']
126
- if q2lab == 0:
127
- md_str = 'βœ… Yes'
128
- else:
129
- md_str = '❌ No'
130
- cols[1].metric('Suggestion Given', (md_str),
131
- help='Did the evaluator give a suggestion for improvement?')
132
-
133
- q3lab = results['q3i']['label']
134
- if q3lab == 0:
135
- md_str = 'βœ… Yes'
136
- else:
137
- md_str = '❌ No'
138
- cols[1].metric('Suggestion Linked', md_str,
139
- help='Is the suggestion for improvement linked to the described behavior?')
 
1
  import streamlit as st
2
  import transformers as tf
 
 
3
  import pandas as pd
4
 
5
+ from overview import NQDOverview
6
+
7
 
8
  # Function to load and cache models
9
  @st.experimental_singleton(show_spinner=False)
 
85
  tabs = st.tabs(tab_titles)
86
 
87
  with tabs[0]:
88
+ overview = NQDOverview(st, results)
89
+ overview.draw()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
overview.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from matplotlib.cm import get_cmap
2
+ import plotly.graph_objects as go
3
+
4
+ class NQDOverview(object):
5
+ def __init__(self, parent, results,
6
+ dial_cmap='RdYlGn'):
7
+ self.p = parent
8
+ self.results = results
9
+ self.cmap = get_cmap(dial_cmap)
10
+
11
+ def _get_color(self):
12
+ color = self.cmap(self.results['qual']['label'] / 6.0)
13
+ color = f'rgba({int(color[0]*256)}, {int(color[1]*256)}, {int(color[2]*256)}, {int(color[3]*256)})'
14
+ return color
15
+
16
+ def _build_figure(self):
17
+ color = self._get_color()
18
+ fig = go.Figure(go.Indicator(
19
+ domain = {'x': [0, 1], 'y': [0, 1]},
20
+ value = self.results['qual']['label'],
21
+ mode = "gauge+number",
22
+ title = {'text': "QuAL"},
23
+ gauge = {'axis': {'range': [None, 5]},
24
+ 'bgcolor': 'lightgray',
25
+ 'bar': {'color': color, 'thickness': 1.0},
26
+
27
+ }
28
+ ),
29
+ layout=go.Layout(margin=dict(t=0, b=135))
30
+ )
31
+ return fig
32
+
33
+ def draw(self):
34
+ st = self.p
35
+
36
+ fig = self._build_figure()
37
+
38
+ cols = st.columns([7, 3])
39
+ with cols[0]:
40
+ st.plotly_chart(fig, use_container_width=True)
41
+ with cols[1]:
42
+ q1lab = self.results['q1']['label']
43
+ if q1lab == 0:
44
+ md_str = 'πŸ˜₯ None'
45
+ elif q1lab == 1:
46
+ md_str = '😐 Low'
47
+ elif q1lab == 2:
48
+ md_str = '😊 Medium'
49
+ elif q1lab == 3:
50
+ md_str = '😁 High'
51
+ cols[1].metric('Level of Detail', md_str,
52
+ help='How specific was the evaluator in describing the behavior?')
53
+
54
+ q2lab = self.results['q2i']['label']
55
+ if q2lab == 0:
56
+ md_str = 'βœ… Yes'
57
+ else:
58
+ md_str = '❌ No'
59
+ cols[1].metric('Suggestion Given', (md_str),
60
+ help='Did the evaluator give a suggestion for improvement?')
61
+
62
+ q3lab = self.results['q3i']['label']
63
+ if q3lab == 0:
64
+ md_str = 'βœ… Yes'
65
+ else:
66
+ md_str = '❌ No'
67
+ cols[1].metric('Suggestion Linked', md_str,
68
+ help='Is the suggestion for improvement linked to the described behavior?')