Fuzzy Clustering

(* 
Fuzzy Spherical Clustering is a complete Mathematica-program for fuzzy
spherical clustering using the LS distance-like function.All modules needed
are listed in the preamble.One has to load one of the suggested examples
first.After that one can perform the fuzzy c-means algorithm cmeans[] or
the fuzzy incremental algorithm FInc[],which will,based on several indexes,propose one of the partitions obtained as the MAPart.If the original partition
is known,it will also calculate the Rand and Jaccard indexes,as well as the
Hausdorff distance between sets of original and calculated cluster centers 
*)

Modules

Membership matrix - popravljeno

q=2;
mu[A_,cen_,i_,j_]:=1/Sum[(Norm[A[[i]]-cen[[j]]]^2/Norm[A[[i]]-cen[[s]]]^2)^(1/(q-1)),{s,Length[cen]}];

q=2;Clear[i,j]
mu[A_,cen_,i_,j_]:=Module[{uu,Ii={}},
Do[
If[A[[i]]==cen[[s]],Ii=Append[Ii,s]]
,{s,Length[cen]}]; 
If[Ii=={},
uu=1/Sum[(Norm[A[[i]]-cen[[j]]]^2/Norm[A[[i]]-cen[[s]]]^2)^(1/(q-1)),{s,Length[cen]}],
If[MemberQ[Ii,j],uu=1/Length[Ii],uu=0]];
uu
]

Fuzzy objective function

Fz[A_,cen_]:=Module[{m=Length[A],k=Length[cen]},
Return[
Sum[mu[A,cen,i,j]^q Norm[cen[[j]]-A[[i]]]^2,{i,m},{j,k}]
	]
];

Fuzzy c - means algorithm

cmeans[A_,z_,Ind_:0]:=Module[{q=2,k=Length[z],m=Length[A],F1,F2, cen,eps=.00005,It=20},
					(* Initial approximation *)
kk=1;
cen=z//N;
U1=Table[mu[A,cen,i,j],{i,m},{j,k}];  
F1=Fz[A,cen];
If[Ind≠0,slcen=ListPlot[cen,PlotStyle->{Red,PointSize[.04],Opacity[.7]}];
sl2=Show[slA,slcen];
Print[GraphicsGrid[{{slA,sl2}},ImageSize->Medium]]];
						(* While loop *)
While[
cenN=Table[Sum[mu[A,cen,i,j]^q A[[i]],{i,m}]/Sum[mu[A,cen,i,j]^q,{i,m}],{j,k}];
If[Ind≠0,slcen=ListPlot[cenN,PlotMarkers->{"✶",20},PlotStyle->{Orange,PointSize[.04],Opacity[.7]}];
sl1=sl2; sl2=Show[slA,slcen];
Print[GraphicsGrid[{{sl1,sl2}},ImageSize->Medium]]];
U2=Table[mu[A,cenN,i,j],{i,m},{j,k}]; 
 DelU=U2-U1; 
U1=U2;
F2=Fz[A,cenN];DelF=Abs[(F1-F2)/F2];F1=F2;
If[Ind≠0,Print["It-",kk,": centri=",cenN,"; Fz = ",F2,"; accuracy(U) = ",Norm[DelU],"; accuracy(F)=", DelF]];
(*Norm[DelU]>eps *)DelF>eps&& kk<It,F1=F2;
kk=kk+1;cen=cenN
 ];
{cen,U2,kk,DelF}
]

Fuzzy Incremental Algorithm

FInc[A_,z_,KK_,Ind_:0]:=Module[{k,centri,m=Length[A],n=Length[A[[1]]],dom,TT=0},
					(* Initialization *)
centri=z;
PART={};IndFXB=IndFCH=IndFDB=IndFHV=IndRand=IndJaccard=IndH={};
				(* Iterative Procedure *)
Do[
Print["\nNa postojecih ",Length[centri]," centara dodaje se 1 novi"];
Clear[u,v]; 
dom=AG;
					(* Compile *)
FCompile=Compile[{{u,_Real},{v,_Real}},
Evaluate[Sum[Min[Append[Table[Norm[A[[i]]-centri[[s]]]^2,{s,Length[centri]}],Norm[A[[i]]-{u,v}]^2]],{i,m}] ]];	
F2[u_,v_]:=Apply[FCompile,{u,v}];	
						(* Non Compile 
F2[u_,v_]:=Sum[Min[Append[Table[Norm[A[[i]]-centri[[s]]]^2,{s,Length[centri]}],Norm[A[[i]]-{u,v}]^2]],{i,m}];
*)
								(* DIRECT *)
minp=DIRECT[F2,dom,DMin->10.^(-3),MaxIter->50, Eps->10^(-4)]//Timing; min=minp[[2]];(* Print["DIRECT: ",min]; *)
centriN=Append[centri,min[[1]]];
If[Ind≠0,Print["Novi optimirani centar: ",centriN]];
					(* Poziv c-means *)
t1=Timing[sol=cmeans[A,centriN,0]]; 
TT=TT+minp[[1]]+t1[[1]];
k=Length[sol[[1]]]; 
If[Ind≠0,Print["Novi c-means profinjeni centar: ",sol[[1]]]];
If[Ind≠0,Print["Fz=",Fz[A,sol[[1]]],
"; Time (DIRECT+cmeans) = ",minp[[1]],"+",t1[[1]]," = ",minp[[1]]+t1[[1]]]];
fch=FCH[A,sol[[1]],sol[[2]]];IndFCH=Append[IndFCH,fch];
fdb=FDB[A,sol[[1]],sol[[2]]];IndFDB=Append[IndFDB,fdb];
fxb=FXB[A,sol[[1]],sol[[2]]];IndFXB=Append[IndFXB,fxb];
If[Ind≠0,Print["k=",Length[centriN],"; FCH=",fch,"; FDB=",fdb,"; FXB=",fxb]];
ind=RandFrigue[sol[[2]],U0]; 
Huel=Hullermeier[sol[[2]],U0]; 
HD=Hdist[centers,sol[[1]]];
If[Ind≠0,Print["{Rand, Jaccard, Hausdorff}: ",{ind,HD} ]];
IndRand=Append[IndRand,ind[[1]]];
IndJaccard=Append[IndJaccard,ind[[2]]];
IndH=Append[IndH,HD];
                                                                     (* FIGUREE *)
If[n==2,
k=Length[sol[[1]]];
slc=ListPlot[sol[[1]],PlotMarkers->{"✶",20},PlotStyle->{Orange,PointSize[.025],Opacity[.9]}];
rad=Table[Sum[mu[A,sol[[1]],i,j]^q Norm[sol[[1,j]]-A[[i]]]^2,{i,Length[A]}]/Sum[mu[A,sol[[1]],i,j]^q,{i,m}],{j,k}];
rad=Sqrt[rad];
sle1=Table[Graphics[{Gray,Circle[sol[[1,j]],rad[[j]]]}],{j,k}];
		(* Ovo je samo za crtanje sljedeceg centra *)
						(* Compile *)
Clear[u,v,F2]; 
FCompile=Compile[{{u,_Real},{v,_Real}},
Evaluate[Sum[Min[Append[Table[Norm[A[[i]]-centriN[[s]]]^2,{s,Length[centriN]}],Norm[A[[i]]-{u,v}]^2]],{i,m}] ]];	
F2[u_,v_]:=Apply[FCompile,{u,v}];
mini=DIRECT[F2,dom,DMin->10.^(-3),MaxIter->20, Eps->10^(-4)];
nextc=ListPlot[{mini[[1]]},PlotStyle->{Red,PointSize[.04],Opacity[.8]}];
								(*  *)
Print[Show[slA,sle1,slc,nextc,AspectRatio->Automatic,GridLines->Automatic,PlotRange->AG,ImageSize->Small]];
];			      
centri=sol[[1]];     
PART=Append[PART,{sol[[1]],sol[[2]]}]; 
,{brk,KK}];
				(* Indexes *)
If[Ind≠0,Print["Rand: ",IndRand,"\nJaccard: ",IndJaccard,"\nHausdorff: ",IndH,"\nFXB: ",IndFXB,"\nFCH: ",IndFCH,"\nIndFDB: ",IndFDB]];
Print["CPU = ",TT];
				(* Figures *)
If[Ind≠0,
slRand=ListPlot[Table[{j+1,IndRand[[j]]},{j,1,KK}],Joined->True,AxesOrigin->{1,.75Min[IndRand]},PlotLabel->"F-Rand",ImageSize->200];
slJaccard=ListPlot[Table[{j+1,IndJaccard[[j]]},{j,1,KK}],Joined->True,AxesOrigin->{1,.75Min[IndJaccard]},PlotLabel->"F-Jaccard",ImageSize->200];
slH=ListPlot[Table[{j+1,IndH[[j]]},{j,1,KK}],Joined->True,AxesOrigin->{1,.75Min[IndH]},PlotLabel->"Hausdorff",ImageSize->200];
slFXB=ListPlot[Table[{j+1,IndFXB[[j]]},{j,1,KK}],Joined->True,AxesOrigin->{1,.75Min[IndFXB]},PlotLabel->"FXB",ImageSize->200];
slFDB=ListPlot[Table[{j+1,IndFDB[[j]]},{j,1,KK}],Joined->True,AxesOrigin->{1,.75Min[IndFDB]},PlotLabel->"FDB",ImageSize->200];
slFCH=ListPlot[Table[{j+1,IndFCH[[j]]},{j,1,KK}],Joined->True,AxesOrigin->{1,.75Min[IndFCH]},PlotLabel->"FCH",ImageSize->200];
Print[Style[GraphicsGrid[{{slFXB,slFDB,slFCH},{slRand,slJaccard,slH}}]]]];	
{PART,IndRand,IndJaccard,IndH,IndFXB,IndFCH,IndFDB}
]

