📄 clusang.m
字号:
% ---------------------------------------------------------------- % FUNCTION clusang.m CLUSterin algorithm, ANGle metric.% ---------------------------------------------------------------- % builds a block training set. % Usage: % cluster_centers = clusang(orig_cluster_centers, training set, precision);% % orig_cluster: matrix, each ROW is a cluster center.% training set: matrix, each ROW is a sample.% Precision = stopping criterion: If the maximum distance between the centers% of the clusters is less than precision, then stop;%% __________________________% Author: Vittorio Castelli% Copyright IBM T. J. Watson Research Center% January 27, 1995; Last modified: January 27, 1995function clCen = clusang(origCen, trSet,prec);learning_rate = 1;[m,n] = size(trSet);[k,n] = size(origCen);aaa = ones(1,n);dist = 1;n_dist = 32;clCen = origCen;count = 0;distance = zeros(1,n_dist);while dist > prec, oldCen=clCen; dist = trSet * clCen'; dist = dist'; [dist,ord] = sort(dist); ord = ord'; ord = ord(:,k); dist=0; for i=1:k, if(sum(ord==i)==0), fprintf(' %g',i) end m = mean((((ord==i)*aaa).*trSet)); clCen(i,:) = normalize(clCen(i,:)+m.*learning_rate); d_i = clCen(i,:)*oldCen(i,:)'; d_i = acos(d_i); dist=max(dist, d_i); end count = count+1; distance(count)= dist; if rem(count,n_dist)==0, if ceil(count/n_dist/2)-floor(count/n_dist/2) ==0, figure(2); else figure(1); end plot(distance,'+'); grid endendfprintf('\n');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -