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

📄 example_yf_fpcmc1_01_.m

📁 模糊C均值聚类的一个参考材料,做模糊聚类是用的一个程序
💻 M
字号:
% ----------------------------------------------------------------------
% Example for testing Yf_FPCMC1
% 
% ----------------------------------------------------------------------
% 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 = 2;

% ----------------------------------------------------------------------
% Options
m = 2.0;
term_thr = 0.00001;
eta = 2.0;
max_iter = 100;
info_display = 1;

%init_V = Xin(1:nC, :);
init_V = [0.08 0.36; 0.41 0.99];

% ----------------------------------------------------------------------
% FCM
[V,U,E] = Yf_FCMC1 (Xin, nC, [m; max_iter; term_thr; info_display; 1], init_V);

V_FCM = V
U_FCM = U;

% ----------------------------------------------------------------------
% PCM
init_V_PCM = V_FCM;
w = Yf_PCMC1_FindWeights1 (Xin, U, V, m, 1);
[V,T,E] = Yf_PCMC1 (Xin, nC, w, [m; max_iter; term_thr; info_display; 1], init_V_PCM);

V_PCM = V
T_PCM = T;

% ----------------------------------------------------------------------
% FPCM
[V,U,T,E] = Yf_FPCMC1 (Xin, nC, [m; eta; max_iter; term_thr; info_display; 1], init_V);

V_FPCM = V
U_FPCM = U;
T_FPCM = T;

% ----------------------------------------------------------------------
% Display
m
eta

V_FCM'
V_PCM'
V_FPCM'

U_FCM'
T_PCM'
U_FPCM'
T_FPCM'

% ----------------------------------------------------------------------
% Plot termination measure values
figure;
plot(E);
title ('Termination measure (FPCM)');
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;
maxU = max(U);
for c = 1:nC
    index_c = find(U(c, :) == maxU);

    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 (FPCM)');

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 (U(1, :), cColor(1))
title ('Membership functions (FPCM)');
for c = 2:nC
    subplot (nC, 1, c)
    plot (U(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 + -