Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
# Copyright 2023 Dmitry Ustalov
|
2 |
#
|
3 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -86,7 +88,7 @@ def counting(wins: npt.NDArray[np.int64], ties: npt.NDArray[np.int64],
|
|
86 |
seed: int = 0, tolerance: float = 10e-6, limit: int = 100) -> npt.NDArray[np.float64]:
|
87 |
M = wins + .5 * ties
|
88 |
|
89 |
-
return M.sum(axis=
|
90 |
|
91 |
|
92 |
def eigen(wins: npt.NDArray[np.int64], ties: npt.NDArray[np.int64],
|
@@ -190,6 +192,9 @@ def handler(file: IO[bytes], algorithm: str, filtered: bool, truncated: bool, se
|
|
190 |
|
191 |
df.dropna(axis='rows', inplace=True)
|
192 |
|
|
|
|
|
|
|
193 |
if filtered:
|
194 |
largest = largest_strongly_connected_component(df)
|
195 |
|
@@ -199,7 +204,7 @@ def handler(file: IO[bytes], algorithm: str, filtered: bool, truncated: bool, se
|
|
199 |
else:
|
200 |
index = pd.Index(np.unique(df[['left', 'right']].values), name='item')
|
201 |
|
202 |
-
df_wins = pd.pivot_table(df[df['winner']
|
203 |
index='left', columns='right', values='winner',
|
204 |
aggfunc='count', fill_value=0)
|
205 |
df_wins = df_wins.reindex(labels=index, columns=index, fill_value=0, copy=False)
|
@@ -286,11 +291,11 @@ def main() -> None:
|
|
286 |
)
|
287 |
],
|
288 |
examples=[
|
289 |
-
['food.csv', 'Counting', False],
|
290 |
-
['food.csv', 'Bradley-Terry (1952)', False],
|
291 |
-
['food.csv', 'Eigenvector (1986)', False],
|
292 |
-
['food.csv', 'PageRank (1998)', False],
|
293 |
-
['food.csv', 'Newman (2023)', False]
|
294 |
],
|
295 |
title='Pair2Rank: Turn Your Side-by-Side Comparisons into Ranking!',
|
296 |
description='''
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
|
3 |
# Copyright 2023 Dmitry Ustalov
|
4 |
#
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
88 |
seed: int = 0, tolerance: float = 10e-6, limit: int = 100) -> npt.NDArray[np.float64]:
|
89 |
M = wins + .5 * ties
|
90 |
|
91 |
+
return cast(npt.NDArray[np.float64], M.sum(axis=1))
|
92 |
|
93 |
|
94 |
def eigen(wins: npt.NDArray[np.int64], ties: npt.NDArray[np.int64],
|
|
|
192 |
|
193 |
df.dropna(axis='rows', inplace=True)
|
194 |
|
195 |
+
df.loc[df['winner'] == 'right', ['left', 'right']] = df.loc[df['winner'] == 'right', ['right', 'left']].values
|
196 |
+
df.loc[df['winner'] == 'right', 'winner'] = 'left'
|
197 |
+
|
198 |
if filtered:
|
199 |
largest = largest_strongly_connected_component(df)
|
200 |
|
|
|
204 |
else:
|
205 |
index = pd.Index(np.unique(df[['left', 'right']].values), name='item')
|
206 |
|
207 |
+
df_wins = pd.pivot_table(df[df['winner'] != 'tie'],
|
208 |
index='left', columns='right', values='winner',
|
209 |
aggfunc='count', fill_value=0)
|
210 |
df_wins = df_wins.reindex(labels=index, columns=index, fill_value=0, copy=False)
|
|
|
291 |
)
|
292 |
],
|
293 |
examples=[
|
294 |
+
['food.csv', 'Counting', False, False],
|
295 |
+
['food.csv', 'Bradley-Terry (1952)', False, False],
|
296 |
+
['food.csv', 'Eigenvector (1986)', False, False],
|
297 |
+
['food.csv', 'PageRank (1998)', False, False],
|
298 |
+
['food.csv', 'Newman (2023)', False, False]
|
299 |
],
|
300 |
title='Pair2Rank: Turn Your Side-by-Side Comparisons into Ranking!',
|
301 |
description='''
|