MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / write_website_results

Function write_website_results

codeclash/analysis/metrics/elo.py:1378–1426  ·  view source on GitHub ↗

Write results in JSON format for website consumption. Creates a leaderboard JSON with rankings per arena and overall. Format: { "ArenaName": [ {"rank": 1, "model": "model_name", "elo": 1500, "elo_std": 50}, ... ], "Overall": [...] }

(results: dict[str, dict], output_dir: Path)

Source from the content-addressed store, hash-verified

1376 row_parts.append("--")
1377
1378 row_parts.append(rf"\eloMainResult{{{int(all_elo)}}}")
1379 lines.append(" & ".join(row_parts) + r" \\")
1380
1381 lines.append(r"\bottomrule")
1382 lines.append(r"\end{tabular}")
1383 lines.append(r"\end{table}")
1384
1385 output_file.write_text("\n".join(lines) + "\n")
1386 logger.info(f"Saved LaTeX table: {output_file}")
1387
1388
1389def write_website_results(results: dict[str, dict], output_dir: Path) -> None:
1390 """Write results in JSON format for website consumption.
1391
1392 Creates a leaderboard JSON with rankings per arena and overall.
1393 Format:
1394 {
1395 "ArenaName": [
1396 {"rank": 1, "model": "model_name", "elo": 1500, "elo_std": 50},
1397 ...
1398 ],
1399 "Overall": [...]
1400 }
1401 """
1402 output_dir.mkdir(parents=True, exist_ok=True)
1403 output_file = output_dir / "leaderboards.json"
1404
1405 leaderboard = {}
1406
1407 for game_name, game_result in results.items():
1408 players = game_result["players"]
1409 strengths = game_result["strengths"]
1410 elo_std = game_result.get("elo_std")
1411
1412 # Convert Bradley-Terry strengths to Elo ratings
1413 elos = {p: BradleyTerryFitter.bt_to_elo(s) for p, s in zip(players, strengths)}
1414
1415 # Sort by Elo (descending)
1416 sorted_players = sorted(elos.items(), key=lambda x: x[1], reverse=True)
1417
1418 # Create leaderboard entries
1419 board = []
1420 for rank, (player, elo) in enumerate(sorted_players):
1421 entry = {"rank": rank + 1, "model": MODEL_TO_DISPLAY_NAME.get(player, player), "elo": int(round(elo))}
1422 # Add confidence interval if available
1423 if elo_std is not None:
1424 player_idx = players.index(player)
1425 entry["elo_std"] = int(round(elo_std[player_idx]))
1426 board.append(entry)
1427
1428 leaderboard[game_name.lower()] = {
1429 "board": board,

Callers 1

elo.pyFile · 0.85

Calls 2

getMethod · 0.80
bt_to_eloMethod · 0.45

Tested by

no test coverage detected