From c7ba0a5dbab4aef1a71b37c0dbbed568543048c3 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 29 Jun 2023 18:52:08 -0700 Subject: [PATCH] aider: Modified show_stats function to plot a bar graph with the average of "pass_rate_1" for each "edit_format" within each model, grouping the bars for each model together. # Context: USER: don't combine the edit formats. plot a different bar for each model/edit_format combo. But group the bars for each model together. ASSISTANT: To implement this change, we need to modify the `show_stats` function in the `benchmark/benchmark.py` file. We will use the pandas and matplotlib libraries to create the bar plot. Here are the steps: 1. In the `show_stats` function, after creating the DataFrame `df`, sort it based on "model" and "edit_format". 2. Group the DataFrame by "model" and "edit_format" and plot a bar graph for "pass_rate_1". Here are the changes: ```python benchmark/benchmark.py <<<<<<< ORIGINAL def show_stats(dirnames): rows = [] for dirname in dirnames: row = summarize_results(dirname) rows.append(vars(row)) df = pd.DataFrame.from_records(rows) df.sort_values(by=["model", "edit_format"], inplace=True) df_grouped = df.groupby("model")["pass_rate_1"].mean() df_grouped.plot(kind='barh', figsize=(10, 6)) plt.xlabel('Pass Rate 1') plt.ylabel('Model') plt.title('Pass Rate 1 for each Model/Edit Format') plt.show() df.to_csv("tmp.benchmark.csv") ======= def show_stats(dirnames): rows = [] for dirname in dirnames: row = summarize_results(dirname) rows.append(vars(row)) df = pd.DataFrame.from_records(rows) df.sort_values(by=["model", "edit_format"], inplace=True) df_grouped = df.groupby(["model", "edit_format"])["pass_rate_1"].mean() df_grouped.unstack().plot(kind='barh', figsize=(10, 6)) plt.xlabel('Pass Rate 1') plt.ylabel('Model') plt.title('Pass Rate 1 for each Model/Edit Format') plt.legend(title='Edit Format') plt.show() df.to_csv("tmp.benchmark.csv") >>>>>>> UPDATED ``` This will create a bar graph with the average of "pass_rate_1" for each "edit_format" within each model. The bars for each model are grouped together. --- benchmark/benchmark.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index f0797f3d4..bffd874e8 100755 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -43,12 +43,13 @@ def show_stats(dirnames): df = pd.DataFrame.from_records(rows) df.sort_values(by=["model", "edit_format"], inplace=True) - df_grouped = df.groupby("model")["pass_rate_1"].mean() - df_grouped.plot(kind='barh', figsize=(10, 6)) + df_grouped = df.groupby(["model", "edit_format"])["pass_rate_1"].mean() + df_grouped.unstack().plot(kind='barh', figsize=(10, 6)) plt.xlabel('Pass Rate 1') plt.ylabel('Model') plt.title('Pass Rate 1 for each Model/Edit Format') + plt.legend(title='Edit Format') plt.show() df.to_csv("tmp.benchmark.csv")