Upload
format-seorang-legenda
View
44
Download
5
Embed Size (px)
DESCRIPTION
Fuzzy c-means clustering
Citation preview
Fuzzy cmeans clustering collapse all in page
[centers,U] = fcm(data,Nc) example
[centers,U] = fcm(data,Nc,options) example
[centers,U,objFunc] = fcm( ___ ) example
example
example
example
Open This Example
collapse all
fcm
Syntax
Description[centers,U] = fcm(data,Nc) performs fuzzy cmeans clusteringon the given data and returns Nc cluster centers.
[centers,U] = fcm(data,Nc,options) specifies additionalclustering options.
[centers,U,objFunc] = fcm( ___ ) also returns the objectivefunction values at each optimization iteration for all of the previoussyntaxes.
Examples
Cluster Data Using Fuzzy CMeans Clustering
Load data.
load fcmdata.dat
Find 2 clusters using fuzzy cmeans clustering.
[centers,U] = fcm(fcmdata,2);
Iteration count = 1, obj. fcn = 8.970479 Iteration count = 2, obj. fcn = 7.197402 Iteration count = 3, obj. fcn = 6.325579 Iteration count = 4, obj. fcn = 4.586142 Iteration count = 5, obj. fcn = 3.893114 Iteration count = 6, obj. fcn = 3.810804 Iteration count = 7, obj. fcn = 3.799801 Iteration count = 8, obj. fcn = 3.797862 Iteration count = 9, obj. fcn = 3.797508 Iteration count = 10, obj. fcn = 3.797444 Iteration count = 11, obj. fcn = 3.797432 Iteration count = 12, obj. fcn = 3.797430
Classify each data point into the cluster with the largest membership value.
maxU = max(U); index1 = find(U(1,:) == maxU); index2 = find(U(2,:) == maxU);
Open This Example
Open This Example
Plot the clustered data and cluster centers.
plot(fcmdata(index1,1),fcmdata(index1,2),'ob') hold on 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)hold off
Specify Fuzzy Overlap Between Clusters
Create a random data set.
data = rand(100,2);
Specify a large fuzzy partition matrix exponent to increase the amount of fuzzy ovrelap between the clusters.
options = [3.0 NaN NaN 0];
Cluster the data.
[centers,U] = fcm(data,2,options);
Configure Clustering Termination Conditions
Load the clustering data.
collapse all
load clusterdemo.dat
Set the clustering termination conditions such that the optimization stops when either of the following occurs:
The number of iterations reaches a maximum of 25.
The objective function improves by less than 0.001 between two consecutive iterations.
options = [NaN 25 0.001 0];
The first option is NaN, which sets the fuzzy partition matrix exponent to its default value of 2. Setting thefourth option to 0 suppresses the objective function display.
Cluster the data.
[centers,U,objFun] = fcm(clusterdemo,3,options);
View the objective function vector to determine which termination condition stopped the clustering.
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
The optimization stopped because the objective function improved by less than0.001 between the final twoiterations.
Related ExamplesCluster QuasiRandom Data Using Fuzzy CMeans Clustering
Adjust Fuzzy Overlap in Fuzzy CMeans Clustering
Input Arguments
data — Data set to be clusteredmatrix
Data set to be clustered, specified as a matrix with N rows, where N is the number of data points. Thenumber of columns in data is equal to the data dimensionality.
Nc — Number of clusters
d d
collapse all
integer
Number of clusters, specified as an integer greater than 1.
options — Clustering optionsvector
Clustering options, specified as a vector with the following elements:
Option Description Default
options(1) Exponent for the fuzzy partition matrix U, specified as ascalar greater than 1.0. This option controls the amount offuzzy overlap between clusters, with larger valuesindicating a greater degree of overlap.
If your data set is wide with a lot of overlap betweenpotential clusters, then the calculated cluster centers mightbe very close to each other. In this case, each data pointhas approximately the same degree of membership in allclusters. To improve your clustering results, decrease thisvalue, which limits the amount of fuzzy overlap duringclustering.
For an example of fuzzy overlap adjustment, see AdjustFuzzy Overlap in Fuzzy CMeans Clustering.
2.0
options(2) Maximum number of iterations, specified as a positiveinteger.
100
options(3) Minimum improvement in objective function between twoconsecutive iterations, specified as a positive scalar.
1e‐5
options(4) Information display toggle indicating whether to displaythe objective function value after each iteration, specifiedas one of the following:
0 — Do not display objective function.
1 — Display objective function.
1
If any element of options is NaN, the default value for that option is used.
The clustering process stops when the maximum number of iterations is reached or when the objectivefunction improvement between two consecutive iterations is less than the specified minimum.
Output Arguments
centers — Cluster centersmatrix
Final cluster centers, returned as a matrix with Nc rows containing the coordinates of each cluster center. Thenumber of columns in centers is equal to the dimensionality of the data being clustered.
U — Fuzzy partition matrixmatrix
Fuzzy partition matrix, returned as a matrix with Nc rows and N columns. Element U(i,j) indicates thedegree of membership of the jth data point in theith cluster. For a given data point, the sum of the
d
collapse all
membership values for all clusters is one.
objFunc — Objective function valuesvector
Objective function values for each iteration, returned as a vector.
More About
Algorithms
Fuzzy cmeans (FCM) is a clustering method that allows each data point to belong to multiple clusters withvarying degrees of membership.
FCM is based on the minimization of the following objective function
where
D is the number of data points.
N is the number of clusters.
m is fuzzy partition matrix exponent for controlling the degree of fuzzy overlap, with m > 1. Fuzzy overlaprefers to how fuzzy the boundaries between clusters are, that is the number of data points that havesignificant membership in more than one cluster.
x is the ith data point.
c is the center of the jth cluster.
μ is the degree of membership of x in the jth cluster. For a given data point,x , the sum of themembership values for all clusters is one.
fcm performs the following steps during clustering:
1. Randomly initialize the cluster membership values, μ .
2. Calculate the cluster centers:
3. Update μ according to the following:
4. Calculate the objective function, J .
5. Repeat steps 2–4 until J improves by less than a specified minimum threshold or until after a specifiedmaximum number of iterations.
Fuzzy Clustering
References[1] Bezdec, J.C., Pattern Recognition with Fuzzy Objective Function Algorithms, Plenum Press, New York, 1981.
Jm =D
i=1
N
j=1μmij xi − cj
2,
i
j
ij i i
ij
cj =
D
i=1μmij xi
D
i=1μmij
.
ij
μij =1
N
k=1
xi − cjxi − ck
2m−1
.
m
m
See Alsofindcluster | genfis3
Introduced before R2006a