David Dale commited on
Commit
99bd427
·
1 Parent(s): 1d0b778

add the "best per language" option

Browse files
Files changed (1) hide show
  1. leaderboard.py +19 -10
leaderboard.py CHANGED
@@ -38,8 +38,10 @@ def leaderboard_tab():
38
 
39
  metrics = ['metricx_both', 'xcomet_both', 'CHRFpp', 'glotlid_ref']
40
  systems = sorted(set(stats["system"]))
 
41
  ALL = "ALL"
42
  MEAN = "Average"
 
43
  XX2EN = "Everything-into-English"
44
  EN2XX = "English-into-Everything"
45
 
@@ -59,9 +61,7 @@ def leaderboard_tab():
59
 
60
  gr.Markdown("## Systems ranking")
61
  # Inputs
62
- gr_level = gr.Dropdown(
63
- ["sentence_level", "paragraph_level"], value="sentence_level", label="Level"
64
- )
65
  gr_src_lang = gr.Dropdown([ALL] + sorted(langs_src), value=ALL, label="Source lang")
66
  gr_tgt_lang = gr.Dropdown([ALL] + sorted(langs_tgt), value=ALL, label="Target lang")
67
 
@@ -105,12 +105,13 @@ def leaderboard_tab():
105
  gr_tgt_lang.input(fn=tgt2src, inputs=[gr_src_lang, gr_tgt_lang], outputs=gr_src_lang)
106
 
107
  gr.Markdown("## Languages difficulty")
108
- gr_system = gr.Dropdown([MEAN] + systems, value=MEAN, label="Translation system")
109
  gr_direction = gr.Dropdown([XX2EN, EN2XX], value=XX2EN, label="Translation direction")
110
  gr_metric = gr.Dropdown(metrics, label="Quality metric", value="metricx_both")
111
- bar_controls = [gr_system, gr_direction, gr_metric]
 
112
 
113
- def get_hist(system, direction, metric):
114
  # decide on the data to process
115
  if direction == EN2XX:
116
  direction_filter = stats['src_lang'].eq('eng_Latn')
@@ -118,14 +119,22 @@ def leaderboard_tab():
118
  else:
119
  direction_filter = stats['tgt_lang'].eq('eng_Latn')
120
  lang_col = "src_lang"
121
- if system == MEAN:
122
  system_filter = stats["system"].astype(bool)
123
  else:
124
  system_filter = stats['system'].eq(system)
125
- subset = stats[system_filter & direction_filter]
126
 
127
  # Compute the means and update the plot
128
- means = subset.groupby(lang_col)[metric].mean().sort_values(
 
 
 
 
 
 
 
 
129
  ascending=(metric=="metricx_both")
130
  )
131
  means = means.to_frame().reset_index()
@@ -135,7 +144,7 @@ def leaderboard_tab():
135
  sort="y",
136
  )
137
 
138
- default_bar = get_hist(gr_system.value, gr_direction.value, gr_metric.value)
139
  gr_barplot = gr.BarPlot(**default_bar)
140
 
141
  for inp in bar_controls:
 
38
 
39
  metrics = ['metricx_both', 'xcomet_both', 'CHRFpp', 'glotlid_ref']
40
  systems = sorted(set(stats["system"]))
41
+ levels = ["sentence_level", "paragraph_level"]
42
  ALL = "ALL"
43
  MEAN = "Average"
44
+ BEST = "Best"
45
  XX2EN = "Everything-into-English"
46
  EN2XX = "English-into-Everything"
47
 
 
61
 
62
  gr.Markdown("## Systems ranking")
63
  # Inputs
64
+ gr_level = gr.Dropdown(levels, value="sentence_level", label="Level")
 
 
65
  gr_src_lang = gr.Dropdown([ALL] + sorted(langs_src), value=ALL, label="Source lang")
66
  gr_tgt_lang = gr.Dropdown([ALL] + sorted(langs_tgt), value=ALL, label="Target lang")
67
 
 
105
  gr_tgt_lang.input(fn=tgt2src, inputs=[gr_src_lang, gr_tgt_lang], outputs=gr_src_lang)
106
 
107
  gr.Markdown("## Languages difficulty")
108
+ gr_system = gr.Dropdown([MEAN, BEST] + systems, value=MEAN, label="Translation system")
109
  gr_direction = gr.Dropdown([XX2EN, EN2XX], value=XX2EN, label="Translation direction")
110
  gr_metric = gr.Dropdown(metrics, label="Quality metric", value="metricx_both")
111
+ gr_level2 = gr.Dropdown(levels, value="sentence_level", label="Level")
112
+ bar_controls = [gr_system, gr_direction, gr_metric, gr_level2]
113
 
114
+ def get_hist(system, direction, metric, level):
115
  # decide on the data to process
116
  if direction == EN2XX:
117
  direction_filter = stats['src_lang'].eq('eng_Latn')
 
119
  else:
120
  direction_filter = stats['tgt_lang'].eq('eng_Latn')
121
  lang_col = "src_lang"
122
+ if system in (MEAN, BEST):
123
  system_filter = stats["system"].astype(bool)
124
  else:
125
  system_filter = stats['system'].eq(system)
126
+ subset = stats[system_filter & direction_filter & stats["level"].eq(level)]
127
 
128
  # Compute the means and update the plot
129
+ grouped = subset.groupby(lang_col)[metric]
130
+ if system == BEST:
131
+ if metric == "metricx_both":
132
+ means = grouped.min()
133
+ else:
134
+ means = grouped.max()
135
+ else:
136
+ means = grouped.mean()
137
+ means = means.sort_values(
138
  ascending=(metric=="metricx_both")
139
  )
140
  means = means.to_frame().reset_index()
 
144
  sort="y",
145
  )
146
 
147
+ default_bar = get_hist(*[x.value for x in bar_controls])
148
  gr_barplot = gr.BarPlot(**default_bar)
149
 
150
  for inp in bar_controls: