-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrust_python.py
executable file
·57 lines (44 loc) · 1.42 KB
/
rust_python.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
from functools import partial
from timeit import repeat
import evalica
import pandas as pd
from tqdm.auto import tqdm
ALGORITHMS = [
evalica.counting,
evalica.average_win_rate,
evalica.bradley_terry,
evalica.elo,
evalica.eigen,
evalica.pagerank,
evalica.newman,
]
REPETITIONS = 10
def main() -> None:
df_llmfao = pd.read_csv("llmfao.csv", dtype=str)
df_llmfao = df_llmfao[["left", "right", "winner"]]
df_llmfao["winner"] = df_llmfao["winner"].map({
"left": evalica.Winner.X,
"right": evalica.Winner.Y,
"tie": evalica.Winner.Draw,
})
_, _, index = evalica.indexing(df_llmfao["left"], df_llmfao["right"])
results = []
for algorithm in tqdm(ALGORITHMS):
for solver in ("pyo3", "naive"):
stmt = partial(
algorithm,
xs=df_llmfao["left"],
ys=df_llmfao["right"],
winners=df_llmfao["winner"],
index=index,
solver=solver,
)
time = repeat(stmt, repeat=REPETITIONS, number=1)
results.append((algorithm.__name__, solver, time))
df_results = pd.DataFrame(results, columns=["algorithm", "solver", "time"])
df_results = df_results.explode("time")
df_results = df_results.reset_index(drop=True)
df_results.to_csv("rust_python.csv", index=False)
if __name__ == "__main__":
main()