Skip to content

Commit

Permalink
0.81.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FBurkhardt committed Mar 18, 2024
1 parent f52bb46 commit 24b21f9
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 16 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.81.0
--------------
* added test selection to test module

Version 0.80.4
--------------
* added test-file folder to demo file lists
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.80.4"
VERSION="0.81.0"
SAMPLING_RATE = 16000
8 changes: 4 additions & 4 deletions nkululeko/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,18 +541,18 @@ def prepare_labels(self):
only_tests = eval(self.util.config_val("DATA", "tests", "False"))
module = glob_conf.module
if only_tests and module == "test":
self.df = self.map_labels(self.df)
self.df_test = self.map_labels(self.df_test)
# Bin target values if they are continuous but a classification experiment should be done
self.map_continuous_classification(self.df)
self.df = self._add_labels(self.df)
self.map_continuous_classification(self.df_test)
self.df_test = self._add_labels(self.df_test)
if self.util.config_val_data(self.name, "value_counts", False):
if not self.got_gender or not self.got_speaker:
self.util.error(
"can't plot value counts if no speaker or gender is" " given"
)
else:
self.plot.describe_df(
self.name, self.df, self.target, f"{self.name}_distplot"
self.name, self.df_test, self.target, f"{self.name}_distplot"
)
return
self.df_train = self.map_labels(self.df_train)
Expand Down
5 changes: 3 additions & 2 deletions nkululeko/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,17 @@ def fill_tests(self):
self.got_age = True
if data.got_speaker:
self.got_speaker = True
data.split()
data.prepare_labels()
self.df_test = pd.concat(
[self.df_test, self.util.make_segmented_index(data.df)]
[self.df_test, self.util.make_segmented_index(data.df_test)]
)
self.df_test.is_labeled = data.is_labeled
self.df_test.got_gender = self.got_gender
self.df_test.got_speaker = self.got_speaker
# self.util.set_config_val('FEATS', 'needs_features_extraction', 'True')
# self.util.set_config_val('FEATS', 'no_reuse', 'True')
self.df_test["class_labels"] = self.df_test[self.target]
self.df_test["class_label"] = self.df_test[self.target]
self.df_test[self.target] = self.label_encoder.transform(
self.df_test[self.target]
)
Expand Down
2 changes: 1 addition & 1 deletion nkululeko/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def main(src_dir):
expr = Experiment(config)
module = "test"
expr.set_module(module)
util = Util(module)
util = Util(module, has_config=True)
util.debug(
f"running {expr.name} from config {config_file}, nkululeko version"
f" {VERSION}"
Expand Down
16 changes: 11 additions & 5 deletions nkululeko/test_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Predict targets from a model and save as csv file.
"""

import nkululeko.glob_conf as glob_conf
from nkululeko.utils.util import Util
import pandas as pd
Expand Down Expand Up @@ -50,9 +51,14 @@ def predict_and_store(self):
else:
predictions = self.model.get_predictions()
# print(predictions)
df = pd.DataFrame(index=self.orig_df.index)
df["speaker"] = self.orig_df["speaker"]
df["gender"] = self.orig_df["gender"]
df[self.target] = self.label_encoder.inverse_transform(predictions)
# df[self.target] = predictions
# df = pd.DataFrame(index=self.orig_df.index)
# df["speaker"] = self.orig_df["speaker"]
# df["gender"] = self.orig_df["gender"]
# df[self.target] = self.orig_df[self.target]
df = self.orig_df.copy()
df["predictions"] = self.label_encoder.inverse_transform(predictions)
target = self.util.config_val("DATA", "target", "emotion")
if "class_label" in df.columns:
df = df.drop(columns=[target])
df = df.rename(columns={"class_label": target})
df.to_csv(self.name)
13 changes: 11 additions & 2 deletions test_runs.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
# test explore module
python -m nkululeko.explore --config tests/exp_emodb_explore_data.ini
python -m nkululeko.explore --config tests/exp_emodb_explore_featimportance.ini
python -m nkululeko.explore --config tests/exp_emodb_explore_scatter.ini
python -m nkululeko.explore --config tests/exp_emodb_explore_features.ini
python -m nkululeko.explore --config tests/exp_androids_explore.ini
python -m nkululeko.explore --config tests/exp_agedb_explore_data.ini
# test basic nkululeko
python -m nkululeko.nkululeko --config tests/exp_emodb_os_praat_xgb.ini
python -m nkululeko.nkululeko --config tests/exp_emodb_featimport_xgb.ini
python -m nkululeko.nkululeko --config tests/exp_emodb_cnn.ini
python -m nkululeko.nkululeko --config tests/exp_emodb_balancing.ini
python -m nkululeko.nkululeko --config tests/exp_emodb_audmodel_xgb.ini
python -m nkululeko.nkululeko --config tests/exp_emodb_split.ini
#python -m nkululeko.nkululeko --config tests/exp_emodb_clap_mlp.ini
python -m nkululeko.nkululeko --config tests/exp_emodb_os_mlp.ini
python -m nkululeko.nkululeko --config tests/exp_ravdess_os_xgb.ini
python -m nkululeko.nkululeko --config tests/exp_agedb_os_xgr.ini
python -m nkululeko.nkululeko --config tests/exp_agedb_os_mlp.ini
python -m nkululeko.nkululeko --config tests/exp_agedb_class_os_xgb.ini
python -m nkululeko.explore --config tests/exp_agedb_explore_data.ini
# test augmentation
python -m nkululeko.augment --config tests/exp_emodb_augment_os_xgb.ini
python -m nkululeko.nkululeko --config tests/exp_emodb-aug_os_xgb.ini
python -m nkululeko.augment --config tests/exp_emodb_random_splice_os_xgb.ini
python -m nkululeko.nkululeko --config tests/exp_emodb_rs_os_xgb.ini
python -m nkululeko.aug_train --config tests/emodb_aug_train.ini
python -m nkululeko.nkululeko --config tests/exp_androids_os_svm.ini
# test prediction
python -m nkululeko.predict --config tests/exp_emodb_predict.ini
python -m nkululeko.nkululeko --config tests/emodb_demo.ini
# test demo
python -m nkululeko.demo --config tests/emodb_demo.ini --list data/test/samples.csv
# test test module
python -m nkululeko.nkululeko --config exp_emodb_os_xgb_test.ini
python -m nkululeko.test --config exp_emodb_os_xgb_test.ini
# test multidb
python -m nkululeko.multidb --config tests/exp_multidb.ini
# test spotlight
python -m nkululeko.explore --config tests/exp_explore.ini
2 changes: 1 addition & 1 deletion tests/data_roots.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ emodb.train_tables = ['emotion.categories.train.gold_standard']
emodb.mapping = {'anger':'angry', 'happiness':'happy', 'sadness':'sad', 'neutral':'neutral'}
polish = ./data/polish_emo
polish.mapping = {'anger':'angry', 'joy':'happy', 'sadness':'sad', 'neutral':'neutral'}
polish.split_strategy = speaker_split
polish.split_strategy = test
polish.test_size = 30
17 changes: 17 additions & 0 deletions tests/exp_emodb_os_xgb_test.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[EXP]
root = ./tests/results/
name = exp_testmodule
save = True
[DATA]
databases = ['emodb']
root_folders = tests/data_roots.ini
target = emotion
tests = ['polish']
polish.split_strategy = speaker_split
labels = ['angry', 'happy', 'neutral', 'sad']
no_reuse = True
[FEATS]
type = ['os']
[MODEL]
type = xgb
save = True

0 comments on commit 24b21f9

Please sign in to comment.