资源简介

可以用的经典密度聚类算法实例,

资源截图

代码片段和文件信息

function [class] = Dbscan( Xkeps )
[mn]=size(X);
class=zeros(1m);
clusterId=1;
X=[class‘X];
n=n+1;

for i=1:m
  if X(i1)==0
  X=expandcluster(iXclusterIdepskn);
  if X(i1)==-1  % if is noisekeep the clusterId not increasing 
  clusterId=clusterId-1;
  end
  clusterId=clusterId+1;
  end
end
clusterId=clusterId-1;
% disp(‘clusterNum:‘);
% disp(clusterId);
class=X(:1)‘;
end

function [X]=expandcluster(indexXclusterIdepskn)
   Di=dist(X(index(2:n))X(:(2:n)));
   D=find(Di   if length(D)    X(index1)=-1;%noise
   return
   else
   for i=1:length(D)
       if(X(D(i)1)==0)
       X(D(i)1)=clusterId;
       end
   end
   end
   D(1)=[];  
  
while ~isempty(D)
   Di=dist(X(D(1)(2:n))X(:(2:n)));
   Result=find(Di   if length(Result)>=k
       for t=1:length(Result) 
         if X(Result(t)1)==0||X(Result(t)1)==-1
            if X(Result(t)1)==0
               D(length(D)+1)=Result(t);
            end
            X(Result(t)1)=clusterId;
         end
       end
   end
       D(1)=[];   
end

end


function [Di]=dist(ix)
[mn]=size(x);
Di=sqrt(sum((((ones(m1)*i)-x).^2)‘));
if n==1
    Di=abs((ones(m1)*i-x))‘;
end
end



 



 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        1251  2014-03-21 21:46  Dbscan.m

评论

共有 条评论