plot.py should calculate the precision of each algorithm run immediately
This means we can process the results file incrementally without having to
load all of it into memory at once, which is nice when the file is more
than a gigabyte in size
@@ -62,29 +62,16 @@ all_algos = set()
for ds, _ in args.dataset:
results_fn = get_fn("results", ds)
queries_fn = get_fn("queries", ds)
- if not os.path.exists(queries_fn):
- assert False, "the queries file '%s' is missing" % queries_fn
- else:
+ assert os.path.exists(queries_fn), """\
+the queries file '%s' is missing""" % queries_fn
+
queries[ds] = pickle.load(open(queries_fn))
- runs[ds] = []
- for line in open(get_fn("results", ds)):
+ runs[ds] = {}
+ with open(get_fn("results", ds)) as f:
+ for line in f:
run = json.loads(line)
- runs[ds].append(run)
all_algos.add(run["library"])
-# print queries
-# print runs
-
-colors = plt.cm.Set1(numpy.linspace(0, 1, len(all_algos)))
-linestyles = {}
-for i, algo in enumerate(all_algos):
- linestyles[algo] = (colors[i], ['--', '-.', '-', ':'][i%4], ['+', '<', 'o', 'D', '*', 'x', 's'][i%7])
-
-# Now generate each plot
-for ds, fn_out in args.dataset:
- all_data = {}
-
- for run in runs[ds]:
algo = run["library"]
algo_name = run["name"]
build_time = run["build_time"]
@@ -133,8 +120,23 @@ for ds, fn_out in args.dataset:
else:
assert False, "precision metric '%s' is not supported" % args.precision
print precision
+ if not algo in runs[ds]:
+ runs[ds][algo] = []
+
+ runs[ds][algo].append(
+ (algo, algo_name, build_time, search_time, precision))
+
+# print queries
+# print runs
+
+colors = plt.cm.Set1(numpy.linspace(0, 1, len(all_algos)))
+linestyles = {}
+for i, algo in enumerate(all_algos):
+ linestyles[algo] = (colors[i], ['--', '-.', '-', ':'][i%4], ['+', '<', 'o', 'D', '*', 'x', 's'][i%7])
- all_data.setdefault(algo, []).append((algo_name, float(build_time), float(search_time), float(precision)))
+# Now generate each plot
+for ds, fn_out in args.dataset:
+ all_data = runs[ds]
handles = []
labels = []
