diff --git a/exp_xgb.ini b/exp_emodb.ini similarity index 84% rename from exp_xgb.ini rename to exp_emodb.ini index 5e0a8857..92fde5da 100644 --- a/exp_xgb.ini +++ b/exp_emodb.ini @@ -1,5 +1,5 @@ [EXP] -root = /home/fburkhardt/ResearchProjects/nkululeko +root = /home/fburkhardt/ResearchProjects/nkululeko/ store = ./store/ name = xgb-exp fig_dir = ./images/ @@ -8,7 +8,7 @@ databases = ['emodb'] emodb = /home/fburkhardt/audb/emodb/6/ emodb.mapping = {'anger':'angry', 'happiness':'happy', 'sadness':'sad', 'neutral':'neutral'} emodb.split_strategy = speaker_split -emodb.testsplit = 10 +emodb.testsplit = 40 target = emotion labels = ['neutral', 'happy', 'sad', 'angry'] [FEATS] diff --git a/main.py b/exp_emodb.py similarity index 92% rename from main.py rename to exp_emodb.py index acd52a2e..3b215db5 100644 --- a/main.py +++ b/exp_emodb.py @@ -38,4 +38,4 @@ def main(config_file): if __name__ == "__main__": - main('/home/fburkhardt/ResearchProjects/nkululeko/exp_xgb.ini') #sys.argv[1]) + main('/home/fburkhardt/ResearchProjects/nkululeko/exp_emodb.ini') #sys.argv[1]) diff --git a/exp_svm.ini b/exp_svm.ini deleted file mode 100644 index 4d1cb5ac..00000000 --- a/exp_svm.ini +++ /dev/null @@ -1,31 +0,0 @@ -[EXP] -root = /home/felix/data/research/nkululeko/ -store = ./store/ -name = svm-exp -fig_dir = ./images/ -type = classification -[DATA] -databases = ['danish', 'polish'] -tests = ['danish'] -trains= ['polish'] -polish = /home/felix/data/audb/polish-emotional-speech -polish.mapping = {'anger':'angry', 'joy':'happy', 'sadness':'sad', 'neutral':'neutral'} -danish = /home/felix/data/audb/danish-emotional-speech -danish.mapping = {'angry':'angry', 'happy':'happy', 'sad':'sad', 'neutral':'neutral'} -emovo = /home/felix/data/audb/emovo -emovo.mapping = {'anger':'angry', 'joy':'happy', 'sadness':'sad', 'neutral':'neutral'} -ravdess = /home/felix/data/audb/ravdess -ravdess.mapping = {'angry':'angry', 'happy':'happy', 'sad':'sad', 'neutral':'neutral'} -emodb = /home/felix/data/audb/emodb -emodb.mapping = {'anger':'angry', 'happiness':'happy', 'sadness':'sad', 'neutral':'neutral'} -emodb.testsplit = 50 -target = emotion -labels = ['neutral', 'happy', 'sad', 'angry'] -strategy = cross_data -[RUN_MGR] -runs = 1 -epochs = 1 -[MODEL] -type = svm -[SVM] -C = 4 \ No newline at end of file diff --git a/src/reporter.py b/src/reporter.py index 3e96a4c3..15bffba3 100644 --- a/src/reporter.py +++ b/src/reporter.py @@ -7,6 +7,8 @@ import ast import numpy as np import glob_conf +from sklearn.metrics import ConfusionMatrixDisplay +from sklearn.metrics import confusion_matrix class Reporter: @@ -20,12 +22,25 @@ def continuous_to_categorical(self): self.truths = np.digitize(self.truths, bins)-1 self.preds = np.digitize(self.preds, bins)-1 + def plot_confmatrix_mew(self, plot_name): + fig_dir = self.util.get_path('fig_dir') + labels = ast.literal_eval(glob_conf.config['DATA']['labels']) + plt.figure() # figsize=[5, 5] + cm = confusion_matrix(self.truths, self.preds, normalize = 'true') + disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=labels).plot(cmap='Blues') + print(f'plotting conf matrix to {fig_dir+plot_name}') + plt.title('Confusion Matrix') + plt.savefig(fig_dir+plot_name) + plt.close() + + def plot_confmatrix(self, plot_name): fig_dir = self.util.get_path('fig_dir') sns.set() # get prettier plots labels = ast.literal_eval(glob_conf.config['DATA']['labels']) - plt.figure(figsize=[5, 5]) + plt.figure() # figsize=[5, 5] plt.title('Confusion Matrix') + plt.ylabel('UAR') audplot.confusion_matrix(self.truths, self.preds) # replace labels locs, _ = plt.xticks() @@ -35,6 +50,12 @@ def plot_confmatrix(self, plot_name): print(f'plotting conf matrix to {fig_dir+plot_name}') plt.savefig(fig_dir+plot_name) plt.close() + print('truths') + print(self.truths.values) + print('preds') + print(self.preds) + print('labels') + print(labels) def uar(self): return recall_score(self.truths, self.preds, average='macro')