dustalov commited on
Commit
94a0793
1 Parent(s): 0704646

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -131,7 +131,7 @@ def newman(wins: npt.NDArray[np.int64], ties: npt.NDArray[np.int64],
131
 
132
  ALGORITHMS = {
133
  'Bradley-Terry (1952)': bradley_terry,
134
- 'PageRank': pagerank,
135
  'Newman (2023)': newman,
136
  }
137
 
@@ -179,6 +179,7 @@ def handler(file: IO[bytes], algorithm: str, seed: int) -> Tuple[pd.DataFrame, F
179
  scores = ALGORITHMS[algorithm](wins, ties, seed=seed)
180
 
181
  df_result = pd.DataFrame(data={'score': scores}, index=index)
 
182
  df_result['rank'] = df_result['score'].rank(na_option='bottom', ascending=False).astype(int)
183
  df_result.fillna(np.NINF, inplace=True)
184
  df_result.sort_values(by=['rank', 'score'], ascending=[True, False], inplace=True)
@@ -213,7 +214,7 @@ def main() -> None:
213
  ],
214
  outputs=[
215
  gr.Dataframe(
216
- headers=['item', 'score', 'rank'],
217
  label='Ranking'
218
  ),
219
  gr.Plot(
@@ -222,6 +223,7 @@ def main() -> None:
222
  ],
223
  examples=[
224
  ['food.csv', 'Bradley-Terry (1952)', 0],
 
225
  ['food.csv', 'Newman (2023)', 0]
226
  ],
227
  title='Pair2Rank: Turn Your Side-by-Side Comparisons into Ranking!',
 
131
 
132
  ALGORITHMS = {
133
  'Bradley-Terry (1952)': bradley_terry,
134
+ 'PageRank (1998)': pagerank,
135
  'Newman (2023)': newman,
136
  }
137
 
 
179
  scores = ALGORITHMS[algorithm](wins, ties, seed=seed)
180
 
181
  df_result = pd.DataFrame(data={'score': scores}, index=index)
182
+ df_result['pairs'] = df.groupby('left')['left'].count() + df.groupby('right')['right'].count()
183
  df_result['rank'] = df_result['score'].rank(na_option='bottom', ascending=False).astype(int)
184
  df_result.fillna(np.NINF, inplace=True)
185
  df_result.sort_values(by=['rank', 'score'], ascending=[True, False], inplace=True)
 
214
  ],
215
  outputs=[
216
  gr.Dataframe(
217
+ headers=['item', 'score', 'pairs', 'rank'],
218
  label='Ranking'
219
  ),
220
  gr.Plot(
 
223
  ],
224
  examples=[
225
  ['food.csv', 'Bradley-Terry (1952)', 0],
226
+ ['food.csv', 'PageRank (1998)', 0],
227
  ['food.csv', 'Newman (2023)', 0]
228
  ],
229
  title='Pair2Rank: Turn Your Side-by-Side Comparisons into Ranking!',