% General Entropy based Possibilistic Fuzzy C-Means (GEPFCM)-Relaxed.
% Note: GEPFCM is a generalized entropy based form of PFCM.
% In GEPFCM, the distance ||Xj-Vi||A is replaced with arbitrary functions
% fFCM,f1PCM f1E, f2E and f2PCM of ||Xj-Vi||A.
% The function fFCM can be chosen such that it be nonzero for all x.
% This choice will remove the problem of FCM and PFCM when ||Xj-Vi||A=0
% and membership grades uij become undetermined. Note that by changing
% values of cFCM, cPCM, c1E and c2E the GEPFCM can be changed into
% FCM, PCM and PFCM. More over, by changing this coefficients,
% importance of memberships, typicalities and entropy can be changed.
clear all
clc
load Data1
N=length(yd(1,:));
D=length(yd(:,1));
e=0.00001;
cFCM=1;
cPCM=1;
c1E=1;
c2E=1;
eta=2;
m=2;
% C=2;
KF=1;
% ruopt=10;
Ti=1000;
% FCM algorithm
% Using results of the FCM, initial cluster centers (prototypes),
% intial partition matrix and values of gama for PFCM are obtained.
% Applying PFCM, new U,V and gama matrices are obtained by which
% GPFCM algorithm is initialized.
% Calculating covariance norm matrix, A.
sumYD=0;
for j=1:N
sumYD=sumYD+yd(:,j);
end
YDave=sumYD/N;
Cov=0;
for j=1:N
Cov=Cov+(yd(:,j)-YDave)*(yd(:,j)-YDave)';
end
Cov=Cov/N;
A=inv(Cov);
% A=eye(D,D);
% FCM.
U=rand(C,N);
% load U
Norm(1)=0;
for j=1:N
for i=1:C
Norm(1)=Norm(1)+U(i,j)^2;
end
end
Norm(1)=sqrt(Norm(1));
for t=2:Ti
% Cluster centers
for i=1:C
sumV=0;
sumU=0;
for j=1:N
sumV=sumV+((U(i,j))^m)*yd(:,j);
sumU=sumU+((U(i,j))^m);
end
V0=sumV/sumU;
for j0=1:D
V(j0,i)=V0(j0);
end
end
% Calculating partition matrix.
for i=1:C
for j=1:N
dji=(yd(:,j)-V(:,i))'*A*(yd(:,j)-V(:,i));
for k=1:C
djk=(yd(:,j)-V(:,k))'*A*(yd(:,j)-V(:,k));
mf(k)=(dji/djk)^(1/(m-1));
end
sumU=0;
for k=1:C
sumU=sumU+mf(k);
end
U(i,j)=1/sumU;
end
end
% Checking convergence
Norm(t)=0;
for j=1:N
for i=1:C
Norm(t)=Norm(t)+U(i,j)^2;
end
end
Norm(t)=sqrt(Norm(t));
E0(t-1)=abs(Norm(t)-Norm(t-1));
Eo=E0(t-1);
t
Eo
if E0(t-1)