if prim == 'PageRank': # normalize per iteration is_PR = True df['m_teps_normalized'] = df['m_teps'] / df['search_depth'] chart = Chart(df).mark_bar().encode( x=X('dataset:N', axis=Axis(title='Dataset', )), y=Y( 'm_teps' if not is_PR else 'm_teps_normalized', axis=Axis(title='MTEPS' if not is_PR else 'MTEPS (normalized)', ), ), ) print chart.to_dict(data=False) plotname = '%s_perf' for fileformat in ['html', 'svg', 'png']: savefile(chart, name=plotname % prim, fileformat=fileformat) data_unfiltered = [json.load(open(jf)) for jf in all_json_files_1011nov16] df = pandas.DataFrame(data_unfiltered) # All prim-specific data is now stored in the pandas DataFrame "df". df.loc[df.algorithm == 'DOBFS', 'algorithm'] = 'BFS' chart = Chart(df).mark_point().encode( x=X( 'dataset:N', axis=Axis(title='Dataset', ), ), column=Column('algorithm:N', axis=Axis( title='Primitive', orient='top', )),
orient='bottom', )), y=Y( 'm_teps', axis=Axis(title='MTEPS', ), # scale=Scale(type='log'), ), color=Color( 'traversal_mode:N', legend=Legend(title='%s / Traversal Mode' % prim), ), ) print chart.to_dict(data=False) plotname = '%s_trav_chart' for fileformat in ['html', 'svg', 'png']: savefile(chart, name=plotname % prim, fileformat=fileformat) # Average node degree chart files = [(json_files_oct16, 'Real-World')] if (prim == 'BFS'): files.append((json_files_7nov16, 'RGG+RMAT')) for file in files: data_unfiltered = [json.load(open(jf)) for jf in file[0]] df = pandas.DataFrame(data_unfiltered) # "graph_type": "grmat", # "graph_type": "rgg", df['avg_node_degree'] = df['edges_visited'] / df['nodes_visited'] chart = Chart(df).mark_point().encode( x=X(
chart = Chart(df).mark_bar().encode( x=X('dataset:N', axis=Axis( title='Dataset', ) ), y=Y('m_teps' if not is_PR else 'm_teps_normalized', axis=Axis( title='MTEPS' if not is_PR else 'MTEPS (normalized)', ), ), ) print chart.to_dict(data=False) plotname = '%s_perf' for fileformat in ['html', 'svg', 'png']: savefile(chart, name=plotname % prim, fileformat=fileformat) data_unfiltered = [json.load(open(jf)) for jf in all_json_files_1011nov16] df = pandas.DataFrame(data_unfiltered) # All prim-specific data is now stored in the pandas DataFrame "df". df.loc[df.algorithm == 'DOBFS', 'algorithm'] = 'BFS' chart = Chart(df).mark_point().encode( x=X('dataset:N', axis=Axis( title='Dataset', ), ), column=Column('algorithm:N', axis=Axis( title='Primitive',
) ), y=Y('m_teps', axis=Axis( title='MTEPS', ), # scale=Scale(type='log'), ), color=Color('traversal_mode:N', legend=Legend(title='%s / Traversal Mode' % prim), ), ) print chart.to_dict(data=False) plotname = '%s_trav_chart' for fileformat in ['html', 'svg', 'png']: savefile(chart, name=plotname % prim, fileformat=fileformat) # Average node degree chart files = [(json_files_oct16, 'Real-World')] if (prim == 'BFS'): files.append((json_files_7nov16, 'RGG+RMAT')) for file in files: data_unfiltered = [json.load(open(jf)) for jf in file[0]] df = pandas.DataFrame(data_unfiltered) # "graph_type": "grmat", # "graph_type": "rgg", df['avg_node_degree'] = df['edges_visited'] / df['nodes_visited'] chart = Chart(df).mark_point().encode( x=X('avg_node_degree',
# Read in the file files = glob.glob('output/do_ab_random_?????*.svg') for f in files: stub = os.path.splitext(os.path.split(f)[1])[0] print stub with open(f, 'rb') as file: filedata = file.read() # Replace the target string p = re.compile(r'^<svg class="marks" width="(\d+)" height="(\d+)"') m = p.match(filedata) w = m.group(1) h = m.group(2) # w: subtract 125 # h: add 48 whin = 'width="%s" height="%s"' % (w, h) neww = int(w) - 125 newh = int(h) + 48 print 'w:', w, neww, 'h:', h, newh whout = 'width="%s" height="%s"' % (neww, newh) filedata = filedata.replace(whin, whout) # 'width="590" height="462"', 'width="465" height="510"') filedata = filedata.replace('translate(404.5,0.5)', 'translate(260,390)') # Write the file out again with open(f, 'wb') as file: file.write(filedata) savefile('', stub, 'pdf', 'output', patchFunctions=[])
from subprocess import Popen, PIPE, STDOUT, check_output, CalledProcessError from fileops import savefile # load data as a pandas DataFrame cars = load_dataset('cars') chart = Chart(cars).mark_point().encode( x='Horsepower', y='Miles_per_Gallon', color='Origin', ) print chart.to_dict(data=False) savefile(chart, name='example', fileformat='html') jsondir = '../gunrock-output/' bfs_json_files = [f for f in os.listdir(jsondir) if (os.path.isfile(jsondir + f) and (os.path.splitext(f)[1] == ".json") and (os.path.basename(f).startswith("BFS") or os.path.basename(f).startswith("DOBFS")) and not os.path.basename(f).startswith("_"))] bfs_data_unfiltered = [json.load(open(jsondir + jf)) for jf in bfs_json_files] bfs_df = pandas.DataFrame(bfs_data_unfiltered) # All DOBFS/BFS data is now stored in the pandas DataFrame "bfs_df". # Unfortunately, some of the runs in the repo have no dataset. Filter them out. bfs_df = bfs_df[bfs_df['dataset'] != ""]
# Unfortunately, some of the runs in the repo have no dataset. Filter them out. bfs_df = bfs_df[bfs_df['dataset'] != ""] # Let's add a new column (attribute), conditional on existing columns. # We'll need this to pivot later. def setParameters(row): return (row['algorithm'] + ', ' + ('un' if row['undirected'] else '') + 'directed, ' + ('' if row['mark_predecessors'] else 'no ') + 'mark predecessors') bfs_df['parameters'] = bfs_df.apply(setParameters, axis=1) bfs_chart = Chart(bfs_df).mark_bar().encode( x=X('dataset', axis=Axis(title='Dataset')), y=Y( 'm_teps', axis=Axis(title='MTEPS'), scale=Scale(type='log'), ), ) print bfs_chart.to_dict(data=False) # print bfs_chart.to_dict(data=False, cleanup_data=True) # print bfs_chart.to_dict(data=True) savefile(bfs_chart, name='bfs_chart', fileformat='html') savefile(bfs_chart, name='bfs_chart', fileformat='json') savefile(bfs_chart, name='bfs_chart', fileformat='md') savefile_df(bfs_df, name='bfs_chart', fileformat='html')
# Unfortunately, some of the runs in the repo have no dataset. Filter them out. bfs_df = bfs_df[bfs_df['dataset'] != ""] # Let's add a new column (attribute), conditional on existing columns. # We'll need this to pivot later. def setParameters(row): return (row['algorithm'] + ', ' + ('un' if row['undirected'] else '') + 'directed, ' + ('' if row['mark_predecessors'] else 'no ') + 'mark predecessors') bfs_df['parameters'] = bfs_df.apply(setParameters, axis=1) bfs_chart = Chart(bfs_df).mark_bar().encode( x=X('dataset', axis=Axis(title='Dataset') ), y=Y('m_teps', axis=Axis(title='MTEPS'), scale=Scale(type='log'), ), ) print bfs_chart.to_dict(data=False) # print bfs_chart.to_dict(data=False, cleanup_data=True) # print bfs_chart.to_dict(data=True) savefile(bfs_chart, name='bfs_chart', fileformat='html') savefile(bfs_chart, name='bfs_chart', fileformat='json') savefile(bfs_chart, name='bfs_chart', fileformat='md')