Indexes

(* Xie-Beni fuzzy index *)
Clear[FXB]
FXB[A_,cen_,U_]:=Module[{m,k},m=Length[A];k=Length[cen];Sum[U[[i,j]]^q Norm[cen[[j]]-A[[i]]]^2,{i,m},{j,k}]/(m*Min[Flatten[Table[Norm[cen[[i]]-cen[[j]]]^2,{i,k-1},{j,i+1,k}],1]])
]

(* Davies-Bouldin fuzzy index *)
Clear[FDB]
FDB[A_,cen_,U_]:=Module[{m=Length[A],k=Length[cen],VV,max,sum=0},
VV=Table[0,{j,k}];
Do[
VV[[j]]=Sum[U[[i,j]]^q Norm[cen[[j]]-A[[i]]]^2,{i,m}]/Sum[U[[i,j]]^q,{i,m}]
   ,{j,k}];
Do[
max={};
Do[
If[i≠j,max=Append[max,(VV[[i]]+VV[[j]])/Norm[cen[[i]]-cen[[j]]] ^2]]
,{i,k}];
sum=sum+Max[max]
,{j,k}];
sum/k
            ]

(* Calinski-Harabasz fuzzy index *)
Clear[FCH]
FCH[A_,cen_,U_]:=Module[{m,k},m=Length[A];k=Length[cen];
cc=Mean[A];
kappa=Table[Sum[U[[ii,j]]^q,{ii,m}] ,{j,k}];
Return[(Sum[kappa[[j]]*Norm[cc-cen[[j]] ]^2,{j,k}]/(k-1))/(Sum[U[[i,j]]^q Norm[cen[[j]]-A[[i]]]^2,{i,m},{j,k}]/(m-k))]
]

Hausdorff distance between two sets of centroids

Hdist[a_,b_]:=Module[{m,n,a1,b1},
If[Length[a]>Length[b],a1=b;b1=a,a1=a;b1=b];
m=Length[a1];n=Length[b1];
Max[Max[Table[Min[Table[Norm[a1[[i]]-b1[[j]]],{j,n}]],{i,m}]],Max[Table[Min[Table[Norm[a1[[i]]-b1[[j]]],{i,m}]],{j,n}]]]]

Fuzzy Rand and Jaccard index according to Frigue et al. (2007)

