Skip to content

Commit

Permalink
csv output
Browse files Browse the repository at this point in the history
  • Loading branch information
jakep-allenai committed Jan 23, 2025
1 parent 201fec3 commit eacd044
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pdelfin/eval/scoreelo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import requests
import re
from urllib.parse import urlsplit, urlunsplit, parse_qs, urlencode
import json
import csv
from collections import defaultdict

def fetch_review_page_html(url):
Expand Down Expand Up @@ -267,6 +267,17 @@ def make_report(urls):
f"{B} wins={B_wins} ({B_rate:.1f}%)"
)

# -- ADDED: Write the same data to scoreelo.csv
with open("scoreelo.csv", "w", newline="", encoding="utf-8") as csvfile:
writer = csv.writer(csvfile)
writer.writerow(["MethodA", "MethodB", "A_wins", "B_wins", "A_rate(%)", "B_rate(%)"])
for (A, B), (A_wins, B_wins) in comparisons.items():
total = A_wins + B_wins
A_rate = A_wins / total * 100 if total else 0
B_rate = B_wins / total * 100 if total else 0
writer.writerow([A, B, A_wins, B_wins, f"{A_rate:.1f}", f"{B_rate:.1f}"])


# ==== ELO Arena ====
elo_ratings = compute_elo_arena(comparisons, k=32, initial_rating=1500)

Expand Down

0 comments on commit eacd044

Please sign in to comment.