Overview
Membership matrices define how points are assigned to clusters. The library provides two types of membership calculations:- Crisp membership: Each point belongs to exactly one cluster (binary assignment)
- Fuzzy membership: Each point can partially belong to multiple clusters (probabilistic assignment)
getMembershipMatrix
Generates a crisp membership matrix from a distance matrix. Each point is assigned to exactly one cluster based on the nearest centroid.Parameters
Matrix of distances between points and centroids, where
distanceMatrix[i][j] represents the distance between centroid i and point j.Returns
A membership matrix where each element
[i][j] is 1 if the j-th point belongs to the i-th centroid, otherwise 0. Returns an empty array if the distance matrix is empty.Example
In crisp clustering, each point belongs to exactly one cluster. The membership value is binary: either 1 (belongs) or 0 (does not belong).
getFuzzyMembershipMatrix
Calculates a fuzzy membership matrix given a distance matrix and a fuzzification parameter. Points can have partial membership in multiple clusters.Parameters
Matrix of distances between points and centroids, where
distanceMatrix[i][j] represents the distance between centroid i and point j.Fuzzification parameter (typically denoted as
m). Controls the degree of fuzziness in the clustering. Common values are between 1.5 and 3, with 2 being the most common choice.- Values closer to 1 make the clustering more crisp
- Higher values make the clustering more fuzzy
Returns
A fuzzy membership matrix where each element
[i][j] represents the degree of membership (between 0 and 1) of point j to cluster i. The sum of memberships for each point across all clusters equals 1. Returns an empty array if the distance matrix is empty.Example
In fuzzy clustering, each point has a membership degree in all clusters, with values between 0 and 1. The membership values for each point across all clusters sum to 1.
Mathematical Formula
The fuzzy membership value is calculated using:uᵢⱼis the membership of pointjto clusteridᵢⱼis the distance from pointjto centroidimis the fuzzification parameter- The sum is over all clusters
k
Crisp vs Fuzzy Membership
Crisp Membership
- Binary assignment: Each point belongs to exactly one cluster
- Hard boundaries: Clear separation between clusters
- Use case: When data has well-separated clusters
Fuzzy Membership
- Probabilistic assignment: Each point can belong to multiple clusters with different degrees
- Soft boundaries: Gradual transition between clusters
- Use case: When data has overlapping clusters or unclear boundaries