-
Notifications
You must be signed in to change notification settings - Fork 0
/
RadiusReductionSVDD.m
46 lines (30 loc) · 958 Bytes
/
RadiusReductionSVDD.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
function R_star = RadiusReductionSVDD(Xtr, Ytr, alpha, Xts, Yts, kernel, param, Rsquared, treshold)
% RadiusReductionSVDD
% Usage: R_star = RadiusReductionSVDD(Xtr, Ytr, alpha, Xts, kernel, param, Rsquared, treshold)
% Xtr: training set
% Ytr: labels of training set
% alpha: lagrange multipliers of SVDD
% Xts: test set
% param: kernel parameter
% Rsquared: squared radius of the SVDD
% kernel: 'linear, 'gaussian', 'polynomial'
% treshold: percentage of FP to be achieved
maxiter = 1000;
i = 1;
Rsq = Rsquared;
while(i<maxiter)
Rsq = Rsq-10e-4;
y = SVDD_N1C_TEST(Xtr, Ytr, alpha, Xts, kernel, param, Rsq);
Y = [y Yts];
TN = sum(Y(:,1)==-1 & Y(:,2)==-1);
FN = sum(Y(:,1)==-1 & Y(:,2)==+1);
TP = sum(Y(:,1)==+1 & Y(:,2)==+1);
FP = sum(Y(:,1)==+1 & Y(:,2)==-1);
FPR=FP/N;
if(FPR<treshold)
R_star = Rsq;
break;
end
i=i+1;
disp(['Iteration --> ',num2str(i)])
end