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

📄 example_yf_pcmc1_01_.m

📁 模糊C均值聚类的一个参考材料,做模糊聚类是用的一个程序
💻 M
字号:
% ----------------------------------------------------------------------
% Example for testing Yf_PCMC1
% 
% ----------------------------------------------------------------------
% Written By: Mahdi Amiri.
% E-Mail: yashil1@yahoo.com
% Homepage: http://yashil.20m.com/
% June 2003
% ----------------------------------------------------------------------

% ----------------------------------------------------------------------
% Clean up
clc;
clear all;
close all;

% ----------------------------------------------------------------------
% Input data => Xin

Xin = Yf_SampleClusteringDataSets1 (30);
%Xin = Yf_SampleClusteringDataSets1 (11);
%Xin = Yf_SampleClusteringDataSets1 (12);
%load fcmdata.dat; Xin = fcmdata;

% ----------------------------------------------------------------------
% Plot input feature vectors
figure; plot(Xin(:,1),Xin(:,2),'o')
title ('Input feature vectors');

% ----------------------------------------------------------------------
% Number of clusters => nC
nC = 3;

% ----------------------------------------------------------------------
% Options
m = 2.0;
term_thr = 0.001;

% ----------------------------------------------------------------------
% Find initial c-partition of X uing FCM clustering
% This is necessary for calculating cluster weights
init_V = Xin(1:nC, :);
[V,U,E] = Yf_FCMC1 (Xin, nC, [m; 100; term_thr; 1; 1], init_V);

% ----------------------------------------------------------------------
% Inits for PCM
init_V = V;
w = Yf_PCMC1_FindWeights1 (Xin, U, V, m, 1);

% ----------------------------------------------------------------------
% Display
w
V_FCM = V
U_FCM = U;

% ----------------------------------------------------------------------
% Call main function
[V,T,E] = Yf_PCMC1 (Xin, nC, w, [m; 100; term_thr; 1; 1], init_V);

% ----------------------------------------------------------------------
% Display
V

% ----------------------------------------------------------------------
% Plot termination measure values
figure;
plot(E);
title ('Termination measure (PCM)');
xlabel ('Iteration num.');
ylabel ('Termination measure value');

% ----------------------------------------------------------------------
cMarker = ['+' 'o' '*' '.' 'x' 's' 'd' '^' 'v' '>' '<' 'p' 'h'];
cColor =  ['r' 'g' 'b' 'm' 'c' 'y' 'k' 'r' 'g' 'b' 'y' 'm' 'c'];

% ----------------------------------------------------------------------
% Plot clustered feature vectors
figure;
maxT = max(T);
for c = 1:nC
    index_c = find(T(c, :) == maxT);

    line(Xin(index_c, 1), Xin(index_c, 2), 'linestyle',...
        'none','marker', cMarker(c), 'color', cColor(c));
    
    hold on
    plot(V(c,1),V(c,2),['k' cMarker(c)],'markersize',15,'LineWidth',2)
end
title ('Clustered feature vectors (PCM)');

figure;
maxU = max(U_FCM);
for c = 1:nC
    index_c = find(U_FCM(c, :) == maxU);

    line(Xin(index_c, 1), Xin(index_c, 2), 'linestyle',...
        'none','marker', cMarker(c), 'color', cColor(c));
    
    hold on
    plot(V_FCM(c,1),V_FCM(c,2),['k' cMarker(c)],'markersize',15,'LineWidth',2)
end
title ('Clustered feature vectors (FCM)');

% ----------------------------------------------------------------------
% Plot membership functions
figure; hold on;
subplot (nC, 1, 1)
plot (T(1, :), cColor(1))
title ('Membership functions (PCM)');
for c = 2:nC
    subplot (nC, 1, c)
    plot (T(c, :), cColor(c))
end

figure; hold on;
subplot (nC, 1, 1)
plot (U_FCM(1, :), cColor(1))
title ('Membership functions (FCM)');
for c = 2:nC
    subplot (nC, 1, c)
    plot (U_FCM(c, :), cColor(c))
end

% ----------------------------------------------------------------------
% ----------------------------------------------------------------------
% ----------------------------------------------------------------------

⌨️ 快捷键说明

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