-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspeaker_plot.py
More file actions
48 lines (45 loc) · 1.43 KB
/
Copy pathspeaker_plot.py
File metadata and controls
48 lines (45 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import argparse
import audmetric
import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
import seaborn as sns
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-root", "-r", nargs="+")
args = parser.parse_args()
labels = {
"results-none": "Baseline",
"results-neutral": "Pers (neutral)",
"results-emotional": "Pers (emotional)",
"results-all": "Pers (all)"
}
plt.rcParams["text.usetex"] = True
plt.rcParams["font.family"] = "serif"
plt.rcParams["font.serif"] = "Palatino"
plt.rcParams["legend.fontsize"] = 9
fig = plt.figure(figsize=[6, 4])
ax = fig.add_subplot()
speaker_indices = None
for root in args.root:
df = pd.read_csv(os.path.join(root, "test.csv"))
speakers = df.groupby("speaker").apply(
lambda x: audmetric.unweighted_average_recall(x["class"], x["predictions"])
).sort_values()
if speaker_indices is None:
speaker_indices = speakers.index
ax.plot(speakers.loc[speaker_indices].values, label=labels[root])
ax.set_xlabel("Speaker ID")
ax.set_ylabel("UAR")
ax.set_title("Speaker-level performance")
sns.despine(ax=ax)
plt.legend(
# title="Model",
loc="upper center",
bbox_to_anchor=(.5, 1.05),
ncols=4
)
plt.tight_layout()
plt.savefig("speakers.png")
plt.savefig("speakers.pdf")