Skip to content

Commit

Permalink
Track the code for the RMSE figure
Browse files Browse the repository at this point in the history
  • Loading branch information
AMR-KELEG committed Nov 28, 2023
1 parent 25ec22f commit 07b7817
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions assets/rmse_figure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import re
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.cm as cmx

font = {"size": 7}
matplotlib.rc("font", **font)
matplotlib.rcParams["axes.spines.left"] = True
matplotlib.rcParams["axes.spines.right"] = True
matplotlib.rcParams["axes.spines.top"] = True
matplotlib.rcParams["axes.spines.bottom"] = True


def plot_RMSE():
"""Generate a bar plot of the RMSEs of the four models on AOC-ALDi's test data."""
plt.figure(figsize=(6.3 / 2, 1.5))

models = [
"(Baseline 1)\nMSA Lexicon",
"(Baseline 2)\nSentence DI",
"(Baseline 3)\nToken DI",
"(Our Model)\nSentence ALDi",
]
RMSEs = [0.34, 0.49, 0.30, 0.18]

cmap = cmx.Reds

for i, (model, RMSE) in enumerate(zip(models, RMSEs)):
plt.barh(y=-i, width=RMSE, label=model, color=cmap(2 * RMSE))
plt.annotate(
RMSE,
xy=(RMSE + 0.02, -i),
size=7,
color="black",
)

plt.yticks(
ticks=[-i for i in range(len(models))],
labels=models,
rotation=0,
weight="bold",
size=8,
)
plt.xlim(0, 1)
plt.xlabel("RMSE (↓) on AOC-ALDi's test data", weight="bold")
plt.ylabel("Model", weight="bold")
plt.savefig(f"RMSE.pdf", bbox_inches="tight")


plot_RMSE()

0 comments on commit 07b7817

Please sign in to comment.