📄 example_iris_01.m
字号:
% ----------------------------------------------------------------------
% Example for testing IRID data clustering (fixed m and eta)
%
% ----------------------------------------------------------------------
% 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
load iris_1.dat; Xin = iris_1;
% ----------------------------------------------------------------------
cMarker = ['+' 'o' '*' '.' 'x' 's' 'd' '^' 'v' '>' '<' 'p' 'h'];
cColor = ['r' 'g' 'b' 'm' 'c' 'y' 'k' 'r' 'g' 'b' 'y' 'm' 'c'];
p = size (Xin, 2);
% ----------------------------------------------------------------------
% Plot input feature vectors
figure; hold on;
for f=1:p,
plot(Xin(:,f), cColor(f))
end
title ('Input feature vectors');
legend ('Sepal length','Sepal width','Petal length', 'Petal width');
xlabel ('Instance Num.');
ylabel ('Value (cm)');
% Iris-setosa : Xin (1:50, :)
% Iris-versicolor : Xin (51:100, :)
% Iris-virginica : Xin (101:150, :)
% ----------------------------------------------------------------------
% Number of clusters => nC
nC = 3;
% ----------------------------------------------------------------------
% Options
m = 2.0;
eta = 2.0;
term_thr = 0.00001;
max_iter = 100;
info_display = 0;
%init_V = Xin(1:nC, :);
%init_V = rand (nC, p);
init_V = [0.077057 0.408295 0.362549 0.997681;
0.928650 0.432343 0.231903 0.345886
0.341949 0.927887 0.713257 0.988281];
% ----------------------------------------------------------------------
% FCM
[V,U,E] = Yf_FCMC1 (Xin, nC, [m; max_iter; term_thr; info_display; 1], init_V);
V_FCM = V;
U_FCM = U;
E_FCM = E;
% ----------------------------------------------------------------------
% PCM
init_V_PCM = V_FCM;
%w = Yf_PCMC1_FindWeights1 (Xin, U, V, m, 1)
w = [.3 .15 .3];
[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;
E_PCM = E;
% ----------------------------------------------------------------------
% 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;
E_FPCM = E;
% ----------------------------------------------------------------------
% Display
m_eta = [m eta]
%V_FCM'
%V_PCM'
%V_FPCM'
%U_FCM'
%T_PCM'
%U_FPCM'
%T_FPCM'
Iter_FCM = length (E_FCM);
Iter_PCM = length (E_PCM);
Iter_FPCM = length (E_FPCM);
Iter = [Iter_FCM Iter_PCM Iter_FPCM]
ResubE_FCM = Tmpf_FindResubErrorIris1 (U_FCM);
ResubE_PCM = Tmpf_FindResubErrorIris1 (T_PCM);
ResubE_FPCM_U = Tmpf_FindResubErrorIris1 (U_FPCM);
ResubE_FPCM_T = Tmpf_FindResubErrorIris1 (T_FPCM);
ResubE = [ResubE_FCM ResubE_PCM ResubE_FPCM_U ResubE_FPCM_T]
% ----------------------------------------------------------------------
% Plot termination measure values
figure; hold on;
subplot(3,1,1); plot(E_FCM,'.-');
title ('Termination measure (FCM)');
subplot(3,1,2); plot(E_PCM,'.-');
title ('Termination measure (PCM)');
subplot(3,1,3); plot(E_FPCM,'.-');
title ('Termination measure (FPCM)');
xlabel ('Iteration num.');
ylabel ('Termination measure value');
% ----------------------------------------------------------------------
% Plot membership functions
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
figure; hold on;
subplot (nC, 1, 1)
plot (T_PCM(1, :), cColor(1))
title ('Membership functions (PCM)');
for c = 2:nC
subplot (nC, 1, c)
plot (T_PCM(c, :), cColor(c))
end
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
% ----------------------------------------------------------------------
% ----------------------------------------------------------------------
% ----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -