资源简介

本资源是ISODATA聚类算法的matlab代码,其中包括isodata.m(ISODATA算法代码,其中包括了合并分裂等一系列子函数)、provaisodata.m(算法实例调用代码)和dades.mat(存放实例数据变量的文件)三个文件,并且每个函数都有详细的中文注释,而非原来的西班牙语注释。 ISODATA算法是在k-均值算法的基础上,增加对聚类结果的“合并”和“分裂”两个操作,并设定算法运行控制参数的一种聚类算法。全称:Iterative Selforganizing Data Analysis Techniques Algorithm 即:迭代自组织数据分析算法。 “合并”操作:当聚类结果某一类中样本数太少,或两个类间的距离太近时,进行合并。“分裂”操作: 当聚类结果某一类中样本某个特征类内方差太大,将该类进行分裂。

资源截图

代码片段和文件信息

function [Z Xcluster Ycluster A cluster] = isodata(X Y k L I ON OC OS NO min);
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  函数参数信息  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
s=size(X);
s=s(2);
cluster=zeros(1s); % 临时空间的内部检查
iter=0;
final=0;
vuelve3=0;
A=1;     % 初始化它的第一例
primeravez=1;   % 没有要求的参数修改

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  1.初始化中心  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Z= inicializa_centros(X Y A);


%%%%%%%%%%%%%%%%%%%%%%%%
%  主要方案  %
%%%%%%%%%%%%%%%%%%%%%%%%

while final==0   %启动循环迭代。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  2.设置的参数值  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
    if primeravez==0
if vuelve3==0
            [Ltemp Itemp ktemp ONtemp OCtemp OStemp]=parametros(L I k ON OC OS iter);
        end;
    end;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  3.计算和分配每个坐标最近的(X,Y)  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    primeravez=0;
vuelve3=1;
for i=1:s
        cluster(i)=cercano(X(i) Y(i) Z A);
end;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  4.删除群集  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 函数可以减少我们(如果需要)的聚类中心数目和发现。
    [Z A cluster]=eliminar(A cluster Z X Y ON);
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  5.更新群集中心  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Z=recalcula(cluster X Y A Z);
    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  6.最后,分裂或合并  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if (iter==I)
        final=1;
        next=0;
else
        next=decide78(iter k A);
    end;


%%%%%%%%%%%%%%%
%  7.分裂  %
%%%%%%%%%%%%%%%
if next==1
        next=2;
        hubo_division=0;
        A2=A;
       divide=0;
        % 分散的集群,全局分散
        % Y的顺序分别为最大分散组件变量y的分散。
        
        [Di D STM]= dispersion(X Y Z cluster A);

        % 满足条件的各组进行分裂
i=0;    % 按条件作出分裂和迭代。                         
while (hubo_division==0) & (i < A)      % 如果由于某种...                                     
    i=i+1;                                                                                      
    index=find(cluster==i); % index显示群集的值分区      
    sindex=size(index);                                                                         
    sindex=sindex(2);                                                                           
    if  (STM(i)>OS) & (  ((Di(i1)>D(1)) & (Di(i2)>D(2)) & (sindex>(2*(ON+1)))) | (A<=(k/2)) ) 
        hubo_division=1;                                                                        
        next=1;                                                                                 
        [Z cluster]=dividir(STM A cluster Z i (A+1) X Y);    % 分裂.                 
        A=A+1;  % 表示一个新的分组。                                      
        iter=iter+1;                                                                      

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        935  2010-04-18 22:45  provaisodata.m

     文件       4512  2004-06-15 16:22  dades.mat

     文件      16043  2010-04-19 11:11  isodata.m

----------- ---------  ---------- -----  ----

                21490                    3


评论

共有 条评论