fcm

Fuzzy C-means clustering

Syntax

[center,U,obj_fcn] = fcm(data,cluster_n)
[center,U,obj_fcn] = fcm(data,cluster_n,options) 

Description

[center, U, obj_fcn] = fcm(data, cluster_n) applies the fuzzy c-means clustering method to a given data set.

The input arguments of this function are

  • data: data set to be clustered; each row is a sample data point

  • cluster_n: number of clusters (greater than one)

The output arguments of this function are

  • center: matrix of final cluster centers where each row provides the center coordinates

  • U: final fuzzy partition matrix (or membership function matrix)

  • obj_fcn: values of the objective function during iterations

fcm(data,cluster_n,options) uses an additional argument variable, options, to specify clustering parameters, introduce a stopping criteria, or set the iteration information display. Specify options as a vector:

  • options(1): Exponent for the partition matrix U. Default: 2.0.

  • options(2): Maximum number of iterations. Default: 100.

  • options(3): Minimum amount of improvement. Default: 1e-5.

  • options(4): Information displayed during iteration. Default: 1.

If any entry of options is NaN, the default value for that option is used instead. The clustering process stops when the maximum number of iterations is reached or when the objective function improvement between two consecutive iterations is less than the minimum amount of improvement specified.

Examples

expand all

Apply Fuzzy C-Means Clustering Method to Data

Apply the Fuzzy C-Means clustering to training data.

data = rand(100,2);
opts = [nan;nan;nan;0];
[center,U,obj_fcn] = fcm(data,2,opts);

The fourth entry of opts turns off the iteration display. The remaining entries specify the default values for the corresponding options.

Plot the results.

plot(data(:,1),data(:,2),'o');
maxU = max(U);
index1 = find(U(1,:)== maxU);
index2 = find(U(2,:)== maxU);
line(data(index1,1),data(index1,2),'linestyle','none',...
     'marker','*','color','g');
line(data(index2,1),data(index2,2),'linestyle','none',...
     'marker', '*','color','r');

Was this topic helpful?