This algorithm is a legacy one. The API has changed since its implementation. New versions and forks will need to be updated.
This algorithm is an analyzer. It can only be used on analysis blocks.

Algorithms have at least one input and one output. All algorithm endpoints are organized in groups. Groups are used by the platform to indicate which inputs and outputs are synchronized together. The first group is automatically synchronized with the channel defined by the block in which the algorithm is deployed.

Group: group

Endpoint Name Data Format Nature
category system/integer/1 Input
scores system/integer/1 Input

Analyzers may produce any number of results. Once experiments using this analyzer are done, you may display the results or filter experiments using criteria based on them.

Name Type
numberNotProcessedT1Samples int32
numberNotProcessedT5Samples int32
totalNumberT1Samples int32
ACER float32
rocT1T5 plot/isoroc/1
rocT1T3 plot/isoroc/1
numberCorrectT5Samples int32
rocT1T6 plot/isoroc/1
rocT1T2 plot/isoroc/1
numberCorrectT3Samples int32
totalNumberT5Samples int32
numberNotProcessedT6Samples int32
numberNotProcessedT4Samples int32
numberCorrectT4Samples int32
numberCorrectT1Samples int32
totalNumberT2Samples int32
numberNotProcessedT2Samples int32
numberCorrectT2Samples int32
rocAll plot/isoroc/1
totalNumberT4Samples int32
totalNumberT6Samples int32
numberNotProcessedT3Samples int32
numberCorrectT6Samples int32
totalNumberT3Samples int32
rocT1T4 plot/isoroc/1
xxxxxxxxxx
204
 
1
import numpy as np
2
import bob.measure
3
4
class Algorithm:
5
    def __init__(self):
6
        self.T1 = None
7
        self.T2 = None
8
        self.T3 = None
9
        self.T4 = None
10
        self.T5 = None
11
        self.T6 = None
12
        self.allspoofs = None
13
        self.correct_T1 = []
14
        self.correct_T2 = []
15
        self.correct_T3 = []
16
        self.correct_T4 = []
17
        self.correct_T5 = []
18
        self.correct_T6 = []
19
        self.incorrect_T1 = []
20
        self.incorrect_T2 = []
21
        self.incorrect_T3 = []
22
        self.incorrect_T4 = []
23
        self.incorrect_T5 = []
24
        self.incorrect_T6 = []
25
        self.notprocessed_T1 = []
26
        self.notprocessed_T2 = []
27
        self.notprocessed_T3 = []
28
        self.notprocessed_T4 = []
29
        self.notprocessed_T5 = []
30
        self.notprocessed_T6 = []
31
        self.acer = None
32
        self.n_bins = 50
33
        self.threshold = 50
34
    def process(self, inputs, outputs):
35
        # accumulate the test scores
36
        data_test = inputs['scores'].data.value
37
        label_test = inputs['category'].data.value
38
        
39
        if label_test == 1:
40
            if data_test < 0 or data_test > 100:
41
                self.notprocessed_T1.append(data_test)
42
            elif data_test > self.threshold:
43
                self.correct_T1.append(data_test)
44
            else:
45
                self.incorrect_T1.append(data_test)
46
        elif label_test == 2:
47
            if data_test < 0 or data_test > 100:
48
                self.notprocessed_T2.append(data_test)
49
            elif data_test <= self.threshold:
50
                self.correct_T2.append(data_test)
51
            else:
52
                self.incorrect_T2.append(data_test)
53
        elif label_test == 3:
54
            if data_test < 0 or data_test > 100:
55
                self.notprocessed_T3.append(data_test)
56
            elif data_test <= self.threshold:
57
                self.correct_T3.append(data_test)
58
            else:
59
                self.incorrect_T3.append(data_test)
60
        elif label_test == 4:
61
            if data_test < 0 or data_test > 100:
62
                self.notprocessed_T4.append(data_test)
63
            elif data_test <= self.threshold:
