Sunteți pe pagina 1din 6

fcm

Fuzzycmeansclustering

collapseallinpage

Syntax
[centers,U]=fcm(data,Nc)

example

[centers,U]=fcm(data,Nc,options)

example

[centers,U,objFunc]=fcm( ___ )

example

Description
[centers,U]=fcm(data,Nc)performsfuzzycmeansclustering
onthegivendataandreturnsNcclustercenters.

example

[centers,U]=fcm(data,Nc,options)specifiesadditional
clusteringoptions.

example

[centers,U,objFunc]=fcm( ___ )alsoreturnstheobjective


functionvaluesateachoptimizationiterationforalloftheprevious
syntaxes.

example

Examples

collapseall

ClusterDataUsingFuzzyCMeansClustering
Loaddata.
loadfcmdata.dat
Find2clustersusingfuzzycmeansclustering.
[centers,U]=fcm(fcmdata,2);
Iterationcount=1,obj.fcn=8.970479
Iterationcount=2,obj.fcn=7.197402
Iterationcount=3,obj.fcn=6.325579
Iterationcount=4,obj.fcn=4.586142
Iterationcount=5,obj.fcn=3.893114
Iterationcount=6,obj.fcn=3.810804
Iterationcount=7,obj.fcn=3.799801
Iterationcount=8,obj.fcn=3.797862
Iterationcount=9,obj.fcn=3.797508
Iterationcount=10,obj.fcn=3.797444
Iterationcount=11,obj.fcn=3.797432
Iterationcount=12,obj.fcn=3.797430
Classifyeachdatapointintotheclusterwiththelargestmembershipvalue.
maxU=max(U);
index1=find(U(1,:)==maxU);
index2=find(U(2,:)==maxU);

OpenThisExample

Plottheclustereddataandclustercenters.
plot(fcmdata(index1,1),fcmdata(index1,2),'ob')
holdon
plot(fcmdata(index2,1),fcmdata(index2,2),'or')
plot(centers(1,1),centers(1,2),'xb','MarkerSize',15,'LineWidth',3)
plot(centers(2,1),centers(2,2),'xr','MarkerSize',15,'LineWidth',3)
holdoff

SpecifyFuzzyOverlapBetweenClusters
Createarandomdataset.

OpenThisExample

data=rand(100,2);
Specifyalargefuzzypartitionmatrixexponenttoincreasetheamountoffuzzyovrelapbetweentheclusters.
options=[3.0NaNNaN0];
Clusterthedata.
[centers,U]=fcm(data,2,options);

ConfigureClusteringTerminationConditions
Loadtheclusteringdata.

OpenThisExample

loadclusterdemo.dat
Settheclusteringterminationconditionssuchthattheoptimizationstopswheneitherofthefollowingoccurs:
Thenumberofiterationsreachesamaximumof25.
Theobjectivefunctionimprovesbylessthan0.001betweentwoconsecutiveiterations.
options=[NaN250.0010];
ThefirstoptionisNaN,whichsetsthefuzzypartitionmatrixexponenttoitsdefaultvalueof2.Settingthe
fourthoptionto0suppressestheobjectivefunctiondisplay.
Clusterthedata.
[centers,U,objFun]=fcm(clusterdemo,3,options);
Viewtheobjectivefunctionvectortodeterminewhichterminationconditionstoppedtheclustering.
objFun
objFun=
54.7257
42.9867
42.8554
42.1857
39.0857
31.6814
28.5736
27.1806
20.7359
15.7147
15.4353
15.4306
15.4305
Theoptimizationstoppedbecausetheobjectivefunctionimprovedbylessthan0.001betweenthefinaltwo
iterations.

RelatedExamples
ClusterQuasiRandomDataUsingFuzzyCMeansClustering
AdjustFuzzyOverlapinFuzzyCMeansClustering

InputArguments

collapseall

dataDatasettobeclustered
matrix
Datasettobeclustered,specifiedasamatrixwithNdrows,whereNdisthenumberofdatapoints.The
numberofcolumnsindataisequaltothedatadimensionality.
NcNumberofclusters