(* A, B su  membership matrices *)
RandFrigue[A_,B_]:=Module[{m=Dimensions[A][[1]],PsiA,PsiB,a,b,c,d},
PsiA=PsiB=Table[0,{i,m},{j,m}];
Do[
PsiA[[i,j]]=A[[i]].A[[j]];PsiB[[i,j]]=B[[i]].B[[j]];
,{i,m-1},{j,i+1,m}];
a=Sum[PsiA[[i,j]]*PsiB[[i,j]],{i,m-1},{j,i+1,m}];
b=Sum[PsiA[[i,j]]*(1-PsiB[[i,j]]),{i,m-1},{j,i+1,m}];
c=Sum[(1-PsiA[[i,j]])*PsiB[[i,j]],{i,m-1},{j,i+1,m}];
d=Sum[(1-PsiA[[i,j]])*(1-PsiB[[i,j]]),{i,m-1},{j,i+1,m}];
{(a+d)/(a+b+c+d),a/(a+b+c)}
]

Fuzzy index according to Hullermeier et al. (2012)

(* A, B su  membership matrices *)
Hullermeier[A_,B_]:=Module[{m=Dimensions[A][[1]],PsiA,PsiB,dAB},
PsiA=PsiB=Table[0,{i,m},{j,m}];
Do[
PsiA[[i,j]]=1-Norm[A[[i]]-A[[j]],Infinity];PsiB[[i,j]]=1-Norm[B[[i]]-B[[j]],Infinity];
,{i,m-1},{j,i+1,m}];
dAB=Sum[Abs[PsiA[[i,j]]-PsiB[[i,j]]],{i,m-1},{j,i+1,m}]/(m(m-1)/2);
1-dAB
]

DIRECT Modul

