-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_stale.py
More file actions
39 lines (30 loc) · 965 Bytes
/
Copy pathplot_stale.py
File metadata and controls
39 lines (30 loc) · 965 Bytes
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
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import argparse
from style import latexify, grid
p = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
p.add_argument("--input", required=True)
p.add_argument("--output")
args = p.parse_args()
data = pd.read_csv(args.input)
data = data[
(data["algorithm"] == "sp") &
(data["load"] == data["load"].max())
]
data["accepted"] = data["status"] == "accepted"
data = data.groupby(by=["path_len", "seed"]).agg(prop=("accepted", "mean"), count=("accepted", "count")).reset_index()
# Take only path lengths with enough samples
data = data[data["count"] > 10]
if args.output:
latexify(columns=1, fig_height=1)
ax = sns.lineplot(data, x="path_len", y="prop")
ax.set_xlabel("Path length (hops)")
ax.set_ylabel("Proportion of\naccepted paths")
grid(ax, "both")
if args.output:
plt.savefig(args.output, bbox_inches="tight")
else:
plt.show()