Skip to content

Commit

Permalink
0.93.2
Browse files Browse the repository at this point in the history
  • Loading branch information
FBurkhardt committed Nov 18, 2024
1 parent ab1f14c commit 6c9e681
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

Version 0.93.2
--------------
* changed class_label in plots to actual target

Version 0.93.1
--------------
* made explore module more robust
Expand Down
2 changes: 1 addition & 1 deletion nkululeko/constants.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION="0.93.1"
VERSION="0.93.2"
SAMPLING_RATE = 16000
4 changes: 3 additions & 1 deletion nkululeko/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,9 @@ def autopredict(self):
f"unknown augmentation selection specifier {sample_selection},"
" should be [all | train | test]"
)
targets = self.util.config_val_list("PREDICT", "targets", ["gender"])
targets = self.util.config_val_list("PREDICT", "targets", None)
if targets is None:
self.util.error("no prediction target specified")
for target in targets:
if target == "speaker":
from nkululeko.autopredict.ap_sid import SIDPredictor
Expand Down
32 changes: 30 additions & 2 deletions nkululeko/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import seaborn as sns
from sklearn.manifold import TSNE

from audmetric import concordance_cc as ccc

import nkululeko.glob_conf as glob_conf
from nkululeko.reporting.defines import Header
from nkululeko.reporting.report_item import ReportItem
Expand Down Expand Up @@ -239,28 +241,54 @@ def _check_binning(self, att, df):

def _plot2cont_cat(self, df, cont1, cont2, cat, ylab):
"""Plot relation of two continuous distributions with one categorical."""
if cont2 == "class_label":
df.rename(columns={cont2: self.target})
cont2 = self.target
if cont1 == "class_label":
df.rename(columns={cont1: self.target})
cont1 = self.target
if cat == "class_label":
df.rename(columns={cat: self.target})
cat = self.target
pearson = stats.pearsonr(df[cont1], df[cont2])
# trunc to three digits
pearson = int(pearson[0] * 1000) / 1000
pearson_string = f"PCC: {pearson}"
ccc_val = ccc(df[cont1], df[cont2])
ccc_val = int(ccc_val * 1000) / 1000
ccc_string = f"CCC: {ccc_val}"
ax = sns.lmplot(data=df, x=cont1, y=cont2, hue=cat)
caption = f"{ylab} {df.shape[0]}. {pearson_string}"
caption = f"{ylab} {df.shape[0]}. {pearson_string} {ccc_string}"
ax.figure.suptitle(caption)
return ax, caption

def _plot2cont(self, df, col1, col2, ylab):
"""Plot relation of two continuous distributions."""
# rename "class_label" to the original target
if col2 == "class_label":
df.rename(columns={col2: self.target})
col2 = self.target
if col1 == "class_label":
df.rename(columns={col1: self.target})
col1 = self.target
pearson = stats.pearsonr(df[col1], df[col2])
# trunc to three digits
pearson = int(pearson[0] * 1000) / 1000
pearson_string = f"PCC: {pearson}"
ccc_val = ccc(df[cont1], df[cont2])
ccc_val = int(ccc_val * 1000) / 1000
ccc_string = f"CCC: {ccc_val}"
ax = sns.lmplot(data=df, x=col1, y=col2)
caption = f"{ylab} {df.shape[0]}. {pearson_string}"
caption = f"{ylab} {df.shape[0]}. {pearson_string} {ccc_string}"
ax.figure.suptitle(caption)
return ax, caption

def plotcatcont(self, df, cat_col, cont_col, xlab, ylab):
"""Plot relation of categorical distribution with continuous."""
# rename "class_label" to the original target
if cat_col == "class_label":
df.rename(columns={cat_col: self.target})
cat_col = self.target
dist_type = self.util.config_val("EXPL", "dist_type", "kde")
cats, cat_str, es = su.get_effect_size(df, cat_col, cont_col)
model_type = self.util.get_model_type()
Expand Down
5 changes: 4 additions & 1 deletion nkululeko/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ def get_target_name(self):
return self.config["DATA"]["target"]

def get_model_type(self):
return self.config["MODEL"]["type"]
try:
return self.config["MODEL"]["type"]
except KeyError:
return ""

def get_model_description(self):
mt = ""
Expand Down

0 comments on commit 6c9e681

Please sign in to comment.