-
Notifications
You must be signed in to change notification settings - Fork 0
/
dcase_utils.py
135 lines (130 loc) · 2.36 KB
/
dcase_utils.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
def get_class_name_train(label):
classes = [
'SNMK',
'c_4',
'c_26',
'c_13',
'c_22',
'c_9',
'c_11',
'c_8',
'c_24',
'GIG',
'c_21',
'GRN',
'COYE',
'RBGR',
'CHSP',
'c_16',
'c_17',
'BTBW',
'c_12',
'BBWA',
'c_20',
'c_19',
'WHP',
'c_7',
'AMRE',
'WTSP',
'GCTH',
'c_23',
'c_6',
'c_14',
'SAVS',
'RUM',
'AGGM',
'c_2',
'c_25',
'CALL',
'SQT',
'SWTH',
'SOCM',
'c_3',
'CCMK',
'c_5',
'c_10',
'OVEN',
'c_15',
'c_1',
'c_18',
'UNK'
]
return classes[label]
def get_label_train(row, columns):
classes = [
'SNMK',
'c_4',
'c_26',
'c_13',
'c_22',
'c_9',
'c_11',
'c_8',
'c_24',
'GIG',
'c_21',
'GRN',
'COYE',
'RBGR',
'CHSP',
'c_16',
'c_17',
'BTBW',
'c_12',
'BBWA',
'c_20',
'c_19',
'WHP',
'c_7',
'AMRE',
'WTSP',
'GCTH',
'c_23',
'c_6',
'c_14',
'SAVS',
'RUM',
'AGGM',
'c_2',
'c_25',
'CALL',
'SQT',
'SWTH',
'SOCM',
'c_3',
'CCMK',
'c_5',
'c_10',
'OVEN',
'c_15',
'c_1',
'c_18',
'UNK'
]
positives = list(columns[3:][row[1][3:] == 'POS'])
if len(positives) == 0:
y_class = classes.index('UNK')
elif len(positives) == 1:
y_class = classes.index(positives[0])
else:
raise ValueError("Unhandled case in get_label")
return y_class
def get_label_valid(row, columns):
classes = [
'Q',
'UNK'
]
positives = list(columns[3:][row[1][3:] == 'POS'])
if len(positives) == 0:
y_class = classes.index('UNK')
elif len(positives) == 1:
y_class = classes.index(positives[0])
else:
raise ValueError("Unhandled case in get_label")
return y_class
def get_class_name_valid(label):
classes = [
'Q',
'UNK'
]
return classes[label]