-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathperformKmeans.m
59 lines (52 loc) · 2.32 KB
/
performKmeans.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
% function [answerclass,sizes] = performKmeans(resized_alpha, answerclass, sizes)
% if size(resized_alpha,1) <= 20
% t = getGlobalx(); % get counter
% sizes(1,t) = size(resized_alpha,1);
% answerclass(resized_alpha(:,1)) = t;
% setGlobalx(t+1);
% return;
% else
% alpha_idx1 = kmedoids(resized_alpha(:,2:129),2);
% resized_alpha1 = resized_alpha(find(alpha_idx1==1),:);
% resized_alpha2 = resized_alpha(find(alpha_idx1==2),:);
%
% [answerclass,sizes] = performKmeans(resized_alpha1, answerclass, sizes);
% [answerclass,sizes] = performKmeans(resized_alpha2, answerclass, sizes);
% end
% end
function [answerclass,sizes,centres] = performKmeans(resized_alpha, answerclass, sizes, c, centres)
if size(resized_alpha,1) <= 20
t = getGlobalx(); % get counter
sizes(1,t) = size(resized_alpha,1);
centres(t,:) = c;
answerclass(resized_alpha(:,1)) = t;
setGlobalx(t+1);
return;
else
[alpha_idx1,c] = kmedoids(resized_alpha(:,2:129),2);
resized_alpha1 = resized_alpha(find(alpha_idx1==1),:);
resized_alpha2 = resized_alpha(find(alpha_idx1==2),:);
[answerclass,sizes,centres] = performKmeans(resized_alpha1, answerclass, sizes, c(1,:), centres);
[answerclass,sizes,centres] = performKmeans(resized_alpha2, answerclass, sizes, c(2,:), centres);
end
end
% while(size(find(alpha_idx1==1),1)>20 | size(find(alpha_idx1==2),1)>20)
%
% if size(find(alpha_idx1==1),1)>20 & size(find(alpha_idx1==2),1)>20
% resized_alpha1 = resized_alpha(find(alpha_idx1==1),1);
% resized_alpha2 = resized_alpha(find(alpha_idx1==2),1);
% resized_alpha
% alpha_idx1 = kmedoids(resized_alpha,2,'Distance','spearman');
% elseif size(find(alpha_idx1==1),1)>20
% find(alpha_idx1==2)
% resized_alpha = resized_alpha(find(alpha_idx1==1),1);
% alpha_idx1 = kmedoids(resized_alpha,2,'Distance','spearman');
%
% elseif size(find(alpha_idx1==2),1)>20
% store alpha_idx1==1
% resized_alpha = resized_alpha(surafind(alpha_idx1==2),1);
% alpha_idx1 = kmedoids(resized_alpha,2,'Distance','spearman');
% else
% store both
% end
% end