def build_detail_site(data, label_func, j2_env): for (name, runs) in data.items(): print("Building '%s'" % name) all_runs = runs.keys() linestyles = convert_linestyle(create_linestyles(all_runs)) label = label_func(name) data = {"normal" : [], "scatter" : []} for plottype in args.plottype: xn, yn = plot_variants[plottype] data["normal"].append(create_plot(runs, xn, yn, linestyles, j2_env)) if args.scatter: data["scatter"].append(create_plot(runs, xn, yn, linestyles, j2_env, "Scatterplot ", "bubble")) # create png plot for summary page data_for_plot = {} for k in runs.keys(): data_for_plot[k] = prepare_data(runs[k], 'k-nn', 'qps') plot.create_plot(data_for_plot, False, False, True, 'k-nn', 'qps', args.outputdir + name + ".png", create_linestyles(all_runs)) with open(args.outputdir + name + ".html", "w") as text_file: text_file.write(j2_env.get_template("detail_page.html"). render(title = label, plot_data = data, args = args))
'--y-log', help='Draw the Y-axis using a logarithmic scale', action='store_true') parser.add_argument( '--raw', help='Show raw results (not just Pareto frontier) in faded colours', action='store_true') args = parser.parse_args() if not args.output: args.output = 'results/%s.png' % args.dataset print('writing output to %s' % args.output) dataset = get_dataset(args.dataset) dimension = len(dataset['train'][0]) # TODO(erikbern): ugly point_type = 'float' # TODO(erikbern): should look at the type of X_train distance = dataset.attrs['distance'] count = int(args.count) definitions = get_definitions(args.definitions, dimension, point_type, distance, count) unique_algorithms = get_unique_algorithms(args.definitions) linestyles = create_linestyles(unique_algorithms) results = load_results(args.dataset, count, definitions) runs = compute_metrics(list(dataset["distances"]), results, args.x_axis, args.y_axis) if not runs: raise Exception('Nothing to plot') create_plot(runs, args.raw, args.x_log, args.y_log, args.x_axis, args.y_axis, args.output, linestyles)
[]).append(ms) all_runs_by_dataset[idx].setdefault(sdn, {}).setdefault(algo, []).append(ms) return (all_runs_by_dataset, all_runs_by_algorithm) j2_env = Environment(loader=FileSystemLoader("./templates/"), trim_blocks=True) j2_env.globals.update(zip=zip, len=len) runs_by_ds, runs_by_algo = load_all_results() dataset_names = [ get_dataset_label(x) for x in list(runs_by_ds['batch'].keys()) + list(runs_by_ds['non-batch'].keys()) ] algorithm_names = list(runs_by_algo['batch'].keys()) + list( runs_by_algo['non-batch'].keys()) linestyles = { **create_linestyles(dataset_names), **create_linestyles(algorithm_names) } build_detail_site(runs_by_ds['non-batch'], lambda label: get_dataset_label(label), j2_env, linestyles, False) build_detail_site(runs_by_ds['batch'], lambda label: get_dataset_label(label), j2_env, linestyles, True) build_detail_site(runs_by_algo['non-batch'], lambda x: x, j2_env, linestyles, False) build_detail_site(runs_by_algo['batch'], lambda x: x, j2_env, linestyles, True) build_index_site(runs_by_ds, runs_by_algo, j2_env, "index.html")
if not algo_ds in all_runs_by_algorithm[algo]: all_runs_by_algorithm[algo][algo_ds] = [] all_runs_by_algorithm[algo][algo_ds].extend(ms) if not sdn in all_runs_by_dataset: all_runs_by_dataset[sdn] = {} dataset_information[sdn] = d if not algo in all_runs_by_dataset[sdn]: all_runs_by_dataset[sdn][algo] = [] all_runs_by_dataset[sdn][algo].extend(ms) del query_cache # Build a website for each dataset for (ds, runs) in all_runs_by_dataset.items(): all_algos = runs.keys() linestyles = convert_linestyle(create_linestyles(all_algos)) output_str = get_html_header(ds) ds_name = dataset_information[ds]["dataset"] + " (k = " + str(dataset_information[ds]["count"]) + ")" output_str += """ <div class="container"> <h2>Plots for %(id)s</h2>""" % { "id" : ds_name } for plottype in args.plottype: xn, yn = plot_variants[plottype] print "Processing '%s' with %s" % (ds, plottype) output_str += create_plot(ds_name, runs, xn, yn, linestyles) if args.scatter: output_str += """ <hr /> <h2>Scatterplots for %(id)s""" % { "id" : ds_name } for plottype in args.plottype: xn, yn = plot_variants[plottype]
action='store_true') parser.add_argument( '--raw', help='Show raw results (not just Pareto frontier) in faded colours', action='store_true') parser.add_argument('--batch', help='Plot runs in batch mode', action='store_true') parser.add_argument('--recompute', help='Clears the cache and recomputes the metrics', action='store_true') args = parser.parse_args() if not args.output: args.output = 'results/%s.png' % get_algorithm_name( args.dataset, args.batch) print('writing output to %s' % args.output) dataset = get_dataset(args.dataset) count = int(args.count) unique_algorithms = get_unique_algorithms() results = load_all_results(args.dataset, count, True, args.batch) linestyles = create_linestyles(sorted(unique_algorithms)) runs = compute_metrics(dataset, results, args.x_axis, args.y_axis, args.recompute) if not runs: raise Exception('Nothing to plot') create_plot(runs, args.raw, args.x_log, args.y_log, args.x_axis, args.y_axis, args.output, linestyles, args.batch)
action='store_true') parser.add_argument( '-Y', '--y-log', help='Draw the Y-axis using a logarithmic scale', action='store_true') parser.add_argument( '--raw', help='Show raw results (not just Pareto frontier) in faded colours', action='store_true') args = parser.parse_args() if not args.output: args.output = 'results/%s.png' % args.dataset print('writing output to %s' % args.output) dataset = get_dataset(args.dataset) dimension = len(dataset['train'][0]) # TODO(erikbern): ugly point_type = 'float' # TODO(erikbern): should look at the type of X_train distance = dataset.attrs['distance'] count = int(args.count) definitions = get_definitions(args.definitions, dimension, point_type, distance, count) unique_algorithms = get_unique_algorithms(args.definitions) linestyles = create_linestyles(unique_algorithms) results = load_results(args.dataset, count, definitions) runs = compute_metrics(list(dataset["distances"]), results, args.x_axis, args.y_axis) if not runs: raise Exception('Nothing to plot') create_plot(runs, args.raw, args.x_log, args.y_log, args.x_axis, args.y_axis, args.output, linestyles)
parser.add_argument('-X', '--x-log', help='Draw the X-axis using a logarithmic scale', action='store_true') parser.add_argument('-Y', '--y-log', help='Draw the Y-axis using a logarithmic scale', action='store_true') parser.add_argument('-G', '--golden', help='Use golden ratio as plotsize', action='store_true') parser.add_argument('--raw', help='Also show raw results in faded colours', action='store_true') args = parser.parse_args() dataset = get_dataset(args.dataset) dimension = len(dataset['train'][0]) # TODO(erikbern): ugly point_type = 'float' # TODO(erikbern): should look at the type of X_train distance = dataset.attrs['distance'] definitions = get_definitions(args.definitions, dimension, point_type, distance, args.count) results = load_results(args.dataset, args.count, definitions) runs, all_algos = compute_metrics(dataset, results) linestyles = create_linestyles(all_algos) create_plot(runs, args.golden, args.raw, args.x_log, args.y_log, args.x_axis, args.y_axis, args.output, linestyles)
help='Draw the X-axis using a logarithmic scale', action='store_true') parser.add_argument( '-Y', '--y-log', help='Draw the Y-axis using a logarithmic scale', action='store_true') parser.add_argument( '-G', '--golden', help='Use golden ratio as plotsize', action='store_true') parser.add_argument( '--raw', help='Also show raw results in faded colours', action='store_true') args = parser.parse_args() query_cache_path = get_query_cache_path( args.dataset, args.count, args.limit, args.distance, args.query_dataset) assert os.path.exists(query_cache_path), """\ error: the query cache file \"%s\" does not exist""" % query_cache_path qs = pickle.load(open(query_cache_path)) runs, all_algos = compute_metrics(qs, get_results( args.dataset, args.limit, args.count, args.distance, args.query_dataset)) linestyles = create_linestyles(all_algos) create_plot(runs, args.golden, args.raw, args.x_log, args.y_log, args.x_axis, args.y_axis, args.output, linestyles)
algo, {}).setdefault(algo_ds, []).append(ms) all_runs_by_dataset[idx].setdefault( sdn, {}).setdefault(algo, []).append(ms) return (all_runs_by_dataset, all_runs_by_algorithm) j2_env = Environment(loader=FileSystemLoader("./templates/"), trim_blocks=True) j2_env.globals.update(zip=zip, len=len) runs_by_ds, runs_by_algo = load_all_results() dataset_names = [get_dataset_label(x) for x in list( runs_by_ds['batch'].keys()) + list(runs_by_ds['non-batch'].keys())] algorithm_names = list(runs_by_algo['batch'].keys( )) + list(runs_by_algo['non-batch'].keys()) linestyles = {**create_linestyles(dataset_names), **create_linestyles(algorithm_names)} build_detail_site( runs_by_ds['non-batch'], lambda label: get_dataset_label(label), j2_env, linestyles, False) build_detail_site( runs_by_ds['batch'], lambda label: get_dataset_label(label), j2_env, linestyles, True) build_detail_site( runs_by_algo['non-batch'], lambda x: x, j2_env, linestyles, False) build_detail_site(
help='Show raw results (not just Pareto frontier) in faded colours', action='store_true') parser.add_argument( '--batch', help='Plot runs in batch mode', action='store_true') parser.add_argument( '--recompute', help='Clears the cache and recomputes the metrics', action='store_true') args = parser.parse_args() if not args.output: args.output = 'results/%s.png' % get_algorithm_name( args.dataset, args.batch) print('writing output to %s' % args.output) dataset = get_dataset(args.dataset) count = int(args.count) unique_algorithms = get_unique_algorithms() results = load_all_results(args.dataset, count, True, args.batch) linestyles = create_linestyles(sorted(unique_algorithms)) runs = compute_metrics(np.array(dataset["distances"]), results, args.x_axis, args.y_axis, args.recompute) if not runs: raise Exception('Nothing to plot') create_plot(runs, args.raw, args.x_log, args.y_log, args.x_axis, args.y_axis, args.output, linestyles, args.batch)