Delta plot added

This commit is contained in:
Lorenzo Volpi 2023-10-20 23:36:41 +02:00
parent d906502c29
commit a25b6bf14d
13 changed files with 1989 additions and 2 deletions

3
.gitignore vendored
View File

@ -11,5 +11,4 @@ lipton_bbse/__pycache__/*
elsahar19_rca/__pycache__/*
*.coverage
.coverage
scp_sync.py
out/*
scp_sync.py

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

1955
out/rcv1_CCAT.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -69,6 +69,12 @@ class EvaluationReport:
columns=g_dict.keys(),
)
def get_plot(self, mode="delta", metric="acc"):
g_prevs, g_dict = self.groupby_prevs(metric=metric)
t_prev = int(round(self.train_prevs["train"][0] * 100))
title = f"{self.name}_{t_prev}_{metric}"
plot.plot_delta(g_prevs, g_dict, metric, title)
def to_md(self, *metrics):
res = ""
for k, v in self.train_prevs.items():
@ -78,6 +84,7 @@ class EvaluationReport:
res += "\n"
for m in metrics:
res += self.get_dataframe(metric=m).to_html() + "\n\n"
self.get_plot(metric=m)
return res

26
quacc/plot.py Normal file
View File

@ -0,0 +1,26 @@
import matplotlib.pyplot as plt
from quacc.environ import env
def plot_delta(base_prevs, dict_vals, metric, title):
fig, ax = plt.subplots()
base_prevs = [f for f, p in base_prevs]
for method, deltas in dict_vals.items():
ax.plot(
base_prevs,
deltas,
label=method,
linestyle="-",
marker="o",
markersize=3,
zorder=2,
)
ax.set(xlabel="test prevalence", ylabel=metric, title=title)
# ax.set_ylim(0, 1)
# ax.set_xlim(0, 1)
ax.legend()
output_path = env.PLOT_OUT_DIR / f"{title}.png"
plt.savefig(output_path)