Commit
·
dacb5dc
1
Parent(s):
e3097e1
Add document information
Browse files
app.py
CHANGED
@@ -185,7 +185,7 @@ class ComparisonMenu:
|
|
185 |
#
|
186 |
#
|
187 |
class ParameterLayout:
|
188 |
-
def __init__(self, name, ci=0.95):
|
189 |
self.name = name
|
190 |
self.ci = ci
|
191 |
self.summarize = DataSummarizer(self.name, self.ci)
|
@@ -215,8 +215,8 @@ class ParameterLayout:
|
|
215 |
raise NotImplementedError()
|
216 |
|
217 |
class PersonLayout(ParameterLayout):
|
218 |
-
def __init__(self, ci=0.95):
|
219 |
-
super().__init__('ability', ci)
|
220 |
|
221 |
def extra(self, df, *args):
|
222 |
with gr.Row():
|
@@ -245,18 +245,25 @@ class PersonLayout(ParameterLayout):
|
|
245 |
button.click(menu, inputs=inputs, outputs=[display])
|
246 |
|
247 |
class ItemLayout(ParameterLayout):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
def extra(self, df, *args):
|
249 |
(frame, ) = args
|
250 |
frame.select(self.df_select_callback,
|
251 |
inputs=[frame],
|
252 |
outputs=[gr.JSON()])
|
253 |
|
254 |
-
|
255 |
-
def df_select_callback(df: pd.DataFrame, evt: gr.SelectData):
|
256 |
index = df.columns.get_loc('Source')
|
257 |
-
|
258 |
-
|
259 |
-
}
|
260 |
|
261 |
#
|
262 |
#
|
@@ -265,20 +272,18 @@ with gr.Blocks() as demo:
|
|
265 |
path = str(Path('jerome-white', 'leaderboard-item-response'))
|
266 |
splits = get_dataset_split_names(path)
|
267 |
pmap = {
|
268 |
-
'alpha': ItemLayout
|
269 |
-
'beta': ItemLayout
|
270 |
-
'theta': PersonLayout
|
271 |
}
|
272 |
|
273 |
for s in splits:
|
274 |
-
|
275 |
-
df = data.to_pandas()
|
276 |
-
|
277 |
with gr.Tab(s):
|
278 |
for (i, g) in df.groupby('parameter'):
|
279 |
-
layout = pmap
|
280 |
tab = str(layout)
|
281 |
with gr.Tab(tab.title()):
|
282 |
layout(g)
|
283 |
|
284 |
-
demo.launch(
|
|
|
185 |
#
|
186 |
#
|
187 |
class ParameterLayout:
|
188 |
+
def __init__(self, name, ci=0.95, **kwargs):
|
189 |
self.name = name
|
190 |
self.ci = ci
|
191 |
self.summarize = DataSummarizer(self.name, self.ci)
|
|
|
215 |
raise NotImplementedError()
|
216 |
|
217 |
class PersonLayout(ParameterLayout):
|
218 |
+
def __init__(self, ci=0.95, **kwargs):
|
219 |
+
super().__init__('ability', ci, **kwargs)
|
220 |
|
221 |
def extra(self, df, *args):
|
222 |
with gr.Row():
|
|
|
245 |
button.click(menu, inputs=inputs, outputs=[display])
|
246 |
|
247 |
class ItemLayout(ParameterLayout):
|
248 |
+
_prefix = Path('jerome-white', 'leaderboard-documents')
|
249 |
+
|
250 |
+
def __init__(self, name, framework, ci=0.95, **kwargs):
|
251 |
+
super().__init__(name, ci, **kwargs)
|
252 |
+
ds = load_dataset(f'{self._prefix}-{framework}', split='train')
|
253 |
+
self.df = (ds
|
254 |
+
.to_pandas()
|
255 |
+
.set_index('doc'))
|
256 |
+
|
257 |
def extra(self, df, *args):
|
258 |
(frame, ) = args
|
259 |
frame.select(self.df_select_callback,
|
260 |
inputs=[frame],
|
261 |
outputs=[gr.JSON()])
|
262 |
|
263 |
+
def df_select_callback(self, df: pd.DataFrame, evt: gr.SelectData):
|
|
|
264 |
index = df.columns.get_loc('Source')
|
265 |
+
doc = evt.row_value[index]
|
266 |
+
return self.df.loc[(doc, 'info')]
|
|
|
267 |
|
268 |
#
|
269 |
#
|
|
|
272 |
path = str(Path('jerome-white', 'leaderboard-item-response'))
|
273 |
splits = get_dataset_split_names(path)
|
274 |
pmap = {
|
275 |
+
'alpha': ft.partial(ItemLayout, name='discrimination'),
|
276 |
+
'beta': ft.partial(ItemLayout, name='difficulty'),
|
277 |
+
'theta': PersonLayout,
|
278 |
}
|
279 |
|
280 |
for s in splits:
|
281 |
+
df = load_dataset(path, split=s).to_pandas()
|
|
|
|
|
282 |
with gr.Tab(s):
|
283 |
for (i, g) in df.groupby('parameter'):
|
284 |
+
layout = pmap.get(i)(framework=s)
|
285 |
tab = str(layout)
|
286 |
with gr.Tab(tab.title()):
|
287 |
layout(g)
|
288 |
|
289 |
+
demo.launch()
|