-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetAllSegs.m
29 lines (26 loc) · 1.45 KB
/
getAllSegs.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% This is a demo for the LWEA and LWGP algorithms. If you find this %
% code useful for your research, please cite the paper below. %
% %
% Dong Huang, Chang-Dong Wang, and Jian-Huang Lai. %
% "Locally weighted ensemble clustering." %
% IEEE Transactions on Cybernetics, 2018, 48(5), pp.1460-1473. %
% %
% 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/316681928 %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [bcs, baseClsSegs] = getAllSegs(baseCls)
[N,M] = size(baseCls);
% n: the number of data points.
% M: the number of base clusterings.
% nCls: the number of clusters (in all base clusterings).
bcs = baseCls;
nClsOrig = max(bcs,[],1);
C = cumsum(nClsOrig);
bcs = bsxfun(@plus, bcs,[0 C(1:end-1)]);
nCls = nClsOrig(end)+C(end-1);
baseClsSegs=sparse(bcs(:),repmat([1:N]',1,M), 1,nCls,N);