nkululeko 0.66.4__py3-none-any.whl → 0.66.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nkululeko/constants.py +1 -1
- nkululeko/data/dataset.py +3 -1
- nkululeko/plots.py +9 -9
- nkululeko/reporter.py +27 -20
- nkululeko/util.py +15 -7
- {nkululeko-0.66.4.dist-info → nkululeko-0.66.5.dist-info}/METADATA +5 -2
- {nkululeko-0.66.4.dist-info → nkululeko-0.66.5.dist-info}/RECORD +10 -10
- {nkululeko-0.66.4.dist-info → nkululeko-0.66.5.dist-info}/LICENSE +0 -0
- {nkululeko-0.66.4.dist-info → nkululeko-0.66.5.dist-info}/WHEEL +0 -0
- {nkululeko-0.66.4.dist-info → nkululeko-0.66.5.dist-info}/top_level.txt +0 -0
nkululeko/constants.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
VERSION="0.66.
|
1
|
+
VERSION="0.66.5"
|
2
2
|
SAMPLING_RATE = 16000
|
nkululeko/data/dataset.py
CHANGED
@@ -82,7 +82,9 @@ class Dataset:
|
|
82
82
|
f" {self.got_speaker} ({speaker_num}), got sexes: {self.got_gender}"
|
83
83
|
)
|
84
84
|
self.util.debug(r_string)
|
85
|
-
glob_conf.report.
|
85
|
+
if glob_conf.report.initial:
|
86
|
+
glob_conf.report.add_item(ReportItem("Data", "Load report", r_string))
|
87
|
+
glob_conf.report.initial = False
|
86
88
|
|
87
89
|
def load(self):
|
88
90
|
"""Load the dataframe with files, speakers and task labels"""
|
nkululeko/plots.py
CHANGED
@@ -10,6 +10,7 @@ from nkululeko.util import Util
|
|
10
10
|
import nkululeko.utils.stats as su
|
11
11
|
import nkululeko.glob_conf as glob_conf
|
12
12
|
from nkululeko.reporting.report_item import ReportItem
|
13
|
+
from nkululeko.reporting.defines import Header
|
13
14
|
|
14
15
|
|
15
16
|
class Plots:
|
@@ -26,7 +27,7 @@ class Plots:
|
|
26
27
|
df_speaker = df[df.speaker == s]
|
27
28
|
df_speaker["samplenum"] = df_speaker.shape[0]
|
28
29
|
df_speakers = pd.concat([df_speakers, df_speaker.head(1)])
|
29
|
-
# plot the
|
30
|
+
# plot the distribution of samples per speaker
|
30
31
|
fig_dir = self.util.get_path("fig_dir") + "../" # one up because of the runs
|
31
32
|
self.util.debug(f"plotting samples per speaker")
|
32
33
|
if "gender" in df_speakers:
|
@@ -51,7 +52,7 @@ class Plots:
|
|
51
52
|
plt.close(fig)
|
52
53
|
glob_conf.report.add_item(
|
53
54
|
ReportItem(
|
54
|
-
|
55
|
+
Header.HEADER_EXPLORE,
|
55
56
|
"Samples per speaker",
|
56
57
|
f"Samples per speaker ({df_speakers.shape[0]})",
|
57
58
|
img_path,
|
@@ -81,13 +82,12 @@ class Plots:
|
|
81
82
|
fig.clear()
|
82
83
|
glob_conf.report.add_item(
|
83
84
|
ReportItem(
|
84
|
-
|
85
|
+
Header.HEADER_EXPLORE,
|
85
86
|
"Sample value counts",
|
86
87
|
f"Samples per speaker ({df_speakers.shape[0]})",
|
87
88
|
img_path,
|
88
89
|
)
|
89
90
|
)
|
90
|
-
|
91
91
|
self.plot_distributions(df_speakers, type="speakers")
|
92
92
|
|
93
93
|
def plot_distributions(self, df, type="samples"):
|
@@ -154,8 +154,8 @@ class Plots:
|
|
154
154
|
plt.close(fig)
|
155
155
|
glob_conf.report.add_item(
|
156
156
|
ReportItem(
|
157
|
-
|
158
|
-
f
|
157
|
+
Header.HEADER_EXPLORE,
|
158
|
+
f"Correlation of {self.target} and {att[0]}",
|
159
159
|
caption,
|
160
160
|
img_path,
|
161
161
|
)
|
@@ -194,7 +194,7 @@ class Plots:
|
|
194
194
|
f" {att} has more than 2 values"
|
195
195
|
)
|
196
196
|
|
197
|
-
def plot_durations(self, df, filename, sample_selection, caption=
|
197
|
+
def plot_durations(self, df, filename, sample_selection, caption=""):
|
198
198
|
fig_dir = self.util.get_path("fig_dir") + "../" # one up because of the runs
|
199
199
|
try:
|
200
200
|
ax = sns.histplot(df, x="duration", hue="class_label", kde=True)
|
@@ -207,12 +207,12 @@ class Plots:
|
|
207
207
|
ax.set_ylabel(f"number of samples")
|
208
208
|
fig = ax.figure
|
209
209
|
plt.tight_layout()
|
210
|
-
img_path = f"{fig_dir}{filename}_{sample_selection}.{self.format}"
|
210
|
+
img_path = f"{fig_dir}{filename}_{sample_selection}.{self.format}"
|
211
211
|
plt.savefig(img_path)
|
212
212
|
plt.close(fig)
|
213
213
|
glob_conf.report.add_item(
|
214
214
|
ReportItem(
|
215
|
-
|
215
|
+
Header.HEADER_EXPLORE,
|
216
216
|
caption,
|
217
217
|
title,
|
218
218
|
img_path,
|
nkululeko/reporter.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
import glob
|
2
|
+
import math
|
1
3
|
import matplotlib.pyplot as plt
|
2
4
|
from sklearn.utils import resample
|
3
|
-
from nkululeko.util import Util
|
4
5
|
import ast
|
5
6
|
import json
|
6
7
|
import numpy as np
|
@@ -15,8 +16,8 @@ from sklearn.metrics import classification_report
|
|
15
16
|
from scipy.stats import pearsonr
|
16
17
|
from nkululeko.result import Result
|
17
18
|
from nkululeko.reporting.report_item import ReportItem
|
18
|
-
import
|
19
|
-
import
|
19
|
+
from nkululeko.reporting.defines import Header
|
20
|
+
from nkululeko.util import Util
|
20
21
|
|
21
22
|
|
22
23
|
class Reporter:
|
@@ -55,9 +56,7 @@ class Reporter:
|
|
55
56
|
else:
|
56
57
|
# regression experiment
|
57
58
|
if self.measure == "mse":
|
58
|
-
self.result.test = mean_squared_error(
|
59
|
-
self.truths, self.preds
|
60
|
-
)
|
59
|
+
self.result.test = mean_squared_error(self.truths, self.preds)
|
61
60
|
elif self.measure == "ccc":
|
62
61
|
self.result.test = self.ccc(self.truths, self.preds)
|
63
62
|
if math.isnan(self.result.test):
|
@@ -145,15 +144,24 @@ class Reporter:
|
|
145
144
|
reg_res = f", {self.MEASURE}: {self.result.test:.3f}"
|
146
145
|
|
147
146
|
if epoch != 0:
|
148
|
-
plt.title(
|
149
|
-
f"Confusion Matrix, UAR: {uar:.3f}{reg_res}, Epoch: {epoch}"
|
150
|
-
)
|
147
|
+
plt.title(f"Confusion Matrix, UAR: {uar:.3f}{reg_res}, Epoch: {epoch}")
|
151
148
|
else:
|
152
149
|
plt.title(f"Confusion Matrix, UAR: {uar:.3f}{reg_res}")
|
153
|
-
|
154
|
-
plt.savefig(
|
150
|
+
img_path = f"{fig_dir}{plot_name}.{self.format}"
|
151
|
+
plt.savefig(img_path)
|
155
152
|
fig.clear()
|
156
153
|
plt.close(fig)
|
154
|
+
plt.savefig(img_path)
|
155
|
+
plt.close(fig)
|
156
|
+
glob_conf.report.add_item(
|
157
|
+
ReportItem(
|
158
|
+
Header.HEADER_RESULTS,
|
159
|
+
self.util.get_model_description(),
|
160
|
+
"Confusion matrix",
|
161
|
+
img_path,
|
162
|
+
)
|
163
|
+
)
|
164
|
+
|
157
165
|
res_dir = self.util.get_path("res_dir")
|
158
166
|
rpt = f"epoch: {epoch}, UAR: {uar}, ACC {acc}"
|
159
167
|
file_name = f"{res_dir}{self.util.get_exp_name()}_conf.txt"
|
@@ -181,8 +189,7 @@ class Reporter:
|
|
181
189
|
except ValueError as e:
|
182
190
|
self.util.debug(
|
183
191
|
"Reporter: caught a ValueError when trying to get"
|
184
|
-
" classification_report: "
|
185
|
-
+ e
|
192
|
+
" classification_report: " + e
|
186
193
|
)
|
187
194
|
rpt = self.result.to_string()
|
188
195
|
with open(file_name, "w") as text_file:
|
@@ -196,7 +203,11 @@ class Reporter:
|
|
196
203
|
rpt_str = f"{json.dumps(rpt)}\n{f1_per_class}"
|
197
204
|
text_file.write(rpt_str)
|
198
205
|
glob_conf.report.add_item(
|
199
|
-
ReportItem(
|
206
|
+
ReportItem(
|
207
|
+
Header.HEADER_RESULTS,
|
208
|
+
f"Classification result {self.util.get_model_description()}",
|
209
|
+
rpt_str,
|
210
|
+
)
|
200
211
|
)
|
201
212
|
|
202
213
|
else: # regression
|
@@ -213,9 +224,7 @@ class Reporter:
|
|
213
224
|
import imageio
|
214
225
|
|
215
226
|
fig_dir = self.util.get_path("fig_dir")
|
216
|
-
filenames = glob.glob(
|
217
|
-
fig_dir + f"{self.util.get_plot_name()}*_?_???_cnf.png"
|
218
|
-
)
|
227
|
+
filenames = glob.glob(fig_dir + f"{self.util.get_plot_name()}*_?_???_cnf.png")
|
219
228
|
images = []
|
220
229
|
for filename in filenames:
|
221
230
|
images.append(imageio.imread(filename))
|
@@ -269,9 +278,7 @@ class Reporter:
|
|
269
278
|
var_pred = np.var(prediction, 0)
|
270
279
|
v_pred = prediction - mean_pred
|
271
280
|
v_gt = ground_truth - mean_gt
|
272
|
-
cor = sum(v_pred * v_gt) / (
|
273
|
-
np.sqrt(sum(v_pred**2)) * np.sqrt(sum(v_gt**2))
|
274
|
-
)
|
281
|
+
cor = sum(v_pred * v_gt) / (np.sqrt(sum(v_pred**2)) * np.sqrt(sum(v_gt**2)))
|
275
282
|
sd_gt = np.std(ground_truth)
|
276
283
|
sd_pred = np.std(prediction)
|
277
284
|
numerator = 2 * cor * sd_gt * sd_pred
|
nkululeko/util.py
CHANGED
@@ -131,8 +131,9 @@ class Util:
|
|
131
131
|
def _get_value_descript(self, section, name):
|
132
132
|
if self.config_val(section, name, False):
|
133
133
|
val = self.config_val(section, name, False)
|
134
|
-
|
135
|
-
|
134
|
+
val = str(val).strip('.')
|
135
|
+
return f'_{name}-{str(val)}'
|
136
|
+
return ''
|
136
137
|
|
137
138
|
def get_data_name(self):
|
138
139
|
"""
|
@@ -147,9 +148,15 @@ class Util:
|
|
147
148
|
ds = "_".join(ast.literal_eval(self.config["DATA"]["trains"]))
|
148
149
|
else:
|
149
150
|
ds = "_".join(ast.literal_eval(self.config["DATA"]["databases"]))
|
150
|
-
|
151
|
+
return_string = f"{ds}"
|
151
152
|
if not only_data:
|
152
|
-
mt =
|
153
|
+
mt = self.get_model_description()
|
154
|
+
return_string = return_string+'_'+mt
|
155
|
+
return return_string.replace("__", "_")
|
156
|
+
|
157
|
+
def get_model_description(self):
|
158
|
+
mt = ""
|
159
|
+
mt = f'{self.config["MODEL"]["type"]}'
|
153
160
|
ft = "_".join(ast.literal_eval(self.config["FEATS"]["type"]))
|
154
161
|
ft += "_"
|
155
162
|
set = self.config_val("FEATS", "set", False)
|
@@ -158,13 +165,14 @@ class Util:
|
|
158
165
|
set_string += set
|
159
166
|
layer_string = ""
|
160
167
|
layer_s = self.config_val("MODEL", "layers", False)
|
161
|
-
if layer_s
|
168
|
+
if layer_s:
|
162
169
|
layers = ast.literal_eval(layer_s)
|
163
170
|
sorted_layers = sorted(layers.items(), key=lambda x: x[1])
|
164
171
|
for l in sorted_layers:
|
165
172
|
layer_string += f"{str(l[1])}-"
|
166
|
-
return_string = f"{
|
173
|
+
return_string = f"{mt}_{ft}{set_string}{layer_string[:-1]}"
|
167
174
|
options = [
|
175
|
+
["MODEL", "C_val"],
|
168
176
|
["MODEL", "drop"],
|
169
177
|
["MODEL", "loss"],
|
170
178
|
["MODEL", "logo"],
|
@@ -173,7 +181,7 @@ class Util:
|
|
173
181
|
]
|
174
182
|
for option in options:
|
175
183
|
return_string += self._get_value_descript(option[0], option[1])
|
176
|
-
return return_string
|
184
|
+
return return_string
|
177
185
|
|
178
186
|
def get_plot_name(self):
|
179
187
|
try:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nkululeko
|
3
|
-
Version: 0.66.
|
3
|
+
Version: 0.66.5
|
4
4
|
Summary: Machine learning audio prediction experiments based on templates
|
5
5
|
Home-page: https://github.com/felixbur/nkululeko
|
6
6
|
Author: Felix Burkhardt
|
@@ -256,11 +256,14 @@ Nkululeko can be used under the [MIT license](https://choosealicense.com/license
|
|
256
256
|
Changelog
|
257
257
|
=========
|
258
258
|
|
259
|
+
Version 0.66.5
|
260
|
+
--------------
|
261
|
+
* Latex report now with images
|
262
|
+
|
259
263
|
Version 0.66.4
|
260
264
|
--------------
|
261
265
|
* Pypi version mixup
|
262
266
|
|
263
|
-
|
264
267
|
Version 0.66.3
|
265
268
|
--------------
|
266
269
|
* made path to PDF output relative to experiment root
|
@@ -2,7 +2,7 @@ nkululeko/__init__.py,sha256=62f8HiEzJ8rG2QlTFJXUCMpvuH3fKI33DoJSj33mscc,63
|
|
2
2
|
nkululeko/augment.py,sha256=lZcqCLNTLfC6G47ZjLYQXGcyPFJkmnOUDJOpn6aIJvE,1819
|
3
3
|
nkululeko/balancer.py,sha256=WslJxQwMNnVYgZXF1y0ueS5zilRPQJZDhUG72Csb4Gw,11
|
4
4
|
nkululeko/cacheddataset.py,sha256=lIJ6hUo5LoxSrzXtWV8mzwO7wRtUETWnOQ4ws2XfL1E,969
|
5
|
-
nkululeko/constants.py,sha256=
|
5
|
+
nkululeko/constants.py,sha256=Fu_qO9F8IJXYOYQlMl0uWE99ABO4cHIA1Fd-dp3TvrI,38
|
6
6
|
nkululeko/demo.py,sha256=6CmLxH_0QJIMazPPg7IZur7ciNdqby6yOlh-6zu6YE0,1951
|
7
7
|
nkululeko/demo_predictor.py,sha256=5PknI8SniGBRMzZOrmBOfPTV71rBbI1JCTnA6lXz6IU,2334
|
8
8
|
nkululeko/experiment.py,sha256=tooe4nLmR_vA0nK047lVxByH3dph65-dW740H97tV1c,27017
|
@@ -14,9 +14,9 @@ nkululeko/filter_data.py,sha256=JpvE7lfGEtDG8fDmnxYW6F6gLMENySy1vkfrVyyxX6k,7350
|
|
14
14
|
nkululeko/glob_conf.py,sha256=6MZe83QCgHD_zB79Sl9m6UJQASwfqJlyb-1nqrQ_6Iw,381
|
15
15
|
nkululeko/modelrunner.py,sha256=gpEX3D1I31-M0xBsbWZAIENMR7vQbP4OxCDS_fa9cDo,6076
|
16
16
|
nkululeko/nkululeko.py,sha256=CKuW2Lh6ioA4IndsxtmXdWromnKr9McJF74LMmgcd_0,1774
|
17
|
-
nkululeko/plots.py,sha256=
|
17
|
+
nkululeko/plots.py,sha256=d6W2I0Cr-dHkQAZPRvBDY0MG_agp8qjkafFHKREIMQg,15950
|
18
18
|
nkululeko/predict.py,sha256=kMrQTnQx3_yWh9JVUB_R6DxIo9jkbOrfT2ZGbONoHNs,1926
|
19
|
-
nkululeko/reporter.py,sha256=
|
19
|
+
nkululeko/reporter.py,sha256=t7X9R5FPL9NCl6qg3Z3R5PhlKcErCUuAr9OJdfMHGCM,11318
|
20
20
|
nkululeko/resample.py,sha256=7O9q8T_vsEExTiWO6lCt5I-ZGdYrRSPJ3CVzhksyAPE,2235
|
21
21
|
nkululeko/result.py,sha256=rEJEdsF9XLdF2DQBaGzvlSTVhLK98q9-NHNOsZOqP0w,447
|
22
22
|
nkululeko/runmanager.py,sha256=M1T75M2VCYF1yrN49ozqyvvkCyJJAJYL8BW5cee1P78,7401
|
@@ -25,7 +25,7 @@ nkululeko/segment.py,sha256=yhlYoFkKWxxOS56r29_InP49uzVxErrksc5BRpmkamE,4874
|
|
25
25
|
nkululeko/syllable_nuclei.py,sha256=Sky-C__MeUDaxqHnDl2TGLLYOYvsahD35TUjWGeG31k,10047
|
26
26
|
nkululeko/test.py,sha256=Z00CQrJ6Pp9zycKSLrCFjzew-_AXll3pud2o0xur_KY,1457
|
27
27
|
nkululeko/test_predictor.py,sha256=mO-jm1ViTtZY8QfWhJLyEboU1nn_CfKQ9c7-dgUxMp0,2403
|
28
|
-
nkululeko/util.py,sha256=
|
28
|
+
nkululeko/util.py,sha256=fxQePaou68_BFq6tND5mvVt0vPqp1BWdKa2s1YryeF0,10320
|
29
29
|
nkululeko/augmenting/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
30
30
|
nkululeko/augmenting/augmenter.py,sha256=S6LUbHz33WFQW8rawSRtMZABEvucjml7ezFG6Zeyq6s,2647
|
31
31
|
nkululeko/augmenting/randomsplicer.py,sha256=6QAl1gV8IODA4_ecgAc_qidtBaqUxUnH0k0ItQLNdnE,2705
|
@@ -44,7 +44,7 @@ nkululeko/autopredict/ap_stoi.py,sha256=KbGe5D0-uCtulhXA-IEMtkUcAYNeaIBsa5TpZvEX
|
|
44
44
|
nkululeko/autopredict/ap_valence.py,sha256=qDsgfb8dF-gM080aP9fDedHC63Yw5cgtlnSqb-0M_Jw,1040
|
45
45
|
nkululeko/autopredict/estimate_snr.py,sha256=kJbvkt2alMN5ouS03USheU7hJ2l7U9JF0s9AtNT1Vx0,4818
|
46
46
|
nkululeko/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
47
|
-
nkululeko/data/dataset.py,sha256=
|
47
|
+
nkululeko/data/dataset.py,sha256=scvmYzvQC-kEFxfzS9-R3-NCWWqlkq9LXcwDtuD9Gwo,22217
|
48
48
|
nkululeko/data/dataset_csv.py,sha256=MgmpADmS2jNBtmKSzCDLAV_sH4MRjMwyNmBLOfS9c3A,3034
|
49
49
|
nkululeko/feat_extract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
50
50
|
nkululeko/feat_extract/feats_agender.py,sha256=sDfsvSC2zt1JLn5rmB7bdck1JmXIIol3oIwN90TossM,2867
|
@@ -92,8 +92,8 @@ nkululeko/segmenting/seg_silero.py,sha256=So2D5eOVoeXwJSpmyA9PSAmnylLCeWuLR2Dg-c
|
|
92
92
|
nkululeko/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
93
93
|
nkululeko/utils/files.py,sha256=UiGAtZRWYjHSvlmPaTMtzyNNGE6qaLaxQkybctS7iRM,4021
|
94
94
|
nkululeko/utils/stats.py,sha256=pbFynlmFvRL2k01CpsqY6S2LvpG9ESNTSv7o4UwgCms,2242
|
95
|
-
nkululeko-0.66.
|
96
|
-
nkululeko-0.66.
|
97
|
-
nkululeko-0.66.
|
98
|
-
nkululeko-0.66.
|
99
|
-
nkululeko-0.66.
|
95
|
+
nkululeko-0.66.5.dist-info/LICENSE,sha256=0zGP5B_W35yAcGfHPS18Q2B8UhvLRY3dQq1MhpsJU_U,1076
|
96
|
+
nkululeko-0.66.5.dist-info/METADATA,sha256=rquTxkHeeRpzwW2RJTz67zJECSqpWyFRoz_Pyob54ro,24482
|
97
|
+
nkululeko-0.66.5.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
98
|
+
nkululeko-0.66.5.dist-info/top_level.txt,sha256=DPFNNSHPjUeVKj44dVANAjuVGRCC3MusJ08lc2a8xFA,10
|
99
|
+
nkululeko-0.66.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|