20.01.2015 Views

njit-etd2003-081 - New Jersey Institute of Technology

njit-etd2003-081 - New Jersey Institute of Technology

njit-etd2003-081 - New Jersey Institute of Technology

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

298<br />

end<br />

[R,C]=size(Data);<br />

if length(TruelD)>0 & length(TruelD)—=R<br />

error('DOCLUSTERING number <strong>of</strong> labels does not match number <strong>of</strong> records');<br />

return<br />

end<br />

if k == 1<br />

RITrue=0 ;RIS elf=0 ;<br />

EstIndex=ones(R, 1);<br />

return<br />

end<br />

%Only want one cluster Well, ...OK<br />

%Hierarchical clustering - calculate distance/dissimilarity matrix<br />

if strncmp(Algorithm,'hier',4) == 1<br />

if Repetitions > 1, warning('Only performing one hierarchical clustering execution');end<br />

%Hier. is deterministic; no point in repeating it<br />

Repetitions = 1;<br />

%Next line does fast distance calculations as given by Peter Acklam, Oslo,<br />

www.math.uio.no/—jacklam<br />

distance=sqrt(sum(abs(repmat(permute(Data, [1 3 2]), [1 R 1]) -<br />

repmat(permute(Data, [3 1 2]), [R 1 1]))."2,3));<br />

distance=distance+diag(ones( 1 ,R).*Inf);<br />

end<br />

%Do the clustering<br />

for i =1:Repetitions<br />

InitCentres = ChooselnitialCentres(Data,k); %randomly choose starting point<br />

%(where needed)<br />

switch Algorithm<br />

case 'kmeans'<br />

Estlndex(i,:) = dcKMeans(Data,k,InitCentres)';<br />

case 'EM_spherical'<br />

[mix, index,likelihood]=dcEMGMM(Data, k, 'spherical', 1);<br />

Estlndex(i,:)=index';<br />

case 'EM_elliptical'<br />

[mix, index,likelihood]=dcEMGMM(Data, k, 'full', 1);<br />

EstIndex(i,:)=index';<br />

case {'hier_complete'}<br />

cluster = dcAgg(distance, 'complete', k);<br />

for j = 1:k<br />

EstIndex(i,cluster {j})=j ;<br />

end

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!