⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dominantsets.m

📁 Dominant-set聚类算法
💻 M
字号:
NumCM = 5;
for CMth = 1:NumCM
    fs = 0; label = 0; ratio = 0;
    str = ['E:\database\KDD99\Clustering\ClusteringMachine',num2str(CMth),'\AMofCM_One.mat'];
    load(str);
    [NumSamplesInAM,M] = size(AM);

    NumInEachLabel = [1000,1500,1000,1000,52];
%     NumInEachLabel = [775,1500,777];
    sampleindex = 1:NumSamplesInAM;
    border(1) = 0;
    clusterth = 1;
    epsilong = 1e-6;

    while (clusterth<=200)
        [x,fx] = EGT(AM);    
        dominantset = find(x>1e-10);
        lengthdominantset = length(dominantset);
        outputDS = [];  
    
        if ((lengthdominantset<sum(NumInEachLabel)/100)||(length(x)<=10))
            outputDS = find(sampleindex>0);
            str = ['E:\database\KDD99\Clustering\ClusteringMachine',num2str(CMth),'\Noncluster.txt'];
            fid = fopen(str,'a+');
            fprintf(fid,'%i\n',outputDS');
            fclose(fid);
            break;
        else
            j = 1;
            for i = 1:NumSamplesInAM
                if(sampleindex(i)==dominantset(j))
                    outputDS(j) = i;
                    sampleindex(i) = 0;
                    j = j+1;
                    if (j>lengthdominantset)
                        break;
                    end
                end
            end
            nonzero = find(sampleindex>0);
            sampleindex(nonzero) = 1:length(nonzero);
        
%             for i = 1:5
            for i = 1:3
                border(i+1) = border(i) + NumInEachLabel(i); 
            end
%             for i = 1:5
            for i = 1:3
                n(i) = length(find((dominantset>border(i))&(dominantset<=border(i+1))));
            end
            n                
            ICQ = (n/lengthdominantset).*(n./NumInEachLabel); % Indicator of the quality of cluster
            [v,l] = max(ICQ);
            NumInEachLabel = NumInEachLabel - n;
            NumInEachLabel(find(NumInEachLabel==0)) = epsilong;
        
            if (sum(ICQ)<ICQ(l)*1.25)        % A good cluster
                str = ['E:\database\KDD99\Clustering\ClusteringMachine',num2str(CMth),'\cluster',num2str(clusterth),'.txt']; 
                fid = fopen(str,'w');
                temp = x(dominantset)';
                fprintf(fid,'%i,%.4d\n',[outputDS;temp]);
                fclose(fid);
                fs(clusterth) = fx;
                label(clusterth) = l;
                ratio(clusterth) = (lengthdominantset - 1)/(lengthdominantset + 1);
                clusterth = clusterth + 1; 
            else
                str = ['E:\database\KDD99\Clustering\ClusteringMachine',num2str(CMth),'\Noncluster.txt'];
                fid = fopen(str,'a+');
                fprintf(fid,'%i\n',outputDS');
                fclose(fid);
            end
            
            other = find(x<=0);        
            AM = AM(other,other);    
        end
    end
    str = ['E:\database\KDD99\Clustering\ClusteringMachine',num2str(CMth),'\ClustersCharacters.txt'];
    fid = fopen(str,'w');
    fprintf(fid,'%.4d,%.4d,%i\n',[fs;ratio;label]);
    fclose(fid);
    clusterth
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -