Logo

Fuzzy C-Means Clustering

7 min read
Lesson slides
1 / 14

Fuzzy C-Means Clustering

Soft clustering where points belong to every cluster by degree

Introduction

Fuzzy C-Means (FCM) is a soft clustering algorithm where each data point can belong to multiple clusters with varying degrees of membership. Unlike hard clustering methods like K-Means where each point belongs to exactly one cluster, FCM allows partial memberships, making it more flexible for handling overlapping clusters.

The algorithm iteratively updates cluster centroids and membership values until convergence is achieved.

Algorithm Overview

flowchart TD
    A[Start] --> B[Initialize Membership Matrix with Random Values]
    B --> C[Calculate Cluster Centroids]
    C --> D[Compute Distances from Points to Centroids]
    D --> E[Update Membership Values]
    E --> F{Convergence<br/>Reached?}
    F -->|No| C
    F -->|Yes| G[End]
    
    style A fill:#e1f5ff
    style G fill:#e1f5ff
    style F fill:#fff4e1

Algorithm Steps

Step 1: Initialize Membership Matrix

Given the data points and the desired number of clusters, initialize a membership matrix with random values between 0 and 1. Each row represents a cluster, and each column represents a data point.

Constraints:

  • Membership values must be between 0 and 1
  • For each data point, the sum of memberships across all clusters must equal 1

Step 2: Calculate Cluster Centroids

Calculate the centroid (center) of each cluster using the weighted average of all data points.

Formula:

Vij=k=1nγikmxkk=1nγikmV_{ij} = \frac{\sum_{k=1}^{n} \gamma_{ik}^m \cdot x_k}{\sum_{k=1}^{n} \gamma_{ik}^m}

Where:

  • VijV_{ij} is the jj-th coordinate of the ii-th cluster centroid
  • γ\gamma (gamma) is the fuzzy membership value
  • mm is the fuzziness parameter (typically set to 2)
  • xkx_k is the data point
  • nn is the total number of data points

Step 3: Calculate Distances

Compute the Euclidean distance between each data point and each cluster centroid.

Formula:

Dki=(xkVi1)2+(ykVi2)2D_{ki} = \sqrt{(x_k - V_{i1})^2 + (y_k - V_{i2})^2}

Where:

  • DkiD_{ki} is the distance from point kk to centroid ii
  • (xk,yk)(x_k, y_k) is the data point
  • (Vi1,Vi2)(V_{i1}, V_{i2}) is the cluster centroid

Step 4: Update Membership Values

Update the membership values based on the calculated distances.

Formula:

γki=(j=1n{dki2dkj2}(1m1))1\gamma_{ki} = \left(\sum_{j=1}^{n} \left\{\frac{d_{ki}^2}{d_{kj}^2}\right\}^{\left(\frac{1}{m-1}\right)}\right)^{-1}

Where:

  • γki\gamma_{ki} is the membership of point kk in cluster ii
  • dkid_{ki} is the distance from point kk to centroid ii
  • mm is the fuzziness parameter (typically 2)

Step 5: Check Convergence

Repeat steps 2-4 until one of the following convergence criteria is met:

  • The membership values remain constant (or change is negligible)
  • The difference between consecutive iterations is less than a tolerance value (e.g., 0.01)
  • A maximum number of iterations is reached

Detailed Example

Given Data

Data points: {(1, 3), (2, 5), (4, 8), (7, 9)}

Number of clusters: 2

Fuzziness parameter: m = 2

Iteration 1

Step 1: Initial Membership Matrix

Cluster(1, 3)(2, 5)(4, 8)(7, 9)
10.80.70.20.1
20.20.30.80.9

Step 2: Calculate Centroids

For Cluster 1 (x-coordinate):

V11=0.821+0.722+0.224+0.1270.82+0.72+0.22+0.12V_{11} = \frac{0.8^2 \cdot 1 + 0.7^2 \cdot 2 + 0.2^2 \cdot 4 + 0.1^2 \cdot 7}{0.8^2 + 0.7^2 + 0.2^2 + 0.1^2}