64
                self.correct_T4.append(data_test)
65
            else:
66
                self.incorrect_T4.append(data_test)
67
        elif label_test == 5:
68
            if data_test < 0 or data_test > 100:
69
                self.notprocessed_T5.append(data_test)
70
            elif data_test <= self.threshold:
71
                self.correct_T5.append(data_test)
72
            else:
73
                self.incorrect_T5.append(data_test)
74
        elif label_test == 6:
75
            if data_test < 0 or data_test > 100:
76
                self.notprocessed_T6.append(data_test)
77
            elif data_test <= self.threshold:
78
                self.correct_T6.append(data_test)
79
            else:
80
                self.incorrect_T6.append(data_test)
81
82
        # once all values are received, evaluate the scores
83
        if not(inputs.hasMoreData()):
84
            self.T1 = np.array(self.correct_T1+self.incorrect_T1)
85
            self.T2 = np.array(self.correct_T2+self.incorrect_T2)
86
            self.T3 = np.array(self.correct_T3+self.incorrect_T3)
87
            self.T4 = np.array(self.correct_T4+self.incorrect_T4)
88
            self.T5 = np.array(self.correct_T5+self.incorrect_T5)
89
            self.T6 = np.array(self.correct_T6+self.incorrect_T6)
90
            self.allspoofs = np.array(self.correct_T2+self.incorrect_T2+self.correct_T3+self.incorrect_T3+self.correct_T4+self.incorrect_T4+self.correct_T5+self.incorrect_T5+self.correct_T6+self.incorrect_T6)
91
92
            apcer = np.float32(len(self.incorrect_T2+self.incorrect_T3+self.incorrect_T4+self.incorrect_T5+self.incorrect_T6)/len(self.allspoofs))
93
            bpcer = np.float32(len(self.incorrect_T1)/len(self.T1))
94
            self.acer = np.float32((apcer+bpcer)/2)
95
96
            # test_hist_pos, test_bin_pos = np.histogram(self.lives, self.n_bins)
97
            # test_hist_neg, test_bin_neg = np.histogram(self.spoofs, self.n_bins)
98
            
99
            # eer_threshold = bob.measure.eer_threshold(self.spoofs.astype(np.double), self.lives.astype(np.double))
100
            # far_test, frr_test = bob.measure.farfrr(self.negatives_test, self.lives, eer_threshold)
101
102
            rocAll  = bob.measure.roc(self.T1.astype(np.double), self.allspoofs.astype(np.double), 100)
103
            rocT1T2 = bob.measure.roc(self.T1.astype(np.double), self.T2.astype(np.double), 100)
104
            rocT1T3 = bob.measure.roc(self.T1.astype(np.double), self.T3.astype(np.double), 100)
105
            rocT1T4 = bob.measure.roc(self.T1.astype(np.double), self.T4.astype(np.double), 100)
106
            rocT1T5 = bob.measure.roc(self.T1.astype(np.double), self.T5.astype(np.double), 100)
107
            rocT1T6 = bob.measure.roc(self.T1.astype(np.double), self.T6.astype(np.double), 100)
108
109
            # writes the output back to the platform