Options[DIRECT]={Eps->0,MaxIter->20,DMin->10.^(-2)};
DIRECT[f_,dom_,OptionsPattern[]]:=Module[{n,ff,c,d,dmax,fc,dmaxrazni,pot0,pot1,pot2,temp,ind,novic,novid,novifc,red,TMin,iter=0,dtest,anim={}},
dtest=N[OptionValue[DMin]/Max[(dom[[All,2]]-dom[[All,1]])]];
DIRECT::maxiter="Dosegnut maksimalan broj iteracija `1`.";
n=Length[dom];
(* skaliranje funkcije na hiperkocku duljine stranice 1 *)
ff=Function[N[f@@({##}(dom[[All,2]]-dom[[All,1]])+dom[[All,1]]),50]];
(* početni centar i promjeri *)
c={Table[1/2,{i,n}]};
d={Table[1,{i,n}]};
dmax={Max[d[[1]]]};
dmaxrazni=Union[dmax];
fc={ff@@c[[1]]};
TMin={c[[1]],fc[[1]]};
(* GLAVNA PETLJA *)
Monitor[
While[(dmaxrazni[[1]]>dtest)&&(iter<OptionValue[MaxIter]),
iter++;
(* KORAK 1: traženje potencijalno optimalnih hiperkvadara *)
dmaxrazni=Union[dmax];
(* svi podaci grupirani po d *)
pot0=Table[Select[Range[Length[fc]],dmax[[#]]==dmaxrazni[[i]]&],{i,Length[dmaxrazni]}];
(* podaci s najmanjim f grupirani po d *)
pot1=Table[pot0[[i,Position[fc[[pot0[[i]]]],Min[fc[[pot0[[i]]]]]][[All,1]]]],{i,Length[dmaxrazni]}];
(* provjera ostalih uvjeta *)
pot2={pot1[[-1]]};
Do[temp=Min[Table[(fc[[pot1[[i,1]]]]-fc[[pot2[[j,1]]]])/(dmax[[pot1[[i,1]]]]-dmax[[pot2[[j,1]]]]),{j,Length[pot2]}]];
If[temp>OptionValue[Eps]&&(i==1||Max[Table[(fc[[pot1[[i,1]]]]-fc[[pot1[[j,1]]]])/(dmax[[pot1[[i,1]]]]-dmax[[pot1[[j,1]]]]),{j,i-1}]]<temp)
,AppendTo[pot2,pot1[[i]]]];
,{i,Length[dmaxrazni]-1,1,-1}];
pot2=Flatten[pot2,1];
(* KORAK 2: dijeljenje potencijalno optimalnih *)
Do[
(* smjerovi po kojima se dijeli *)
ind=Flatten[Position[d[[pot]],Max[d[[pot]]]]];
novic=Table[c[[pot]],{2*Length[ind]}];
novid=Table[d[[pot]],{2*Length[ind]}];
d[[pot,ind]]/=3;
dmax[[pot]]/=3;
Do[
novic[[2i-1,ind[[i]]]]-=d[[pot,ind[[i]]]];
novic[[2i,ind[[i]]]]+=d[[pot,ind[[i]]]];
,{i,Length[ind]}];
novifc=Table[ff@@novic[[i]],{i,Length[novic]}];
red=Ordering[Table[Min[{novifc[[2i-1]],novifc[[2i]]}],{i,Length[ind]}]];
Do[novid[[2red[[j]]-1,ind[[red[[i]]]]]]=novid[[2red[[j]],ind[[red[[i]]]]]]/=3,{i,1,Length[red]},{j,i,Length[red]}];
c=Join[c,novic];
d=Join[d,novid];
dmax=Join[dmax,Map[Max,novid]];
fc=Join[fc,novifc];
If[novifc[[2red[[1]]-1]]<TMin[[2]],TMin=N[{novic[[2red[[1]]-1]],novifc[[2red[[1]]-1]]},10]];
If[novifc[[2red[[1]]]]<TMin[[2]],TMin=N[{novic[[2red[[1]]]],novifc[[2red[[1]]]]},10]];
,{pot,pot2}];
(*Print[iter,": ",{TMin[[1]](dom[[All,2]]-dom[[All,1]])+dom[[All,1]],TMin[[2]]}];*)
If[iter==OptionValue[MaxIter],Message[DIRECT::maxiter,OptionValue[MaxIter]];];
(* slika za 2D slučaj *)
(*If[n==2,
AppendTo[anim,
Graphics[{{Green,Rectangle[]},Table[{Blue,Rectangle[c[[i]]-d[[i]]/2+d[[i]]/10,c[[i]]+d[[i]]/2-d[[i]]/10]},{i,Length[d]}],Point[c]}]
];
];*)
];
,{iter,Length[pot2]}]
(* vraćanje u početnu domenu *)
TMin[[1]]=TMin[[1]](dom[[All,2]]-dom[[All,1]])+dom[[All,1]];
(* ispis slika za 2D slučaj *)
(*If[n==2,Print[ListAnimate[anim,AnimationRunning->False]]];*)
Return[TMin];
]

Test-example 1:  5 clusters uz var=1

n=2;SeedRandom[1213];
centers={{2,2},{3,5},{6,7},{7,3},{8,8}};
var=1; number=100; AG={{0,10},{0,10}};
data0=Table[RandomVariate[MultinormalDistribution[ci,var IdentityMatrix[2]],number],{ci,centers}];
data=Flatten[data0,1]; 
m=Length[data];
k=Length[centers];
Dimensions[data]	
					(* PODACI *)
A=Flatten[data0,1];
xG={Min[A[[All,1]]]-.5,Max[A[[All,1]]]+.5};yG={Min[A[[All,2]]]-.5,Max[A[[All,2]]]+.5};
AG={xG,yG};
m=Length[A];
cc=Mean[data];
sldata=ListPlot[data0,PlotStyle->{PointSize[.015]}];
slcen=ListPlot[centers,PlotStyle->{Gray,PointSize[.04],Opacity[.8]}];
slA=ListPlot[A,PlotStyle->{PointSize[.01]},AspectRatio->Automatic,GridLines->Automatic,PlotRange->AG,ImageSize->Small];
rad=Table[Sum[mu[A,centers,i,j]^q Norm[centers[[j]]-A[[i]]]^2,{i,Length[A]}]/Sum[mu[A,centers,i,j]^q,{i,m}],{j,k}];
rad=Sqrt[rad]
sle=Table[Graphics[{Red,Circle[centers[[j]],rad[[j]]]}],{j,k}];
slA1=Show[sldata,slcen,sle,AspectRatio->Automatic,GridLines->Automatic,PlotRange->AG,ImageSize->Small]
z0={{3,3},{4,5},{6,6},{8,4},{8,6}};
slz0=ListPlot[z0,PlotStyle->{Gray,PointSize[.04],Opacity[.8]}];
slA2=Show[slA,slz0,AspectRatio->Automatic,GridLines->Automatic,PlotRange->AG,ImageSize->Small]
(* GraphicsGrid[{{slA1,slA2}},ImageSize->Medium] *)
(* Membership Matrix *)
U0=Table[mu[A,centers,i,j],{i,m},{j,k}];

Test Example 9.2 : 5 clusters (Pinter, 1996)

n=2;SeedRandom[1213];
centers={{2.5,3},{2,8.5},{5,6},{8,5},{8.5,1.5}};
var=1; number=200; AG={{0,10},{0,10}};
data0=Table[RandomVariate[MultinormalDistribution[ci,var IdentityMatrix[2]],number],{ci,centers}];
data=Flatten[data0,1]; 
m=Length[data];
k=Length[centers];
Dimensions[data]	
						(* PODACI *)
A=Flatten[data0,1];
xG={Min[A[[All,1]]]-.5,Max[A[[All,1]]]+.5};yG={Min[A[[All,2]]]-.5,Max[A[[All,2]]]+.5};
AG={xG,yG};
m=Length[A];
cc=Mean[data];
sldata=ListPlot[data0,PlotStyle->{PointSize[.01]}];
slcen=ListPlot[centers,PlotStyle->{Gray,PointSize[.04],Opacity[.8]}];
rad=Table[Sum[mu[A,centers,i,j] Norm[centers[[j]]-A[[i]]]^2,{i,Length[A]}]/Length[A],{j,k}];
rad=Sqrt[rad]
sle=Table[Graphics[{Red,Circle[centers[[j]],rad[[j]]]}],{j,k}];
slA=ListPlot[A,PlotStyle->{PointSize[.01]},AspectRatio->Automatic,GridLines->Automatic,PlotRange->AG,ImageSize->Small];
slA1=Show[sldata,slcen,sle,AspectRatio->Automatic,GridLines->Automatic,PlotRange->AG,ImageSize->Small]
z0={{2,2},{3,8},{5,5},{9,6},{8,2}};
slz0=ListPlot[z0,PlotStyle->{Gray,PointSize[.04],Opacity[.8]}];
slA2=Show[slA,slz0,AspectRatio->Automatic,GridLines->Automatic,PlotRange->AG,ImageSize->Small]
(* GraphicsGrid[{{slA1,slA2}},ImageSize->Medium] *)
(* Membership Matrix *)
U0=Table[mu[A,centers,i,j],{i,m},{j,k}];

Test-example 9.3:  6 clusters uz var=3.5

n=2;SeedRandom[1213];
centers={{-8,-6},{-3,-8},{-1,-1},{8,4},{6,9},{-1,8}};
var=3.5; number=200; AG={{-15,15},{-15,15}};
data0=Table[RandomVariate[MultinormalDistribution[ci,var IdentityMatrix[2]],number],{ci,centers}];
data=Flatten[data0,1]; 
m=Length[data];
k=Length[centers];
Dimensions[data]	
					(* PODACI *)
A=Flatten[data0,1];
xG={Min[A[[All,1]]]-.5,Max[A[[All,1]]]+.5};yG={Min[A[[All,2]]]-.5,Max[A[[All,2]]]+.5};
AG={xG,yG};
m=Length[A];
cc=Mean[data];
sldata=ListPlot[data0,PlotStyle->{PointSize[.01]}];
slcen=ListPlot[centers,PlotStyle->{Gray,PointSize[.04],Opacity[.8]}];
rad=Table[Sum[mu[A,centers,i,j] Norm[centers[[j]]-A[[i]]]^2,{i,Length[A]}]/Length[A],{j,k}];
rad=Sqrt[rad]
sle=Table[Graphics[{Red,Circle[centers[[j]],rad[[j]]]}],{j,k}];
slA=ListPlot[A,PlotStyle->{PointSize[.01]},AspectRatio->Automatic,GridLines->Automatic,PlotRange->AG,ImageSize->Small];
slA1=Show[sldata,slcen,sle,AspectRatio->Automatic,GridLines->Automatic,PlotRange->AG,ImageSize->Small]
z0={{-10,-8},{0,-8},{0,0},{0,8},{8,2},{8,10}};
slz0=ListPlot[z0,PlotStyle->{Gray,PointSize[.04],Opacity[.8]}];
slA2=Show[slA,slz0,AspectRatio->Automatic,GridLines->Automatic,PlotRange->AG,ImageSize->Small]
(* GraphicsGrid[{{slA1,slA2}},ImageSize->Medium] *)
(* Membership Matrix *)
U0=Table[mu[A,centers,i,j],{i,m},{j,k}];

Call Fuzzy c - means

Time=Timing[cm=cmeans[A,z0,0]];
Print["It-",cm[[3]],"; eps=",cm[[4]],"; CPU = ",Time[[1]],"\ncenters=",Round[cm[[1]],-.01] ]
slcenN=ListPlot[cm[[1]],PlotMarkers->{"✶",20},PlotStyle->{Orange,PointSize[.04],Opacity[.7]}];
rad=Table[Sum[mu[A,cm[[1]],i,j]^q Norm[cm[[1,j]]-A[[i]]]^2,{i,Length[A]}]/Sum[mu[A,cm[[1]],i,j]^q,{i,m}],{j,k}];
rad=Sqrt[rad]
sle1=Table[Graphics[{Gray,Circle[cm[[1,j]],rad[[j]]]}],{j,k}];
Show[slA,slcenN,sle,sle1,ImageSize->Small]
Timing2=Timing[rand=RandFrigue[U0,cm[[2]]]];
Print["H = ",Hdist[centers,cm[[1]]], "; RandFrigue = ",rand[[1]], "; JaccFrigue = ",rand[[2]]"; Huller = ",Hullermeier[U0,cm[[2]]],"; CPU(indexes)=",Timing2[[1]]]
(* Attention: generally the matrix CC is of the tipe (k,l) *)
CC=Transpose[U0].cm[[2]]; dim=Dimensions[CC];
CC2=Table[Append[CC[[i]],Total[CC[[i]]]],{i,dim[[1]]}]; (* added a column *)
CC2=Append[CC2,Table[Sum[CC2[[i,j]],{i,dim[[1]]}],{j,dim[[2]]+1}]]; (* added a row *)
CCN=CC2;
Do[
Do[
CCN[[i,j]]=100CC2[[i,j]]/CC2[[i,dim[[2]]+1]]
,{j,dim[[2]]+1}]
,{i,dim[[1]]}]
Do[CCN[[dim[[1]]+1,j]]=Sum[CCN[[i,j]],{i,dim[[1]]}],{j,dim[[2]]}]; 
Print["C=",MatrixForm[Round[CC2,-.1]],"; C(%)=",MatrixForm[Round[CCN,-.1]]]

Za text

Round[CC2,-.1]
Round[CCN,-.1]

Call Fuzzy Incremental

finc=FInc[A,{Mean[A]},5,1];

Figures

slFXB=ListPlot[Table[{j+1,finc[[5,j]]},{j,1,5}],Joined->True,AxesOrigin->{1,.75Min[IndFXB]},GridLines->Automatic,ImageSize->Small]
slFCH=ListPlot[Table[{j+1,finc[[6,j]]},{j,1,5}],Joined->True,AxesOrigin->{1,.75Min[IndFCH]},GridLines->{Automatic,{600,700,800}},ImageSize->Small]	
slFDB=ListPlot[Table[{j+1,finc[[7,j]]},{j,1,5}],Joined->True,AxesOrigin->{1,.75Min[IndFDB]},GridLines->Automatic,ImageSize->Small]
slFDB=ListPlot[Table[{j+1,finc[[4,j]]},{j,1,5}],Joined->True,AxesOrigin->{1,.75Min[IndH]},GridLines->Automatic,ImageSize->Small]

Dissipation of cluster elements

Do[
sl[j]=ListPlot[Transpose[cm[[2]]][[j]],PlotStyle->{PointSize[.015]},ImageSize->Small];
Print[sl[j]]
,{j,k}]

GraphicsGrid[{Table[sl[j],{j,3}],
Table[sl[j],{j,4,k}]},ImageSize->Large]