integer
Numberofclusters,specifiedasanintegergreaterthan1.
optionsClusteringoptions
vector
Clusteringoptions,specifiedasavectorwiththefollowingelements:
Option

Description

options(1) ExponentforthefuzzypartitionmatrixU,specifiedasa
scalargreaterthan1.0.Thisoptioncontrolstheamountof
fuzzyoverlapbetweenclusters,withlargervalues
indicatingagreaterdegreeofoverlap.

Default
2.0

Ifyourdatasetiswidewithalotofoverlapbetween
potentialclusters,thenthecalculatedclustercentersmight
beveryclosetoeachother.Inthiscase,eachdatapoint
hasapproximatelythesamedegreeofmembershipinall
clusters.Toimproveyourclusteringresults,decreasethis
value,whichlimitstheamountoffuzzyoverlapduring
clustering.
Foranexampleoffuzzyoverlapadjustment,seeAdjust
FuzzyOverlapinFuzzyCMeansClustering.
options(2) Maximumnumberofiterations,specifiedasapositive
integer.

100

options(3) Minimumimprovementinobjectivefunctionbetweentwo
consecutiveiterations,specifiedasapositivescalar.

1e5

options(4) Informationdisplaytoggleindicatingwhethertodisplay
theobjectivefunctionvalueaftereachiteration,specified
asoneofthefollowing:

0Donotdisplayobjectivefunction.
1Displayobjectivefunction.

IfanyelementofoptionsisNaN,thedefaultvalueforthatoptionisused.
Theclusteringprocessstopswhenthemaximumnumberofiterationsisreachedorwhentheobjective
functionimprovementbetweentwoconsecutiveiterationsislessthanthespecifiedminimum.

OutputArguments

collapseall

centersClustercenters
matrix
Finalclustercenters,returnedasamatrixwithNcrowscontainingthecoordinatesofeachclustercenter.The
numberofcolumnsincentersisequaltothedimensionalityofthedatabeingclustered.
UFuzzypartitionmatrix
matrix
Fuzzypartitionmatrix,returnedasamatrixwithNcrowsandNdcolumns.ElementU(i,j)indicatesthe
degreeofmembershipofthejthdatapointintheithcluster.Foragivendatapoint,thesumofthe

membershipvaluesforallclustersisone.
objFuncObjectivefunctionvalues
vector
Objectivefunctionvaluesforeachiteration,returnedasavector.

MoreAbout

collapseall

Algorithms
Fuzzycmeans(FCM)isaclusteringmethodthatallowseachdatapointtobelongtomultipleclusterswith
varyingdegreesofmembership.
FCMisbasedontheminimizationofthefollowingobjectivefunction
D

Jm =

i =1 j=1

ij xi cj

where
Disthenumberofdatapoints.
Nisthenumberofclusters.
misfuzzypartitionmatrixexponentforcontrollingthedegreeoffuzzyoverlap,withm>1.Fuzzyoverlap
referstohowfuzzytheboundariesbetweenclustersare,thatisthenumberofdatapointsthathave
significantmembershipinmorethanonecluster.
x iistheithdatapoint.
c jisthecenterofthejthcluster.
ijisthedegreeofmembershipofx iinthejthcluster.Foragivendatapoint,x i,thesumofthe
membershipvaluesforallclustersisone.
fcmperformsthefollowingstepsduringclustering:
1.Randomlyinitializetheclustermembershipvalues,ij.
2.Calculatetheclustercenters:
D

cj =

i =1
D

mx
ij i

i =1

m
ij

3.Updateijaccordingtothefollowing:

ij =

1
N
k=1

x c
i j
x c
i k

2
m 1

4.Calculatetheobjectivefunction,J m.
5.Repeatsteps24untilJ mimprovesbylessthanaspecifiedminimumthresholdoruntilafteraspecified
maximumnumberofiterations.
FuzzyClustering

References
[1]Bezdec,J.C.,PatternRecognitionwithFuzzyObjectiveFunctionAlgorithms,PlenumPress,NewYork,1981.

SeeAlso
findcluster|genfis3

IntroducedbeforeR2006a

S-ar putea să vă placă și