📄 yf_fpcmc1.m
字号:
function [V, U, T, E] = Yf_FPCMC1 (X, c, options, init_V)
%Yf_FPCMC1: Fuzzy-Possibilistic C-Means Clustering.
%
% [V, U, T, E] = Yf_FPCMC1 (X, c, options, inti_V)
% X: Input data (n by p)
% n: Number of feature vectors
% p: Length of each feature vector
% c: Number of clusters
% init_V: Initial cluster centers
% OPTIONS(1): Weighting exponent (m) (default: 2.0)
% OPTIONS(2): Typicality weight (eta) (default: 4.0)
% OPTIONS(3): Maximum number of iterations (default: 100)
% OPTIONS(4): Termination threshold (default: 1e-3)
% OPTIONS(5): Info display during iteration (default: 1)
% OPTIONS(6): Use provided init_V (default: 0)
%
% V: Cluster centers (c by p)
% U: Membership degrees (c by p)
% T: Typicality (Possibility) values (c by p)
% E: Termination measure values (max_iter by 1)
%
% Reference:
% [PalPB97] N. R. Pal, K. Pal and J. C. Bezdek, A mixed c-means
% clustering model, Proceedings of the Sixth IEEE International
% Conference on Fuzzy Systems, Vol. 1, pp. 11-21, Jul. 1997.
%
% Mahdi Amiri, June 20, 2003
% http://yashil.20m.com/
if nargin < 2,
error('Too few input arguments!');
end
if nargin > 4,
error('Too many input arguments!');
end
n = size(X, 1);
p = size(X, 2);
% Change the following to set default options
default_options = [2; % weighting exponent (m)
4; % typicality weight (eta)
100; % max. number of iteration
1e-3; % termination threshold
1; % info display during iteration
0]; % use provided init_V
if nargin == 2,
options = default_options;
else
% If "options" is not fully specified, pad it with default values.
if length(options) < 6,
tmp = default_options;
tmp(1:length(options)) = options;
options = tmp;
end
% If some entries of "options" are nan's, replace them with defaults.
nan_index = find(isnan(options)==1);
options(nan_index) = default_options(nan_index);
end
m = options(1); % Weighting exponent
eta = options(2); % Typicality weight (eta)
max_iter = options(3); % Max. iteration
term_thr = options(4); % Termination threshold
display = options(5); % Display info or not
use_init_V = options(6); % use provided init_V
if m <= 1,
error('The weighting exponent should be greater than 1!');
end
E = zeros(max_iter, 1); % Array for termination measure values
if use_init_V,
V = init_V;
else
V = Yf_FPCMC1_InitV (c, p); % Initial cluster centers
end
%U = zeros (c, n);
%T = zeros (c, n);
% Main loop
for i = 1:max_iter,
[V, U, T, E(i)] = Yf_FPCMC1_Step (X, V, c, m, eta);
if display,
fprintf('Iteration count = %d, Termination measure value = %f\n', i, E(i));
end
% check termination condition
if E(i) <= term_thr, break; end,
end
iter_n = i; % Actual number of iterations
E(iter_n+1:max_iter) = [];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -