forked from kimna4/FaceSpoofingDetection
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathtrainingAndTesting_JPG.m
386 lines (312 loc) · 17 KB
/
trainingAndTesting_JPG.m
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
%% feature train & test %%
% clear all;
% featuresCASIA = feature_CASIA( 'distortion', 'glcm', 'lbpU8' );
% featuresMSU = feature_MSU( 'distortion', 'glcm', 'lbpU8' );
% distortion: 115, glcm: 12, visualRhythmHori: 3600, lbpU8: 59,
% lbpU8Fourier: 59, lbpU16: 243
%
%% init
numFrames = 30;
%% CASE 1 - only MSU Features
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- REPLAY
% JPG replay
MSU_TrainData = [featuresMSU.trainGenuine; featuresMSU.trainReplay; ];
MSU_TestData = [featuresMSU.testGenuine; featuresMSU.testReplay; ];
% Label replay
MSU_TrainLabel = [1*ones(size(featuresMSU.trainGenuine, 1), 1); -1*ones(size(featuresMSU.trainReplay, 1), 1)];
MSU_TestLabel = [1*ones(size(featuresMSU.testGenuine, 1), 1); -1*ones(size(featuresMSU.testReplay, 1), 1)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- PRINTED
% JPG print
MSU_TrainData = [featuresMSU.trainGenuine; featuresMSU.trainPrinted];
MSU_TestData = [featuresMSU.testGenuine; featuresMSU.testPrinted];
% Label print
MSU_TrainLabel = [ones(size(featuresMSU.trainGenuine, 1), 1); -1*ones(size(featuresMSU.trainPrinted, 1), 1)];
MSU_TestLabel = [ones(size(featuresMSU.testGenuine, 1), 1); -1*ones(size(featuresMSU.testPrinted, 1), 1)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- REPLAY + PRINTED
% JPG replay + print
MSU_TrainData = [featuresMSU.trainGenuine; featuresMSU.trainReplay; featuresMSU.trainPrinted];
MSU_TestData = [featuresMSU.testGenuine; featuresMSU.testReplay; featuresMSU.testPrinted];
% Label replay + print
MSU_TrainLabel = [ones(size(featuresMSU.trainGenuine, 1), 1); -1*ones(size(featuresMSU.trainReplay, 1), 1); -1*ones(size(featuresMSU.trainPrinted, 1), 1)];
MSU_TestLabel = [ones(size(featuresMSU.testGenuine, 1), 1); -1*ones(size(featuresMSU.testReplay, 1), 1); -1*ones(size(featuresMSU.testPrinted, 1), 1)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% jpg (dis, glcm, lbp)
MSU_TrainDistortion = MSU_TrainData(:, 1:115);
MSU_TrainGlcm = MSU_TrainData(:, 116:203);
MSU_TrainLBP = MSU_TrainData(:, 204:1036);
MSU_TestDistortion = MSU_TestData(:, 1:115);
MSU_TestGlcm = MSU_TestData(:, 116:203);
MSU_TestLBP = MSU_TestData(:, 204:1036);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% distortion features normalization
[MSU_TrainDistortion MSU_FeaturesMu MSU_FeaturesStddev ]= featureNormalize(MSU_TrainDistortion);
MSU_TestDistortion = featureNormalizeForTesting(MSU_TestDistortion, MSU_FeaturesMu, MSU_FeaturesStddev);
% glcm features normalization
[MSU_TrainGlcm MSU_FeaturesMu MSU_FeaturesStddev ]= featureNormalize(MSU_TrainGlcm);
MSU_TestGlcm = featureNormalizeForTesting(MSU_TestGlcm, MSU_FeaturesMu, MSU_FeaturesStddev);
% LBP normalization
[MSU_TrainLBP MSU_FeaturesMu MSU_FeaturesStddev ]= featureNormalize(MSU_TrainLBP);
MSU_TestLBP = featureNormalizeForTesting(MSU_TestLBP, MSU_FeaturesMu, MSU_FeaturesStddev);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1. JPG: dis + glcm + lbp//
MSU_TrainData = [MSU_TrainDistortion MSU_TrainGlcm MSU_TrainLBP];
MSU_TestData = [MSU_TestDistortion MSU_TestGlcm MSU_TestLBP];
% linear SVM
MSU_Model_1 = svmtrain(MSU_TrainLabel, MSU_TrainData, '-c 0.5000 -g 0.0313 -t 2');
[MSU_predict_label_1, MSU_accuracy_1, MSU_dec_values1] = svmpredict(MSU_TestLabel, MSU_TestData, MSU_Model_1);
MSU_Model_2 = svmtrain(MSU_TrainLabel, MSU_TrainData, '-c 2 -g 0.0313 -t 2');
[MSU_predict_label_2, MSU_accuracy_2, MSU_dec_values2] = svmpredict(MSU_TestLabel, MSU_TestData, MSU_Model_2);
MSU_Model_3 = svmtrain(MSU_TrainLabel, MSU_TrainData, '-c 128 -g 0.0000991 -t 2');
[MSU_predict_label_3, MSU_accuracy_3, MSU_dec_values3] = svmpredict(MSU_TestLabel, MSU_TestData, MSU_Model_3);
MSU_Model_4 = svmtrain(MSU_TrainLabel, MSU_TrainData, '-c 330 -g 0.00099 -t 2');
[MSU_predict_label_4, MSU_accuracy_4, MSU_dec_values4] = svmpredict(MSU_TestLabel, MSU_TestData, MSU_Model_4);
MSU_Model_5 = svmtrain(MSU_TrainLabel, MSU_TrainData, '-c 220 -g 0.000097 -t 2');
[MSU_predict_label_5, MSU_accuracy_5, MSU_dec_values5] = svmpredict(MSU_TestLabel, MSU_TestData, MSU_Model_5);
MSU_Model_6 = svmtrain(MSU_TrainLabel, MSU_TrainData, '-c 195 -g 0.00139-t 2');
[MSU_predict_label_6, MSU_accuracy_6, MSU_dec_values6] = svmpredict(MSU_TestLabel, MSU_TestData, MSU_Model_6);
% nogada
MSU_Model_5 = svmtrain(MSU_TrainLabel, MSU_TrainData, '-c 0.353553390593274 -g 0.000976562500000000 -t 2');
[MSU_predict_label_5, MSU_accuracy_5, MSU_dec_values5] = svmpredict(MSU_TestLabel, MSU_TestData, MSU_Model_5);
% HTER
MSU_predict_label = MSU_predict_label_5;
[acc HTER ] = getHTER( MSU_predict_label, MSU_TestLabel, numFrames);
% ROC
MSU_dec_values = MSU_dec_values5;
[X, Y, T, AUC] = perfcurve(MSU_TestLabel, MSU_dec_values, 1);
AUC
figure
plot(X,Y)
% set(gca, 'XTick', [0.0001 : 0.1 : 10])
% axis([0 10 0 1])
xlabel('False positive rate')
ylabel('True positive rate')
%title('ROC for Classification by Logistic Regression')
for i = 1 : size(X, 1),
if X(i) == 0.01,
fprintf('Y: %f \n', Y(i));
end
end
%ERR
MSU_dec_values = MSU_dec_values5;
[X, Y, T, AUC] = perfcurve(MSU_TestLabel, MSU_dec_values, 1, 'XCrit', 'fpr', 'Ycrit', 'fnr');
AUC
figure
plot(X,Y)
% set(gca, 'XTick', [0.0001 : 0.1 : 10])
% axis([0 10 0 1])
xlabel('False positive rate')
ylabel('False negative rate')
%title('ROC for Classification by Logistic Regression')
for i = 1 : size(X, 1),
if X(i) == Y(i),
fprintf('X: %f Y: %f \n', X(i), Y(i));
end
end
% auto find parameter numFrames= 30
[ resultAuto ] = findParameter( MSU_TrainLabel, MSU_TrainData, MSU_TestLabel, MSU_TestData, numFrames, 'A' );
% auto find parameter Fine
[ resultAutoFine ] = findParameterFine( MSU_TrainLabel, MSU_TrainData, MSU_TestLabel, MSU_TestData, numFrames, 0, 0, 0, 0 );
%% case2 - only CASIA Features
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- REPLAY
% JPG replay
CASIA_TrainData = [featuresCASIA.trainGenuine; featuresCASIA.trainReplay; ];
CASIA_TestData = [featuresCASIA.testGenuine; featuresCASIA.testReplay; ];
% Label replay
CASIA_TrainLabel = [1*ones(size(featuresCASIA.trainGenuine, 1), 1); -1*ones(size(featuresCASIA.trainReplay, 1), 1)];
CASIA_TestLabel = [1*ones(size(featuresCASIA.testGenuine, 1), 1); -1*ones(size(featuresCASIA.testReplay, 1), 1)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- PRINTED
% JPG print
CASIA_TrainData = [featuresCASIA.trainGenuine; featuresCASIA.trainPrinted];
CASIA_TestData = [featuresCASIA.testGenuine; featuresCASIA.testPrinted];
% Label print
CASIA_TrainLabel = [ones(size(featuresCASIA.trainGenuine, 1), 1); -1*ones(size(featuresCASIA.trainPrinted, 1), 1)];
CASIA_TestLabel = [ones(size(featuresCASIA.testGenuine, 1), 1); -1*ones(size(featuresCASIA.testPrinted, 1), 1)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- REPLAY + PRINTED
% JPG replay + print
CASIA_TrainData = [featuresCASIA.trainGenuine; featuresCASIA.trainReplay; featuresCASIA.trainPrinted];
CASIA_TestData = [featuresCASIA.testGenuine; featuresCASIA.testReplay; featuresCASIA.testPrinted];
% Label replay + print
CASIA_TrainLabel = [ones(size(featuresCASIA.trainGenuine, 1), 1); -1*ones(size(featuresCASIA.trainReplay, 1), 1); -1*ones(size(featuresCASIA.trainPrinted, 1), 1)];
CASIA_TestLabel = [ones(size(featuresCASIA.testGenuine, 1), 1); -1*ones(size(featuresCASIA.testReplay, 1), 1); -1*ones(size(featuresCASIA.testPrinted, 1), 1)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% jpg (dis, glcm, lbp)
CASIA_TrainDistortion = CASIA_TrainData(:, 1:115);
CASIA_TrainGlcm = CASIA_TrainData(:, 116:203);
CASIA_TrainLBP = CASIA_TrainData(:, 204:1036);
CASIA_TestDistortion = CASIA_TestData(:, 1:115);
CASIA_TestGlcm = CASIA_TestData(:, 116:203);
CASIA_TestLBP = CASIA_TestData(:, 204:1036);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% distortion features normalization
[CASIA_TrainDistortion CASIA_FeaturesMu CASIA_FeaturesStddev ]= featureNormalize(CASIA_TrainDistortion);
CASIA_TestDistortion = featureNormalizeForTesting(CASIA_TestDistortion, CASIA_FeaturesMu, CASIA_FeaturesStddev);
% glcm features normalization
[CASIA_TrainGlcm CASIA_FeaturesMu CASIA_FeaturesStddev ]= featureNormalize(CASIA_TrainGlcm);
CASIA_TestGlcm = featureNormalizeForTesting(CASIA_TestGlcm, CASIA_FeaturesMu, CASIA_FeaturesStddev);
% LBP normalization
[CASIA_TrainLBP CASIA_FeaturesMu CASIA_FeaturesStddev ]= featureNormalize(CASIA_TrainLBP);
CASIA_TestLBP = featureNormalizeForTesting(CASIA_TestLBP, CASIA_FeaturesMu, CASIA_FeaturesStddev);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1. JPG: dis + glcm //
CASIA_TrainData = [CASIA_TrainDistortion CASIA_TrainGlcm CASIA_TrainLBP];
CASIA_TestData = [CASIA_TestDistortion CASIA_TestGlcm CASIA_TestLBP];
% linear SVM
% Accuracy = 79.5222% (7157/9000) (classification) [ cut 25´Â ´õ ¶³¾îÁü], [glcm normalization, 82.9778%]
CASIA_Model_1 = svmtrain(CASIA_TrainLabel, CASIA_TrainData, '-c 1 -g 0.09 -t 2');
[CASIA_predict_label_1, CASIA_accuracy_1, CASIA_dec_values1] = svmpredict(CASIA_TestLabel, CASIA_TestData, CASIA_Model_1);
CASIA_Model_2 = svmtrain(CASIA_TrainLabel, CASIA_TrainData, '-c 50 -g 0.0028125 -t 2');
[CASIA_predict_label_2, CASIA_accuracy_2, CASIA_dec_values2] = svmpredict(CASIA_TestLabel, CASIA_TestData, CASIA_Model_2);
CASIA_Model_3 = svmtrain(CASIA_TrainLabel, CASIA_TrainData, '-c 10 -g 0.0091 -t 2');
[CASIA_predict_label_3, CASIA_accuracy_3, CASIA_dec_values3] = svmpredict(CASIA_TestLabel, CASIA_TestData, CASIA_Model_3);
CASIA_Model_4 = svmtrain(CASIA_TrainLabel, CASIA_TrainData, '-c 32 -g 0.1250 -t 2');
[CASIA_predict_label_4, CASIA_accuracy_4, CASIA_dec_values4] = svmpredict(CASIA_TestLabel, CASIA_TestData, CASIA_Model_4);
CASIA_Model_5 = svmtrain(CASIA_TrainLabel, CASIA_TrainData, '-c 40 -g 0.0098425 -t 2');
[CASIA_predict_label_5, CASIA_accuracy_5, CASIA_dec_values5] = svmpredict(CASIA_TestLabel, CASIA_TestData, CASIA_Model_5);
% nogada
CASIA_Model_5 = svmtrain(CASIA_TrainLabel, CASIA_TrainData);
[CASIA_predict_label_5, CASIA_accuracy_5, CASIA_dec_values5] = svmpredict(CASIA_TestLabel, CASIA_TestData, CASIA_Model_5);
CASIA_Model_Print = svmtrain(CASIA_TrainLabel, CASIA_TrainData, '-c 16 -g 0.000244140625000000');
[CASIA_predict_label_Print, CASIA_accuracy_Print, CASIA_dec_valuesPrint] = svmpredict(CASIA_TestLabel, CASIA_TestData, CASIA_Model_Print);
% HTER numFrames = 30
CASIA_predict_label = CASIA_predict_label_Print;
[acc HTER ]= getHTER( CASIA_predict_label, CASIA_TestLabel, numFrames);
% ROC
CASIA_dec_values = CASIA_dec_values5;
[X, Y, T, AUC] = perfcurve(CASIA_TestLabel, CASIA_dec_values, 1);
AUC
figure
plot(X,Y)
% set(gca, 'XTick', [0.0001 : 0.1 : 10])
% axis([0 10 0 1])
xlabel('False positive rate')
ylabel('True positive rate')
%title('ROC for Classification by Logistic Regression')
for i = 1 : size(X, 1),
if X(i) == 0.01,
fprintf('Y: %f \n', Y(i));
end
end
%ERR
CASIA_dec_values = CASIA_dec_values5;
[X, Y, T, AUC] = perfcurve(CASIA_TestLabel, CASIA_dec_values, 1, 'XCrit', 'fpr', 'Ycrit', 'fnr');
AUC
figure
plot(X,Y)
% set(gca, 'XTick', [0.0001 : 0.1 : 10])
% axis([0 10 0 1])
xlabel('False positive rate')
ylabel('False negative rate')
%title('ROC for Classification by Logistic Regression')
for i = 1 : size(X, 1),
if X(i) == Y(i),
fprintf('X: %f Y: %f \n', X(i), Y(i));
end
end
% auto find parameter
[ resultAuto ] = findParameter( CASIA_TrainLabel, CASIA_TrainData, CASIA_TestLabel, CASIA_TestData, numFrames, 'A' );
% auto find parameter Fine
[ resultAutoFine ] = findParameterFine( CASIA_TrainLabel, CASIA_TrainData, CASIA_TestLabel, CASIA_TestData, numFrames, 0, 0, 0, 0 );
%% case 3 - only Idiap Features
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- REPLAY
% JPG replay
Idiap_TrainData = [featuresIdiap.trainGenuine; featuresIdiap.trainReplay; ];
Idiap_TestData = [featuresIdiap.testGenuine; featuresIdiap.testReplay; ];
% Label replay
Idiap_TrainLabel = [1*ones(size(featuresIdiap.trainGenuine, 1), 1); -1*ones(size(featuresIdiap.trainReplay, 1), 1)];
Idiap_TestLabel = [1*ones(size(featuresIdiap.testGenuine, 1), 1); -1*ones(size(featuresIdiap.testReplay, 1), 1)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- PRINTED
% JPG print
Idiap_TrainData = [featuresIdiap.trainGenuine; featuresIdiap.trainPrinted];
Idiap_TestData = [featuresIdiap.testGenuine; featuresIdiap.testPrinted];
% Label print
Idiap_TrainLabel = [ones(size(featuresIdiap.trainGenuine, 1), 1); -1*ones(size(featuresIdiap.trainPrinted, 1), 1)];
Idiap_TestLabel = [ones(size(featuresIdiap.testGenuine, 1), 1); -1*ones(size(featuresIdiap.testPrinted, 1), 1)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- REPLAY + PRINTED
% JPG replay + print
Idiap_TrainData = [featuresIdiap.trainGenuine; featuresIdiap.trainReplay; featuresIdiap.trainPrinted];
Idiap_TestData = [featuresIdiap.testGenuine; featuresIdiap.testReplay; featuresIdiap.testPrinted];
% Label replay + print
Idiap_TrainLabel = [ones(size(featuresIdiap.trainGenuine, 1), 1); -1*ones(size(featuresIdiap.trainReplay, 1), 1); -1*ones(size(featuresIdiap.trainPrinted, 1), 1)];
Idiap_TestLabel = [ones(size(featuresIdiap.testGenuine, 1), 1); -1*ones(size(featuresIdiap.testReplay, 1), 1); -1*ones(size(featuresIdiap.testPrinted, 1), 1)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% jpg (dis, glcm, lbp)
Idiap_TrainDistortion = Idiap_TrainData(:, 1:115);
Idiap_TrainGlcm = Idiap_TrainData(:, 116:203);
Idiap_TrainLBP = Idiap_TrainData(:, 204:1036);
Idiap_TestDistortion = Idiap_TestData(:, 1:115);
Idiap_TestGlcm = Idiap_TestData(:, 116:203);
Idiap_TestLBP = Idiap_TestData(:, 204:1036);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% distortion features normalization
[Idiap_TrainDistortion Idiap_FeaturesMu Idiap_FeaturesStddev ]= featureNormalize(Idiap_TrainDistortion);
Idiap_TestDistortion = featureNormalizeForTesting(Idiap_TestDistortion, Idiap_FeaturesMu, Idiap_FeaturesStddev);
% glcm features normalization
[Idiap_TrainGlcm Idiap_FeaturesMu Idiap_FeaturesStddev ]= featureNormalize(Idiap_TrainGlcm);
Idiap_TestGlcm = featureNormalizeForTesting(Idiap_TestGlcm, Idiap_FeaturesMu, Idiap_FeaturesStddev);
% LBP normalization
[Idiap_TrainLBP Idiap_FeaturesMu Idiap_FeaturesStddev ]= featureNormalize(Idiap_TrainLBP);
Idiap_TestLBP = featureNormalizeForTesting(Idiap_TestLBP, Idiap_FeaturesMu, Idiap_FeaturesStddev);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1. JPG: dis + glcm //
Idiap_TrainData = [Idiap_TrainDistortion Idiap_TrainGlcm Idiap_TrainLBP];
Idiap_TestData = [Idiap_TestDistortion Idiap_TestGlcm Idiap_TestLBP];
% linear SVM
% Idiap_Model_1 = svmtrain(Idiap_TrainLabel, Idiap_TrainData, '-c 2 -g 0.0313 -t 2');
% [Idiap_predict_label_1, Idiap_accuracy_1, Idiap_dec_values1] = svmpredict(Idiap_TestLabel, Idiap_TestData, Idiap_Model_1);
%
% Idiap_Model_2 = svmtrain(Idiap_TrainLabel, Idiap_TrainData, '-c 32 -g 0.0313 -t 2');
% [Idiap_predict_label_2, Idiap_accuracy_2, Idiap_dec_values2] = svmpredict(Idiap_TestLabel, Idiap_TestData, Idiap_Model_2);
%
% Idiap_Model_3 = svmtrain(Idiap_TrainLabel, Idiap_TrainData, '-c 8 -g 0.0078125 -t 2');
% [Idiap_predict_label_3, Idiap_accuracy_3, Idiap_dec_values3] = svmpredict(Idiap_TestLabel, Idiap_TestData, Idiap_Model_3);
%
% Idiap_Model_4 = svmtrain(Idiap_TrainLabel, Idiap_TrainData, '-c 0.125 -g 0.0078125 -t 2');
% [Idiap_predict_label_4, Idiap_accuracy_4, Idiap_dec_values4] = svmpredict(Idiap_TestLabel, Idiap_TestData, Idiap_Model_4);
%
% Idiap_Model_5 = svmtrain(Idiap_TrainLabel, Idiap_TrainData, '-c 0.125 -g 0.0038125 -t 2');
% [Idiap_predict_label_5, Idiap_accuracy_5, Idiap_dec_values5] = svmpredict(Idiap_TestLabel, Idiap_TestData, Idiap_Model_5);
%
Idiap_Model_6 = svmtrain(Idiap_TrainLabel, Idiap_TrainData, '-c 0.225 -g 0.00048125 -t 2');
[Idiap_predict_label_6, Idiap_accuracy_6, Idiap_dec_values6] = svmpredict(Idiap_TestLabel, Idiap_TestData, Idiap_Model_6);
%
Idiap_Model_5 = svmtrain(Idiap_TrainLabel, Idiap_TrainData, '-c 0.250000000000000 -g 6.10351562500000e-05');
[Idiap_predict_label_5, Idiap_accuracy_5, Idiap_dec_values5] = svmpredict(Idiap_TestLabel, Idiap_TestData, Idiap_Model_5);
% HTER
Idiap_predict_label = Idiap_predict_label_5;
[acc HTER ] = getHTER( Idiap_predict_label, Idiap_TestLabel, numFrames);
% ROC
Idiap_dec_values = Idiap_dec_values5;
[X, Y, T, AUC] = perfcurve(Idiap_TestLabel, Idiap_dec_values, 1);
AUC
figure
plot(X,Y)
% set(gca, 'XTick', [0.0001 : 0.1 : 10])
% axis([0 10 0 1])
xlabel('False positive rate')
ylabel('True positive rate')
%title('ROC for Classification by Logistic Regression')
for i = 1 : size(X, 1),
if X(i) == 0.01,
fprintf('Y: %f \n', Y(i));
end
end
%ERR
Idiap_dec_values = Idiap_dec_values5;
[X, Y, T, AUC] = perfcurve(Idiap_TestLabel, Idiap_dec_values, 1, 'XCrit', 'fpr', 'Ycrit', 'fnr');
AUC
figure
plot(X,Y)
% set(gca, 'XTick', [0.0001 : 0.1 : 10])
% axis([0 10 0 1])
xlabel('False positive rate')
ylabel('False negative rate')
%title('ROC for Classification by Logistic Regression')
for i = 1 : size(X, 1),
if X(i) == Y(i),
fprintf('X: %f Y: %f \n', X(i), Y(i));
end
end
% auto find parameter
[ resultAuto ] = findParameter( Idiap_TrainLabel, Idiap_TrainData, Idiap_TestLabel, Idiap_TestData, numFrames, 'A' );
% auto find parameter Fine
[ resultAutoFine ] = findParameterFine( Idiap_TrainLabel, Idiap_TrainData, Idiap_TestLabel, Idiap_TestData, numFrames, 0, 0, 0, 0 );