nazneen commited on
Commit
eba677f
·
1 Parent(s): 64e9fde
Files changed (2) hide show
  1. app.py +16 -13
  2. error_analysis/utils/style_hacks.py +12 -2
app.py CHANGED
@@ -82,16 +82,16 @@ def data_comparison(df):
82
  ).interactive()
83
 
84
  legend = alt.Chart(df).mark_point().encode(
85
- y=alt.Y('slice:N', axis=alt.Axis(orient='left'), title=""),
86
  x=alt.X("label"),
87
  shape=alt.Shape('label', scale=alt.Scale(
88
- range=['circle', 'diamond']), legend=None),
89
  color=color
90
  ).add_selection(
91
  selection
92
  )
93
 
94
- layered = scatter |legend
95
 
96
  layered = layered.configure_axis(
97
  grid=False
@@ -189,6 +189,9 @@ def topic_distribution(weights, smoothing=0.01):
189
  if __name__ == "__main__":
190
  ### STREAMLIT APP CONGFIG ###
191
  st.set_page_config(layout="wide", page_title="Error Slice Analysis")
 
 
 
192
  lcol, rcol = st.columns([2, 3])
193
  # ******* loading the mode and the data
194
  dataset = st.sidebar.selectbox(
@@ -231,18 +234,18 @@ if __name__ == "__main__":
231
  columns=['content', 'label', 'pred', 'loss'], max_rows=100)
232
  # table_html = table_html.replace("<th>", '<th align="left">') # left-align the headers
233
  st.write(dataframe)
 
 
 
234
  # st_aggrid.AgGrid(dataframe)
235
  # table_html = dataframe.to_html(columns=['content', 'label', 'pred', 'loss'], max_rows=100)
236
  # table_html = table_html.replace("<th>", '<th align="left">') # left-align the headers
237
  # st.write(table_html)
238
 
239
- with rcol:
240
- st.title('Word Distribution in Error Slice')
241
- commontokens = frequent_tokens(data_df, tokenizer, loss_quantile=loss_quantile)
242
- st.write(commontokens)
243
- data_df['loss'] = data_df['loss'].astype(float)
244
- losses = data_df['loss']
245
- high_loss = losses.quantile(loss_quantile)
246
- data_df['slice'] = 'high-loss'
247
- data_df['slice'] = data_df['slice'].where(data_df['loss'] > high_loss, 'low-loss')
248
- quant_panel(data_df)
 
82
  ).interactive()
83
 
84
  legend = alt.Chart(df).mark_point().encode(
85
+ y=alt.Y('slice:N', axis=alt.Axis(orient='right'), title=""),
86
  x=alt.X("label"),
87
  shape=alt.Shape('label', scale=alt.Scale(
88
+ range=['circle', 'diamond']), legend=None),
89
  color=color
90
  ).add_selection(
91
  selection
92
  )
93
 
94
+ layered = legend | scatter
95
 
96
  layered = layered.configure_axis(
97
  grid=False
 
189
  if __name__ == "__main__":
190
  ### STREAMLIT APP CONGFIG ###
191
  st.set_page_config(layout="wide", page_title="Error Slice Analysis")
192
+
193
+ ut.init_style()
194
+
195
  lcol, rcol = st.columns([2, 3])
196
  # ******* loading the mode and the data
197
  dataset = st.sidebar.selectbox(
 
234
  columns=['content', 'label', 'pred', 'loss'], max_rows=100)
235
  # table_html = table_html.replace("<th>", '<th align="left">') # left-align the headers
236
  st.write(dataframe)
237
+ st.title('Word Distribution in Error Slice')
238
+ commontokens = frequent_tokens(data_df, tokenizer, loss_quantile=loss_quantile)
239
+ st.write(commontokens)
240
  # st_aggrid.AgGrid(dataframe)
241
  # table_html = dataframe.to_html(columns=['content', 'label', 'pred', 'loss'], max_rows=100)
242
  # table_html = table_html.replace("<th>", '<th align="left">') # left-align the headers
243
  # st.write(table_html)
244
 
245
+ with rcol:
246
+ data_df['loss'] = data_df['loss'].astype(float)
247
+ losses = data_df['loss']
248
+ high_loss = losses.quantile(loss_quantile)
249
+ data_df['slice'] = 'high-loss'
250
+ data_df['slice'] = data_df['slice'].where(data_df['loss'] > high_loss, 'low-loss')
251
+ quant_panel(data_df)
 
 
 
error_analysis/utils/style_hacks.py CHANGED
@@ -9,12 +9,22 @@ def init_style():
9
  """
10
  <style>
11
  /* Side Bar */
12
- .sidebar .sidebar-content {
 
 
 
 
 
 
 
13
  background-color:rgb(254 244 219);
14
  width:10rem;
15
- padding:10px 10px 10px 10px;
16
  }
17
  /* Main Panel*/
 
 
 
18
  .css-18e3th9 {
19
  padding:10px 10px 10px 10px;
20
  }
 
9
  """
10
  <style>
11
  /* Side Bar */
12
+ [data-testid="stSidebar"][aria-expanded="true"] > div:first-child {
13
+ width: 225px;
14
+ }
15
+ [data-testid="stSidebar"][aria-expanded="false"] > div:first-child {
16
+ width: 200px;
17
+ margin-left: -500px;
18
+ }
19
+ .css-1outpf7 {
20
  background-color:rgb(254 244 219);
21
  width:10rem;
22
+ padding:20px 20px 20px 20px;
23
  }
24
  /* Main Panel*/
25
+ .reportview-container .css-1lcbmhc .css-1outpf7 {
26
+ padding-top: 35px;
27
+ }
28
  .css-18e3th9 {
29
  padding:10px 10px 10px 10px;
30
  }