-
Notifications
You must be signed in to change notification settings - Fork 0
/
outlier_algo_big
68 lines (48 loc) · 1.68 KB
/
outlier_algo_big
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
rng default;
global rrr;global gv;global m3;global uuu;
rrr =[];c2=[];uuu=[];cb=[];
%GMM
acca=[];data = m3;gh = 0:4:size(data,2)-2;yy=1:80;
for j = 1:size(data,2)
%x = data(:,gh(j)+1:gh(j+1));
x = data(:,j);acc = x;
AIC = zeros(1,20);
obj = cell(1,20);
for k = 1:20
obj{k} = fitgmdist(acc,k,'RegularizationValue',0.1);
AIC(k)= obj{k}.AIC;
end
[minAIC,numComponents] = min(AIC);yp = numComponents;
gm = fitgmdist(acc,yp,'RegularizationValue',0.1);
idx = cluster(gm,acc);
uv = unique(idx);n = histc(idx,uv);[m1,m2] = min(n);minmode = uv(m2);
acca = vertcat(acca,yy(find(idx==minmode)));
c1 = intersect(acca,yy(:,80-gv(j)+1:end));
lu = (length(acca)-length(c1))/length(acca);lu = lu*100;
c1 = length(c1)/length(yy(:,80-gv(j)+1:end));c1 = c1*100;
c2 = horzcat(c2,c1);cb = horzcat(cb,lu);
acca=[];
end
rrr = vertcat(rrr,c2);uuu = vertcat(uuu,cb);c2=[];cb=[];
acca=[];data = m3;gh = 0:4:size(data,2)-2;yy=1:80;
for j = 1:size(data,2)
%x = data(:,gh(j)+1:gh(j+1));
x = data(:,j);acc = x;
AIC = zeros(1,20);
obj = cell(1,20);
for k = 1:20
obj{k} = fitgmdist(acc,k,'RegularizationValue',0.1);
AIC(k)= obj{k}.AIC;
end
[minAIC,numComponents] = min(AIC);yp = numComponents;
gm = kmeans(acc,yp);
uv = unique(idx);n = histc(idx,uv);[m1,m2] = min(n);minmode = uv(m2);
acca = vertcat(acca,yy(find(idx==minmode)));
c1 = intersect(acca,yy(:,80-gv(j)+1:end));
lu = (length(acca)-length(c1))/length(acca) ;
lu = lu*100;
c1 = length(c1)/length(yy(:,80-gv(j)+1:end));c1 = c1*100;
c2 = horzcat(c2,c1);cb = horzcat(cb,lu);
acca=[];
end
rrr = vertcat(rrr,c2);uuu = vertcat(uuu,cb);c2=[];cb=[];