Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
mrfakename
commited on
Update app/leaderboard.py
Browse files- app/leaderboard.py +9 -9
app/leaderboard.py
CHANGED
@@ -42,15 +42,15 @@ def get_leaderboard(reveal_prelim = False, hide_battle_votes = False):
|
|
42 |
for j in range(len(df)):
|
43 |
if i != j:
|
44 |
try:
|
45 |
-
expected_a = 1 / (1 + 10 ** ((df['score'][j] - df['score'][i]) / 400))
|
46 |
-
expected_b = 1 / (1 + 10 ** ((df['score'][i] - df['score'][j]) / 400))
|
47 |
-
actual_a = df['upvote'][i] / df['votes'][i] if df['votes'][i] > 0 else 0.5
|
48 |
-
actual_b = df['upvote'][j] / df['votes'][j] if df['votes'][j] > 0 else 0.5
|
49 |
-
df.
|
50 |
-
df.
|
51 |
-
except:
|
52 |
-
print(f
|
53 |
-
|
54 |
df['score'] = round(df['score'])
|
55 |
## ELO SCORE
|
56 |
df = df.sort_values(by='score', ascending=False)
|
|
|
42 |
for j in range(len(df)):
|
43 |
if i != j:
|
44 |
try:
|
45 |
+
expected_a = 1 / (1 + 10 ** ((df['score'].iloc[j] - df['score'].iloc[i]) / 400))
|
46 |
+
expected_b = 1 / (1 + 10 ** ((df['score'].iloc[i] - df['score'].iloc[j]) / 400))
|
47 |
+
actual_a = df['upvote'].iloc[i] / df['votes'].iloc[i] if df['votes'].iloc[i] > 0 else 0.5
|
48 |
+
actual_b = df['upvote'].iloc[j] / df['votes'].iloc[j] if df['votes'].iloc[j] > 0 else 0.5
|
49 |
+
df.iloc[i, df.columns.get_loc('score')] += 32 * (actual_a - expected_a)
|
50 |
+
df.iloc[j, df.columns.get_loc('score')] += 32 * (actual_b - expected_b)
|
51 |
+
except Exception as e:
|
52 |
+
print(f"Error in ELO calculation for rows {i} and {j}: {str(e)}")
|
53 |
+
continue
|
54 |
df['score'] = round(df['score'])
|
55 |
## ELO SCORE
|
56 |
df = df.sort_values(by='score', ascending=False)
|