V11=0.641+0.492+0.044+0.0170.64+0.49+0.04+0.01=1.851.18=1.568V_{11} = \frac{0.64 \cdot 1 + 0.49 \cdot 2 + 0.04 \cdot 4 + 0.01 \cdot 7}{0.64 + 0.49 + 0.04 + 0.01} = \frac{1.85}{1.18} = 1.568

For Cluster 1 (y-coordinate):

V12=0.823+0.725+0.228+0.1290.82+0.72+0.22+0.12V_{12} = \frac{0.8^2 \cdot 3 + 0.7^2 \cdot 5 + 0.2^2 \cdot 8 + 0.1^2 \cdot 9}{0.8^2 + 0.7^2 + 0.2^2 + 0.1^2}

V12=0.643+0.495+0.048+0.0191.18=4.781.18=4.051V_{12} = \frac{0.64 \cdot 3 + 0.49 \cdot 5 + 0.04 \cdot 8 + 0.01 \cdot 9}{1.18} = \frac{4.78}{1.18} = 4.051

For Cluster 2 (x-coordinate):

V21=0.221+0.322+0.824+0.9270.22+0.32+0.82+0.92V_{21} = \frac{0.2^2 \cdot 1 + 0.3^2 \cdot 2 + 0.8^2 \cdot 4 + 0.9^2 \cdot 7}{0.2^2 + 0.3^2 + 0.8^2 + 0.9^2}

V21=0.041+0.092+0.644+0.8170.04+0.09+0.64+0.81=8.451.58=5.35V_{21} = \frac{0.04 \cdot 1 + 0.09 \cdot 2 + 0.64 \cdot 4 + 0.81 \cdot 7}{0.04 + 0.09 + 0.64 + 0.81} = \frac{8.45}{1.58} = 5.35

For Cluster 2 (y-coordinate):

V22=0.223+0.325+0.828+0.9290.22+0.32+0.82+0.92V_{22} = \frac{0.2^2 \cdot 3 + 0.3^2 \cdot 5 + 0.8^2 \cdot 8 + 0.9^2 \cdot 9}{0.2^2 + 0.3^2 + 0.8^2 + 0.9^2}

V22=0.043+0.095+0.648+0.8191.58=12.981.58=8.215V_{22} = \frac{0.04 \cdot 3 + 0.09 \cdot 5 + 0.64 \cdot 8 + 0.81 \cdot 9}{1.58} = \frac{12.98}{1.58} = 8.215

Centroids: (1.568, 4.051) and (5.35, 8.215)

Step 3: Calculate Distances

Distances from each point to Centroid 1 (1.568, 4.051):

  • D11=(11.568)2+(34.051)2=1.2D_{11} = \sqrt{(1 - 1.568)^2 + (3 - 4.051)^2} = 1.2
  • D21=(21.568)2+(54.051)2=1.04D_{21} = \sqrt{(2 - 1.568)^2 + (5 - 4.051)^2} = 1.04
  • D31=(41.568)2+(84.051)2=4.63D_{31} = \sqrt{(4 - 1.568)^2 + (8 - 4.051)^2} = 4.63
  • D41=(71.568)2+(94.051)2=7.34D_{41} = \sqrt{(7 - 1.568)^2 + (9 - 4.051)^2} = 7.34

Distances from each point to Centroid 2 (5.35, 8.215):

  • D12=(15.35)2+(38.215)2=6.79D_{12} = \sqrt{(1 - 5.35)^2 + (3 - 8.215)^2} = 6.79
  • D22=(25.35)2+(58.215)2=4.64D_{22} = \sqrt{(2 - 5.35)^2 + (5 - 8.215)^2} = 4.64
  • D32=(45.35)2+(88.215)2=1.36D_{32} = \sqrt{(4 - 5.35)^2 + (8 - 8.215)^2} = 1.36
  • D42=(75.35)2+(98.215)2=1.82D_{42} = \sqrt{(7 - 5.35)^2 + (9 - 8.215)^2} = 1.82

Step 4: Update Membership Values

For Point 1 (1, 3):

γ11=((1.2)2(1.2)2+(1.2)2(6.79)2)1=0.97\gamma_{11} = \left(\frac{(1.2)^2}{(1.2)^2} + \frac{(1.2)^2}{(6.79)^2}\right)^{-1} = 0.97

