Skip to content

Commit

Permalink
Update graphs.ipynb
Browse files Browse the repository at this point in the history
Implements the generation of the .tex table identical as in the SIGMOD paper for better reproducibility
  • Loading branch information
marcocosta97 committed Aug 26, 2024
1 parent ad88ecd commit 594701f
Showing 1 changed file with 46 additions and 18 deletions.
64 changes: 46 additions & 18 deletions bench/scripts/graphs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,10 @@
" df_list = []\n",
" for i in range(nrows): \n",
" df = pd.DataFrame()\n",
" df['Competitor'] = mean_row[i].keys()\n",
" df['idx'] = df['Competitor'].copy()\n",
" df = df.set_index('idx')\n",
" for key, value in mean_row[i].items():\n",
" col_name = 'Avg Query time (wrt ' + filters[0] + ')'\n",
" col_name = 'Avg ns/query'\n",
" df.at[key, 'avg'] = value[0]\n",
" df.at[key, col_name] = str(value[0]) + ' (' + str(value[1]) + 'x)'\n",
" df.at[key, col_name] = str(value[0]) + ' (' + str(value[1]) + '$\\\\times$)'\n",
"\n",
" # sort by 'temp' column ignoring the row of index 'Grafite'\n",
" df.iat[0, df.columns.get_loc('avg')] = -1\n",
Expand All @@ -278,7 +275,28 @@
" df = df.drop('avg', axis=1)\n",
" df_list.append(df)\n",
" \n",
" return df_list"
" return df_list\n",
"\n",
"def print_table(df_list : list[pd.DataFrame], filename, space_em_list):\n",
" filled_sections = []\n",
" \n",
" for i, df in enumerate(df_list):\n",
" if i == 0:\n",
" table_string = df.to_latex(index=True, header=True, escape=False, column_format=\"rl\")\n",
" table_string = table_string.replace(\"{}\", \"Range filter\")\n",
" filled_sections.extend(table_string.split(\"\\n\")[:-2])\n",
" else:\n",
" table_string = df.to_latex(index=True, header=False, escape=False)\n",
" filled_sections.extend(table_string.split(\"\\n\")[1:-2])\n",
" \n",
" filled_sections.append(\"\\\\vspace{\" + space_em_list[i] + \"}\\\\\\\\\")\n",
" \n",
" filled_sections.append(\"\\\\end{tabular}\")\n",
" # Join all filled sections\n",
" filled_template = \"\\n\".join(filled_sections)\n",
" \n",
" with open(filename, \"w\") as file:\n",
" file.write(filled_template) "
]
},
{
Expand All @@ -288,8 +306,15 @@
"outputs": [],
"source": [
"workloads = [('kuniform', 'qcorrelated'), ('kuniform', 'quniform'), ('books'), ('osm')]\n",
"filters_heuristics = ['Bucketing', 'SuRF', 'Proteus', 'SNARF', 'REncoder_SS', 'REncoder_SE']\n",
"\n",
"filters_heuristics = ['Bucketing', 'SuRF', 'Proteus', 'SNARF', 'REncoder_SS', 'REncoder_SE']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print_fpr_test(filters_heuristics, workloads, 'heuristics')"
]
},
Expand All @@ -300,10 +325,17 @@
"outputs": [],
"source": [
"df_list = generate_tables(filters_heuristics, workloads)\n",
"with open(f'{out_folder}/table_heuristics.tex', 'w') as f:\n",
" for df in df_list:\n",
" f.write(df.to_latex(index=False))\n",
" f.write(\"\\n\\n\")"
"spaces_list = ['.7em', '.7em', '.7em', '1.4em']\n",
"print_table(df_list, f'{out_folder}/table_heuristics.tex', spaces_list)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"filters_bounded = ['Grafite', 'Rosetta', 'REncoder']"
]
},
{
Expand All @@ -312,8 +344,6 @@
"metadata": {},
"outputs": [],
"source": [
"filters_bounded = ['Grafite', 'Rosetta', 'REncoder']\n",
"\n",
"print_fpr_test(filters_bounded, workloads, 'bounded')"
]
},
Expand All @@ -324,10 +354,8 @@
"outputs": [],
"source": [
"df_list = generate_tables(filters_bounded, workloads)\n",
"with open(f'{out_folder}/table_bounded.tex', 'w') as f:\n",
" for df in df_list:\n",
" f.write(df.to_latex(index=False))\n",
" f.write(\"\\n\\n\")"
"spaces_list = ['4em', '4.4em', '4.4em', '3em']\n",
"print_table(df_list, f'{out_folder}/table_bounded.tex', spaces_list)"
]
},
{
Expand Down

0 comments on commit 594701f

Please sign in to comment.