Skip to content
Snippets Groups Projects
Commit eafcddb1 authored by vjp17's avatar vjp17
Browse files

First commit

parent 22e50db0
No related branches found
No related tags found
No related merge requests found
import matplotlib.pyplot as plt
import sys
import os
import pickle
def plot_run(n, epsilon, delta, run_id=1):
run_directory = f"{os.getcwd()}/runs/{n}/{epsilon}_{delta}"
errors_directory = f"{os.getcwd()}/figures/{n}/{epsilon}_{delta}/errors"
upds_directory = f"{os.getcwd()}/figures/{n}/{epsilon}_{delta}/updates"
if not os.path.exists(errors_directory):
os.makedirs(errors_directory)
if not os.path.exists(upds_directory):
os.makedirs(upds_directory)
with open(f"{run_directory}/errors_{run_id}.txt", "rb") as f:
errors = pickle.load(f)
err_labels = []
for key in errors:
if errors[key] >= epsilon:
err_labels.append(key)
with open(f"{run_directory}/updates_{run_id}.txt", "rb") as f:
upds = pickle.load(f)
upd_labels = []
for key in upds:
if upds[key] == -1:
upd_labels.append(key)
error_fig = plt.figure(layout="tight")
x, y = zip(*errors.items())
plt.plot(x, [epsilon for i in x], label="Epsilon", color="r")
plt.scatter(x, y, marker="+")
plt.xlabel("function")
plt.ylabel("error rate")
plt.xticks(err_labels, rotation=45, ha="right")
plt.legend()
plt.savefig(f"{errors_directory}/run_{run_id}.png")
upd_fig = plt.figure(layout="tight")
x, y = zip(*upds.items())
plt.scatter(x, y, marker="+")
plt.xlabel("function")
plt.ylabel("N")
plt.yticks([-1, 0, 1, max(y)])
plt.xticks(upd_labels, rotation=45, ha="right")
plt.savefig(f"{upds_directory}/run_{run_id}.png")
if __name__ == '__main__':
n = int(sys.argv[1])
epsilon = float(sys.argv[2])
delta = float(sys.argv[3])
run_id = int(sys.argv[4])
plot_run(n, epsilon, delta, run_id)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment