-
Notifications
You must be signed in to change notification settings - Fork 6
/
plot_ratings.py
54 lines (47 loc) · 1.54 KB
/
plot_ratings.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
import matplotlib.pyplot as plt
import argparse
import os
def main():
parser = argparse.ArgumentParser()
parser.add_argument("path")
args = parser.parse_args()
scores = {}
random_score = None
mcts_scores = {}
with open(args.path) as fp:
# skip header
fp.readline()
for line in fp:
while " " in line:
line = line.replace(" ", " ", 1)
parts = line.strip().split(" ")
elo = int(parts[2])
if parts[1] == "Random":
random_score = elo
elif "VanillaMCTS" in parts[1]:
mcts_scores[parts[1]] = elo
else:
num = int(parts[1].split("_")[1].split(".")[0])
scores[num] = elo
if len(scores) > 0:
names = sorted(scores)
elos = [scores[name] - scores[0] for name in names]
plt.plot(names, elos, label="Learner")
plt.scatter(names, elos)
for name, elo in mcts_scores.items():
if elo - scores[0] < 0:
continue
plt.plot(
[names[0], names[-1]],
[elo - scores[0], elo - scores[0]],
linestyle="dashed",
label=name,
)
plt.text(names[-1], elo - scores[0], name.replace("VanillaMCTS", ""))
plt.title("Strength through training")
plt.xlabel("Iteration")
plt.ylim(bottom=-20)
plt.ylabel("BayesianELO")
plt.savefig(f"{os.path.dirname(args.path)}/ratings.png")
if __name__ == "__main__":
main()