110
            outputs.write({
111
                'totalNumberT1Samples': np.int32(len(self.T1)),
112
                'totalNumberT2Samples': np.int32(len(self.T2)),
113
                'totalNumberT3Samples': np.int32(len(self.T3)),
114
                'totalNumberT4Samples': np.int32(len(self.T4)),
115
                'totalNumberT5Samples': np.int32(len(self.T5)),
116
                'totalNumberT6Samples': np.int32(len(self.T6)),
117
                'numberCorrectT1Samples': np.int32(len(self.correct_T1)),
118
                'numberCorrectT2Samples': np.int32(len(self.correct_T2)),
119
                'numberCorrectT3Samples': np.int32(len(self.correct_T3)),
120
                'numberCorrectT4Samples': np.int32(len(self.correct_T4)),
121
                'numberCorrectT5Samples': np.int32(len(self.correct_T5)),
122
                'numberCorrectT6Samples': np.int32(len(self.correct_T6)),
123
                'numberNotProcessedT1Samples': np.int32(len(self.notprocessed_T1)),
124
                'numberNotProcessedT2Samples': np.int32(len(self.notprocessed_T2)),
125
                'numberNotProcessedT3Samples': np.int32(len(self.notprocessed_T3)),
126
                'numberNotProcessedT4Samples': np.int32(len(self.notprocessed_T4)),
127
                'numberNotProcessedT5Samples': np.int32(len(self.notprocessed_T5)),
128
                'numberNotProcessedT6Samples': np.int32(len(self.notprocessed_T6)),
129
                'ACER': np.float32(self.acer),
130
                'rocAll': {
131
                    "data":
132
                        [
133
                            {
134
                                "label": 'rocAll',
135
                                "false_positives": rocAll[1],
136
                                "false_negatives": rocAll[0],
137
                                "number_of_positives": np.uint64(len(self.T1)),
138
                                "number_of_negatives": np.uint64(len(self.allspoofs))
139
                            }
140
                        ]
141
                }, 
142
                'rocT1T2': {
143
                    "data":
144
                        [
145
                            {
146
                                "label": 'rocT1T2',
147
                                "false_positives": rocT1T2[1],
148
                                "false_negatives": rocT1T2[0],
149
                                "number_of_positives": np.uint64(len(self.T1)),
150
                                "number_of_negatives": np.uint64(len(self.T2))
151
                            }
152
                        ]
153
                }, 
154
                'rocT1T3': {
155
                    "data":
156
                        [
157
                            {
158
                                "label": 'rocT1T3',
159
                                "false_positives": rocT1T3[1],
160
                                "false_negatives": rocT1T3[0],
161
                                "number_of_positives": np.uint64(len(self.T1)),
162
                                "number_of_negatives": np.uint64(len(self.T3))
163
                            }
164
                        ]
165
                }, 
166
                'rocT1T4': {
167
                    "data":
168
                        [
169
                            {
170
                                "label": 'rocT1T4',
171
                                "false_positives": rocT1T4[1],
172
                                "false_negatives": rocT1T4[0],
173
                                "number_of_positives": np.uint64(len(self.T1)),
174
                                "number_of_negatives": np.uint64(len(self.T4))
175
                            }
176
                        ]
177
                }, 
178
                'rocT1T5': {
179
                    "data":
180
                        [
181
                            {
182
                                "label": 'rocT1T5',
183
                                "false_positives": rocT1T5[1],
184
                                "false_negatives": rocT1T5[0],
185
                                "number_of_positives": np.uint64(len(self.T1)),
186
                                "number_of_negatives": np.uint64(len(self.T5))
187
                            }
188
                        ]
189
                }, 
190
                'rocT1T6': {
191
                    "data":
192
                        [
193
                            {
194
                                "label": 'rocT1T6',
195
                                "false_positives": rocT1T6[1],
196
                                "false_negatives": rocT1T6[0],
197
                                "number_of_positives": np.uint64(len(self.T1)),
198
                                "number_of_negatives": np.uint64(len(self.T6))
199
                            }
200
                        ]
201
                }
202
            })
203
204
        return True

The code for this algorithm in Python
The ruler at 80 columns indicate suggested POSIX line breaks (for readability).
The editor will automatically enlarge to accomodate the entirety of your input
Use keyboard shortcuts for search/replace and faster editing. For example, use Ctrl-F (PC) or Cmd-F (Mac) to search through this box

Could not find any documentation for this object.
No experiments are using this algorithm.
Created with Raphaël 2.1.2[compare]zfang/livdet_analyzer/1amohammadi/livdet_analyzer/12020Jul13
This algorithm was never executed.
Terms of Service | Contact Information | BEAT platform version 2.2.1b0 | © Idiap Research Institute - 2013-2025