γ12=((6.79)2(1.2)2+(6.79)2(6.79)2)1=0.03\gamma_{12} = \left(\frac{(6.79)^2}{(1.2)^2} + \frac{(6.79)^2}{(6.79)^2}\right)^{-1} = 0.03

For Point 2 (2, 5):

γ21=((1.04)2(1.04)2+(1.04)2(4.64)2)1=0.95\gamma_{21} = \left(\frac{(1.04)^2}{(1.04)^2} + \frac{(1.04)^2}{(4.64)^2}\right)^{-1} = 0.95

γ22=((4.64)2(1.04)2+(4.64)2(4.64)2)1=0.05\gamma_{22} = \left(\frac{(4.64)^2}{(1.04)^2} + \frac{(4.64)^2}{(4.64)^2}\right)^{-1} = 0.05

For Point 3 (4, 8):

γ31=((4.63)2(4.63)2+(4.63)2(1.36)2)1=0.08\gamma_{31} = \left(\frac{(4.63)^2}{(4.63)^2} + \frac{(4.63)^2}{(1.36)^2}\right)^{-1} = 0.08

γ32=((1.36)2(4.63)2+(1.36)2(1.36)2)1=0.92\gamma_{32} = \left(\frac{(1.36)^2}{(4.63)^2} + \frac{(1.36)^2}{(1.36)^2}\right)^{-1} = 0.92

For Point 4 (7, 9):

γ41=((7.34)2(7.34)2+(7.34)2(1.82)2)1=0.06\gamma_{41} = \left(\frac{(7.34)^2}{(7.34)^2} + \frac{(7.34)^2}{(1.82)^2}\right)^{-1} = 0.06

γ42=((1.82)2(7.34)2+(1.82)2(1.82)2)1=0.94\gamma_{42} = \left(\frac{(1.82)^2}{(7.34)^2} + \frac{(1.82)^2}{(1.82)^2}\right)^{-1} = 0.94

Updated Membership Matrix:

Cluster(1, 3)(2, 5)(4, 8)(7, 9)
10.970.950.080.06
20.030.050.920.94

Step 5: Convergence Check

Compare the updated membership values with the initial values. If the maximum change is less than the tolerance (e.g., 0.01), stop. Otherwise, repeat steps 2-4 with the new membership values.

In this example, the changes are significant (e.g., point 1 changed from 0.8 to 0.97), so we would continue iterating until convergence.

Key Concepts

Fuzziness Parameter (m)

The fuzziness parameter controls how "fuzzy" the clusters are:

  • m = 1: Hard clustering (equivalent to K-Means)
  • m = 2: Standard fuzzy clustering (most commonly used)
  • m > 2: More fuzziness, points can belong equally to multiple clusters

Membership Interpretation

For a point with memberships [0.97, 0.03]:

  • The point belongs 97% to cluster 1
  • The point belongs 3% to cluster 2
  • This indicates strong membership in cluster 1

Applications

Fuzzy C-Means is widely used in:

  • Image segmentation
  • Pattern recognition
  • Bioinformatics
  • Customer segmentation
  • Medical diagnosis
  • Data analysis with overlapping categories

Advantages

  1. Soft clustering: Points can belong to multiple clusters
  2. Flexibility: Better handles overlapping clusters
  3. Robustness: Less sensitive to initialization than hard clustering
  4. Interpretability: Membership degrees provide additional information

Limitations

  1. Convergence: May converge to local optima
  2. Cluster number: Requires pre-specification of the number of clusters
  3. Computational cost: More expensive than K-Means
  4. Noise sensitivity: Sensitive to outliers and noise

Summary

Fuzzy C-Means is an iterative algorithm that:

  1. Initializes membership values randomly
  2. Calculates cluster centroids based on weighted memberships
  3. Computes distances from points to centroids
  4. Updates membership values based on distances
  5. Repeats until convergence

The algorithm produces soft cluster assignments where each data point has a membership degree to each cluster, providing a more nuanced view of the data structure compared to hard clustering methods.