-
Notifications
You must be signed in to change notification settings - Fork 0
/
export_excel.py
70 lines (55 loc) · 1.61 KB
/
export_excel.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from pandas import DataFrame
import pickle
import parametrization
def recognize(m):
""""
:param m: rr_matrix
:return: list of indexes that have a non-zero value,
list of percentage recognition for each digit
"""
recognition_idx = []
recognition = []
for i in range(len(MFCC_labels)):
for j in range(len(MFCC_labels[0])):
if not m[i][j] == 0:
recognition_idx.append([i, j])
if i == j:
recognition.append(m[i][j])
return recognition_idx, recognition
toLoop = [-1, 0, 1, 2, 4, 8]
""""
for k in toLoop:
if k == -1:
name = 'Speakers'
elif k == 0:
name = 'Noises'
else:
name = 'Mixed_snr_1_' + str(k)
MFCC = parametrization.reconstruct('files/parametrization/parametrized_' + name)
MFCC_labels = []
with open('files/cross_val/crossVal_'+name+'.p', 'rb') as file:
matrix1 = pickle.load(file)
matrix = []
for i in range(len(matrix1)):
helper = []
for k in range(len(matrix1[i])):
helper.append(matrix1[i][k][0])
matrix.append(helper)
"""
with open('files/Recognition/errors.p', 'rb') as file:
matrix1 = pickle.load(file)
print(matrix1)
matrix2 = []
names = []
toSave = []
for key in matrix1:
helper = []
for key2 in matrix1[key]:
gender = key2[:key2.find("_")]
helper.append(matrix1[key][key2])
toSave.append(helper)
names.append(key)
names.append(helper)
names.append(matrix2)
import_ = DataFrame(toSave)
import_.to_excel('recognition_errors.xlsx', index=False, startrow=1, startcol=1)