代码拉取完成,页面将自动刷新
function T = SpectralClustNg(K,N)
% Performs spectral K-means for ell samples specified by the kernel K
%
%INPUTS
% K = the kernel matrix
% N = the number of clusters desired
%
%OUTPUTS
% T = vector (Nr*1) containing, for each point, the index of the cluster he belongs to
% X = Matrix (Nr*N) containing the eigenvectors of L
% totsumD = Total sum of values of distances from each point to every centroid.
% Reference:
% - Dhillon, I., Guan Y and Kulis B., Kernel k-means, Spectral Clustering and Normalized Cuts,
% KKD'04, August 22-25, 2004, Seattle, Washinton, USA
invSqrtD = diag(1./sqrt(sum(K,1)));
L = invSqrtD*K*invSqrtD;
% Find the N largest eigenvectors of L
% [V,D] = eig(L);
% X = V(:,1:N);
% Method Mehrdad for faster eig
[X,D] = symeig(L, N);
% Normalization of X
Z = sqrt(sum(X.^2, 2));
% X = X ./ Z(:, ones(size(X,2), 1));
X = bsxfun(@rdivide,X,Z);
% Try to find N points that are orthogonal to initialize KKM and avoid
% randomness of the results
idxclusters = centroidortho2(X,N);
% Perform traditionnal k-means algorithm using previous initial points
[T a sumD D totsumD] = kmeans2(X,N,'Start',X(idxclusters,:),'Maxiter',500,'EmptyAction','singleton','Display','final');
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。