Spaces:
Running
Running
Update app.py
Browse filesImproved the Score Chart
app.py
CHANGED
@@ -213,14 +213,26 @@ def get_leaderboard():
|
|
213 |
|
214 |
def get_leaderboard_chart():
|
215 |
battle_results = get_current_leaderboard()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
sorted_results = sorted(
|
217 |
battle_results.items(),
|
218 |
-
key=lambda x: (x[1]["
|
219 |
reverse=True
|
220 |
)
|
|
|
221 |
models = [get_human_readable_name(model) for model, _ in sorted_results]
|
222 |
wins = [results["wins"] for _, results in sorted_results]
|
223 |
losses = [results["losses"] for _, results in sorted_results]
|
|
|
224 |
|
225 |
fig = go.Figure()
|
226 |
|
@@ -238,11 +250,25 @@ def get_leaderboard_chart():
|
|
238 |
marker_color='#38a3a5'
|
239 |
))
|
240 |
|
241 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
fig.update_layout(
|
243 |
title='Model Performance',
|
244 |
xaxis_title='Models',
|
245 |
yaxis_title='Number of Battles',
|
|
|
|
|
|
|
|
|
|
|
246 |
barmode='stack',
|
247 |
height=800,
|
248 |
width=1450,
|
|
|
213 |
|
214 |
def get_leaderboard_chart():
|
215 |
battle_results = get_current_leaderboard()
|
216 |
+
|
217 |
+
# Calculate scores and sort results
|
218 |
+
for model, results in battle_results.items():
|
219 |
+
total_battles = results["wins"] + results["losses"]
|
220 |
+
if total_battles > 0:
|
221 |
+
win_rate = results["wins"] / total_battles
|
222 |
+
results["score"] = win_rate * (1 - 1 / (total_battles + 1))
|
223 |
+
else:
|
224 |
+
results["score"] = 0
|
225 |
+
|
226 |
sorted_results = sorted(
|
227 |
battle_results.items(),
|
228 |
+
key=lambda x: (x[1]["score"], x[1]["wins"] + x[1]["losses"]),
|
229 |
reverse=True
|
230 |
)
|
231 |
+
|
232 |
models = [get_human_readable_name(model) for model, _ in sorted_results]
|
233 |
wins = [results["wins"] for _, results in sorted_results]
|
234 |
losses = [results["losses"] for _, results in sorted_results]
|
235 |
+
scores = [results["score"] for _, results in sorted_results]
|
236 |
|
237 |
fig = go.Figure()
|
238 |
|
|
|
250 |
marker_color='#38a3a5'
|
251 |
))
|
252 |
|
253 |
+
# Line chart for Scores
|
254 |
+
fig.add_trace(go.Scatter(
|
255 |
+
x=models,
|
256 |
+
y=scores,
|
257 |
+
name='Score',
|
258 |
+
yaxis='y2',
|
259 |
+
line=dict(color='#ff7f0e', width=2)
|
260 |
+
))
|
261 |
+
|
262 |
+
# Update layout for full-width, increased height, and secondary y-axis
|
263 |
fig.update_layout(
|
264 |
title='Model Performance',
|
265 |
xaxis_title='Models',
|
266 |
yaxis_title='Number of Battles',
|
267 |
+
yaxis2=dict(
|
268 |
+
title='Score',
|
269 |
+
overlaying='y',
|
270 |
+
side='right'
|
271 |
+
),
|
272 |
barmode='stack',
|
273 |
height=800,
|
274 |
width=1450,
|