in evals/elsuite/function_deduction/scripts/make_plots.py [0:0]
def make_ask_guess_incorrect_plot(df, out_path: Path):
# Ask/Guess/Incorrect
ask_guess_incorrect_data = {
"solver": df["solver"],
"Ask": df["avg_ask_rounds"],
"SEM Average Ask Rounds": df["sem_avg_ask_rounds"],
"Guess": df["avg_guess_rounds"],
"SEM Average Guess Rounds": df["sem_avg_guess_rounds"],
"Incorrect Format": df["avg_incorrect_format_rounds"],
"SEM Average Incorrect Format Rounds": df["sem_avg_incorrect_format_rounds"],
}
agi_palette = {
"Ask": "blue",
"Guess": "pink",
"Incorrect Format": "red",
}
ask_guess_incorrect_df = pd.DataFrame(ask_guess_incorrect_data)
# Melting the DataFrame to make it suitable for seaborn's factorplot
melted_df = pd.melt(
ask_guess_incorrect_df,
id_vars="solver",
value_vars=["Ask", "Guess", "Incorrect Format"],
var_name="Round Type",
value_name="Average Rounds",
)
# Generating the plot for Average Ask/Guess/Incorrect Format Rounds
plt.figure(figsize=(14, 14))
ax = sns.barplot(
x="Average Rounds", y="solver", hue="Round Type", data=melted_df, palette=agi_palette
)
plt.xlabel("Average Number of Rounds")
plt.ylabel("Solver")
plt.title("Distribution of Type of Responses by Model")
plt.grid(axis="x")
plt.legend(title="Response Type")
plt.tight_layout()
# Expanding the x-axis limit
x_lim = ax.get_xlim()
ax.set_xlim([x_lim[0], x_lim[1] * 1.05]) # Increase the upper limit by 5%
# Annotating each bar with its value
for p in ax.patches:
width = p.get_width()
ax.text(
width + 0.1, # x position of text
p.get_y() + p.get_height() / 2, # y position of text
"{:.1f}".format(width), # text to be shown
va="center",
) # vertical alignment
plt.savefig(out_path)
return