-
Notifications
You must be signed in to change notification settings - Fork 1
/
computeMicroclusters.m
61 lines (56 loc) · 2.15 KB
/
computeMicroclusters.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% This is a demo for the PTA and PTGP algorithms. If you find the %
% code useful for your research,please cite the paper below. %
% %
% Dong Huang, Jian-Huang Lai, and Chang-Dong Wang. Robust ensemble %
% clustering using probability trajectories, IEEE Transactions on %
% Knowledge and Data Engineering, 2016, 28(5), pp.1312-1326. %
% %
% The code has been tested in Matlab R2014a and Matlab R2015a on a %
% workstation with Windows Server 2008 R2 64-bit. %
% %
% https://www.researchgate.net/publication/284259332 %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [newBaseCls, mClsLabels] = computeMicroclusters(baseCls)
%% Obtain the set of microclusters w.r.t. the clustering ensemble.
%% Get micro-clusters
[sortBaseCls, I] = sortrows(baseCls);
[uniqueBaseCls, uI] = unique(baseCls,'rows');
mClsLabels = zeros(numel(I),2); % micro-cluster labels
mClsLabels(:,1) = I;
for i = 1:numel(uI)
mClsLabels(I==uI(i), 2) = i;
end
flag_r2014a = 0;
for i = 1:size(mClsLabels,1)-1
if mClsLabels(i,2)~=0 && mClsLabels(i+1,2)==0
test = sortBaseCls(i,:)-sortBaseCls(i+1,:);
if sum(abs(test(:))) == 0
flag_r2014a = 1;
end
end
end
if flag_r2014a>0
tmp = mClsLabels(1,2);
for i = 2:numel(I)
if mClsLabels(i,2) ~= 0
tmp = mClsLabels(i,2);
else
mClsLabels(i,2) = tmp;
end
end
else
tmp = mClsLabels(end,2);
for i = (numel(I)-1):(-1):1
if mClsLabels(i,2) ~= 0
tmp = mClsLabels(i,2);
else
mClsLabels(i,2) = tmp;
end
end
end
%% Get the newBaseCls (represented by micro-clusters)
%%
newBaseCls = baseCls(uI,:);