Skip to content
coden

Fuzzy clustering: the fuzzy c-means algorithm and points between clusters

K-means and its hard assignment, fuzzy c-means with memberships in all clusters, the fuzzifier m, the partition coefficient and the Xie–Beni index for choosing the number of clusters — and why outliers get high memberships.

13 minutes Matěj Žalmánek 2026-10-15

Series AI basics Part 36 of 52
  1. Map of artificial intelligence: what is what and how it all fits together
  2. A brief history of artificial intelligence: from Turing to language models
  3. Data, model, training, inference: the basic terms on a single example
  4. How to read mathematical notation: symbols, indices, sums and quantifiers
  5. Sets and relations: the building blocks of definitions in AI
  6. Functions and mappings: why every AI model is a function
  7. Logic and proofs: the rules AI reasons by
  8. Graphs and trees: the structure that both search and neural networks stand on
  9. Linear algebra for machine learning: vectors, matrices and why AI mostly multiplies
  10. Derivatives, the gradient and the chain rule: how a model finds out which way to learn
  11. Gradient descent: how a model learns
  12. What probability is: from rolling dice to the Kolmogorov axioms
  13. Conditional probability and Bayes’ theorem: how to update your estimate when you learn something new
  14. Random variables and the cumulative distribution function: one function that tells you everything about a distribution
  15. Probability density and probability mass functions: why a continuous variable has zero probability at a point
  16. Expected value, variance and covariance: where a distribution lies, how wide it is and what goes with what
  17. Overview of probability distributions: Bernoulli, binomial, Poisson, uniform, normal and exponential
  18. Law of large numbers and central limit theorem: why averages behave so predictably
  19. Statistics and parameter estimation: maximum likelihood, MAP and confidence intervals
  20. Information theory: entropy, cross-entropy and KL divergence — where loss functions come from
  21. State-space search: BFS, DFS, UCS and A* with animations
  22. Games and adversaries: minimax, alpha-beta pruning and Monte Carlo tree search
  23. Constraint satisfaction: backtracking, constraint propagation and AC-3 on sudoku and a map of Czech regions
  24. Logic and knowledge systems: forward and backward chaining, resolution and expert systems
  25. Planning: STRIPS, the blocks world, heuristics from relaxation and planning in AI agents
  26. Local search and simulated annealing: a travelling salesman through the Czech regional capitals
  27. Genetic algorithms: population, crossover, mutation and selection on a backpack for a hike
  28. Evolution strategies and genetic programming: from the one-fifth rule to Kepler’s law
  29. Ant colony optimization: how a pheromone trail finds a short path
  30. Particle swarm optimisation: inertia, personal experience and the swarm’s experience
  31. Neuroevolution: evolving the weights and shape of neural networks, and the NEAT algorithm
  32. Fuzzy sets and membership functions: how to write down “somewhat warm”
  33. Fuzzy logic and probability: why “somewhat warm” does not mean “probably warm”
  34. Fuzzy logic: t-norms, implications and IF–THEN rules
  35. Fuzzy control: Mamdani and Sugeno from a fan to a pole on a cart
  36. Fuzzy clustering: the fuzzy c-means algorithm and points between clusters
  37. Neuro-fuzzy systems (ANFIS): fuzzy rules that learn from data
  38. Markov chains: the transition matrix, the stationary distribution and PageRank
  39. Hidden Markov models: the Viterbi algorithm and the dishonest casino
  40. Bayesian networks: why the grass is wet and what it means for the sprinkler
  41. The Kalman filter: how to estimate where a car is and how fast it goes from imprecise measurements
  42. Types of machine learning: supervised, unsupervised, semi-supervised and more
  43. Prompts, context and RAG: how to give a model the right information
  44. Variational autoencoders (VAE): new images from a continuous latent space
  45. Generative adversarial networks (GAN): the forger versus the detective
  46. Diffusion models: how pure noise becomes an image
  47. Markov decision processes: states, actions, rewards and the Bellman equations
  48. Q-learning and DQN: learning the value of actions, from a table to a neural network
  49. Policy gradient and PPO: learning the policy directly
  50. How an AI agent works: a language model in a loop with tools
  51. Programming with AI agents: the task, tests and review
  52. Evaluating and securing AI systems: how to measure and how to keep watch

Full series syllabus 52 of 83 topics published

What you will take away
  • How k-means works and what it keeps quiet about points on the boundary between clusters.
  • How fuzzy c-means computes memberships and centres, and what the fuzzifier m does.
  • How to choose the number of clusters and where fuzzy c-means fails.

Useful to know first: Fuzzy sets and membership functions: how to write down “somewhat warm”, Types of machine learning: supervised, unsupervised, semi-supervised and more

Clustering looks for groups in data that we know nothing about in advance: customers with similar shopping behaviour, regions of the same tissue in a magnetic resonance image, documents on a similar topic. The classic k-means algorithm assigns every point to exactly one group. But real data tend to have points on the boundary — a customer who shops a bit like a student and a bit like a parent, a pixel where the grey and white matter of the brain meet. Fuzzy clustering lets a point belong to several groups at once, to each of them a little.

It builds on the articles Fuzzy sets and membership functions and Types of machine learning, where clustering appeared as a typical unsupervised learning task.

1. Hard clustering: k-means

Definition — the k-means problem

Let d ≥ 1 and n ≥ 1 be natural numbers, x1, …, xn ∈ ℝd points and c ∈ ℕ, 1 ≤ c ≤ n, the number of clusters. An assignment is a mapping shluk : {1, …, n} → {1, …, c} that assigns to the point xi the number of its cluster. For centres v1, …, vc ∈ ℝd and an assignment shluk the cost is

J(v1, …, vc, shluk) = ∑i=1n ‖xi − vshluk(i)‖2,

where ‖·‖ is the Euclidean distance (next definition). The k-means problem is to find centres and an assignment for which J is as small as possible.

Lloyd's algorithm (an approximate solution of the k-means problem). Input: points x1, …, xn ∈ ℝd and the number of clusters c. Output: centres v1, …, vc and an assignment shluk. Steps:

  1. As the initial centres choose c mutually distinct points from x1, …, xn (at random).
  2. Assignment: for every i = 1, …, n choose shluk(i) ∈ argminj ∈ {1, …, c} ‖xi − vj‖2; if there are several nearest centres and the point’s current centre is among them, leave the point in its cluster.
  3. Stopping: if the assignment has not changed since the previous pass, stop and return the centres and the assignment.
  4. Centres: for every j = 1, …, c let Sj = {i : shluk(i) = j} and, if Sj ≠ ∅, set vj = 1/|Sj| ∑i ∈ Sj xi (the mean of the cluster’s points; an empty cluster does not change its centre).
  5. Continue with step 2.
In plain words

You place a few “flags” in the data. Every point joins the nearest one. Then each flag moves to the middle of its points. The points join the nearest flag again — and so on, until nothing changes. Every step decreases J, so the algorithm is sure to stop, though not necessarily at the best possible partition.

Definition — Euclidean distance

Let d ≥ 1 and x = (x1, …, xd), v = (v1, …, vd) ∈ ℝd. The Euclidean distance of the points x and v is the non-negative number

‖x − v‖ = √∑r=1d (xr − vr)2.

In the plane (d = 2) it is the ordinary length of a line segment, for instance from the point M1 = (4.5, 2.5) to the centre of cluster A (1.73, 2.31) as fuzzy c-means finds it below: √2.772 + 0.192 ≈ 2.78. Clustering works with the square ‖·‖2 — the square root goes away and distant points are penalised more.

def kmeans(X, c):
    V = c randomly chosen points from X           # initial centres
    while True:
        shluk = [argmin_j ‖x − V[j]‖² for x in X]  # assignment step
        if shluk did not change: return V, shluk
        for j in range(c):                         # centre step
            V[j] = mean of the points x with shluk(x) = j
Theorem — Lloyd's algorithm terminates

Let x1, …, xn ∈ ℝd, 1 ≤ c ≤ n, and let Lloyd's algorithm run according to the definition above (including the rule that on a tie the point stays in its cluster). Then

  1. no assignment step and no centre step increases the value of J;
  2. the algorithm stops after finitely many passes.

Proof: Assignment: each term ‖xi − vshluk(i)‖2 is replaced by the smallest of all ‖xi − vj‖2, so it does not increase. Centres: for a non-empty index set S of one cluster with mean x̄ = 1/|S| ∑i∈S xi and any v ∈ ℝd the decomposition

∑i∈S ‖xi − v‖2 = ∑i∈S ‖xi − x̄‖2 + |S| · ‖x̄ − v‖2

holds (the cross term 2 ∑ (xi − x̄) · (x̄ − v) is zero because ∑ (xi − x̄) = 0). The sum is therefore smallest for v = x̄. There are finitely many partitions of n points into c clusters and J strictly decreases with every change of assignment (on a tie we leave the point in its cluster), so no partition repeats. ∎

The theorem says nothing about whether the partition found is the one with the smallest J — only that the algorithm will not cycle.

Our data: three groups of 40 points — A at the bottom left, B on the right and C at the top —, four points on the boundary (M1–M4) and two outliers far from everything (O1, O2). K-means settled after four iterations:

00551010 feature x₁ (unitless) feature x₂ (unitless) M1 M2 M3 M4 O1 O2
k-means: every point belongs to exactly one cluster

It found the clusters well, but had to decide the boundary points: it put M1, M3 and M4 into B, M2 into A. Yet M3 lies almost exactly between B and C — k-means tells you nothing about that. And both outliers ended up in cluster C, as if they belonged to it just as much as its core.

2. Fuzzy c-means

Definition — fuzzy c-means (Dunn 1973, Bezdek 1981)

Let x1, …, xn ∈ ℝd be points, c ∈ ℕ, 2 ≤ c < n, the number of clusters and m ∈ ℝ, m > 1, the fuzzifier. A membership matrix is an n × c matrix U = (uij) (i = 1, …, n numbers the points, j = 1, …, c the clusters) that satisfies

  1. uij ∈ [0, 1] for all i, j;
  2. ∑j=1c uij = 1 for every i — every point splits a total membership of 1 among the clusters;
  3. 0 < ∑i=1n uij < n for every j — no cluster is empty and none swallows all points completely.

For a membership matrix U and centres V = (v1, …, vc) ∈ (ℝd)c the cost is

Jm(U, V) = ∑i=1n ∑j=1c uijm ‖xi − vj‖2.

Fuzzy c-means is the problem of finding U and V with the smallest cost Jm, and the following algorithm for solving it approximately. Input: the points, c, m, a tolerance ε > 0 and a maximum number of iterations. Output: U and V. Steps:

  1. Choose initial centres v1, …, vc (e.g. c distinct random points).
  2. Memberships: for all i, j compute dij = ‖xi − vj‖ (we assume dij > 0) and uij = 1/∑k=1c (dij/dik)2/(m−1).
  3. Stopping: if no uij has changed by ε or more since the previous pass, or the number of iterations is exhausted, stop (not after the first pass) and return U and V.
  4. Centres: for every j = 1, …, c set vj = ∑i=1n uijm xi/∑i=1n uijm and continue with step 2.

Both computational steps follow from the optimality conditions (theorem below): each minimises Jm with the other group of variables fixed.

In plain words

Every point splits its single unit among all clusters — more to the one it is closer to. The centre of a cluster is a weighted mean of all points: points that belong to the cluster strongly pull it more, points from other clusters only slightly. The membership formula compares distances: if a point is twice as close to one centre as to the other, it gets (for m = 2) four times the membership.

Jm = ∑i=1n ∑j=1c uijm ‖xi − vj‖2,    ∑j uij = 1

Jm
the total “cost” of the partition — the algorithm minimises it; it is small when points belong mainly to centres that are close to them
∑i ∑j
every point counts towards every cluster — unlike k-means, where only one cluster per point was taken
uij
the membership of point i in cluster j — the weight with which the distance enters the cost
m
the fuzzifier — without the power (m = 1) it would pay to give the whole unit to the nearest centre and we would get k-means again; with m > 1 splitting pays off: a point equally far from two centres pays, for m = 2 and an even split, only (½2 + ½2) · d2 = ½d2 instead of d2
‖xi − vj‖2
the squared distance — what it costs to keep the point “at” this centre; a distant centre comes out expensive
∑j uij = 1
the constraint — without it the minimum would be trivial: all uij = 0 and zero cost

uij = 1/∑k=1c ( dij/dik )2/(m−1)

uij
the new membership of point i in cluster j with the centres fixed
dij/dik
the ratio of distances — how many times farther centre j is than centre k; the ratio (not the difference) makes the result independent of the scale of the data
exponent 2/m − 1
how sharply the ratio decides — for m = 2 it is 2, so a centre twice as close gets four times as much; for m → 1 the exponent grows without bound and the nearest centre gets everything
∑k
a comparison with all centres including j itself (the term k = j is 1) — thanks to this the memberships of a point add up to exactly 1
For m = 2 the formula simplifies to uij = 1/dij2/∑k 1/dik2: the membership is proportional to the inverse square of the distance.
Theorem — where the two steps come from

Let x1, …, xn ∈ ℝd, c and m > 1 be as in the definition of fuzzy c-means. Then:

  1. For fixed centres v1, …, vc for which all distances dij = ‖xi − vj‖ are positive, Jm attains its minimum over the set of matrices with uij ≥ 0 and ∑j uij = 1 exactly at uij = 1/∑k=1c (dij/dik)2/(m−1).
  2. For a fixed matrix U in which ∑i uijm > 0 for every j, Jm attains its minimum over v1, …, vc ∈ ℝd exactly at vj = ∑i uijm xi/∑i uijm.

Proof. Memberships with the centres fixed. Jm is a sum over the points and each constraint concerns a single row of U, so it suffices to minimise, for one point i, ∑j uijm dij2 subject to ∑j uij = 1. The Lagrangian is L = ∑j uijm dij2 − λ (∑j uij − 1). From ∂L/∂uij = m uijm−1 dij2 − λ = 0 it follows that uij = (λ/m)1/(m−1) · dij−2/(m−1). Substituting into the sum constraint, the unknown λ cancels out and we are left with

uij = dij−2/(m−1)/∑k dik−2/(m−1) = 1/∑k (dij/dik)2/(m−1).

The results are positive numbers, so the constraint uij ≥ 0 need not be enforced separately. The function u ↦ um d2 is strictly convex on [0, 1] for m > 1 and d > 0, so this single stationary point is the minimum. (If a point lies exactly at a centre, dij = 0, it gets membership 1 in that cluster; our implementation handles this by never letting the distance drop below 10−12.)

Centres with the memberships fixed. Jm is a convex quadratic function of vj (strictly convex, because ∑i uijm > 0), and ∂Jm/∂vj = −2 ∑i uijm (xi − vj) = 0 gives vj = ∑i uijm xi/∑i uijm. ∎

Each step therefore minimises Jm with the other group of variables fixed and cannot increase it — the same argument as for k-means. Bezdek et al. (1987, a correction of Bezdek's original 1980 theorem) showed that the sequence has its accumulation points at stationary points of Jm (not necessarily at the global minimum).

import numpy as np

def fcm(X, c, m=2.0, iteraci=100, eps=1e-5):
    U = np.random.dirichlet(np.ones(c), size=len(X))        # random memberships, row = 1
    for _ in range(iteraci):
        W = U ** m
        V = (W.T @ X) / W.sum(axis=0)[:, None]             # centres as weighted means
        D = np.linalg.norm(X[:, None, :] - V[None, :, :], axis=2) + 1e-12
        nove = 1 / ((D[:, :, None] / D[:, None, :]) ** (2 / (m - 1))).sum(axis=2)
        if np.abs(nove - U).max() < eps:
            return V, nove
        U = nove
    return V, U

3. Fuzzy c-means on our data

The colour of a point is now a mix of the cluster colours according to the memberships: a pure green point belongs only to A, a point “between” green and orange is partly in A and partly in B. The dotted lines show how the centres moved — the algorithm settled after nine iterations:

00551010 feature x₁ (unitless) feature x₂ (unitless) M1 M2 M3 M4 O1 O2
Fuzzy c-means (m = 2): colour is a mix by membership
Pointk-meansABC
M1 (4.5, 2.5)B0.410.450.15
M2 (3.3, 4.5)A0.430.180.38
M3 (5.8, 5)B0.120.440.45
M4 (4.6, 4)B0.280.400.32

Now you can see what k-means kept quiet about. M1 is almost halfway between A and B; M3 is actually a hair more in C than in B, although k-means put it in B; and M4 in the middle of the triangle belongs a little to all three. Points in the cores of the clusters have a membership close to one in their own cluster. The centres came out practically the same as with k-means — fuzzy c-means does not change where the clusters are, but adds information about how surely each point belongs to them.

Example — memberships of the point M1 = (4.5, 2.5)

Centres after nine iterations: A ≈ (1.73, 2.31), B ≈ (7.12, 2.87), C ≈ (4.51, 7.11). For m = 2 the inverse squared distances are enough (colours as in the simplified formula for m = 2 in the caption above):

Clusterd21/d2u = 1/d2/0.3190
A2.772 + 0.192 ≈ 7.720.12960.41
B2.622 + 0.372 ≈ 7.030.14230.45
C0.012 + 4.612 ≈ 21.250.04710.15
sum0.31901.00

M1 is almost equally far from centres A and B (7.72 versus 7.03), and so it splits between them almost in half; C is three times farther (in squared terms), so it gets only the remainder.

4. The fuzzifier m

Definition — partition coefficient

Let n ≥ 1, c ≥ 2 and let U = (uij) be an n × c matrix with uij ∈ [0, 1] and ∑j=1c uij = 1 for every i (a membership matrix). The partition coefficient is the number

PC(U) = 1/n ∑i=1n ∑j=1c uij2.

It always holds that 1/c ≤ PC(U) ≤ 1, where

  1. PC(U) = 1 if and only if the partition is hard: in every row one uij = 1 and the others are 0;
  2. PC(U) = 1/c if and only if uij = 1/c for all i, j — every point belongs to all clusters equally.

(For every row ∑j uij2 ≤ ∑j uij = 1 with equality only for the values 0 and 1, and by the Cauchy–Schwarz inequality ∑j uij2 ≥ 1/c (∑j uij)2 = 1/c with equality only for equal values.)

In plain words

A single number that says how “sharp” the partition is. For three clusters it lies between 1/3 (everything is blurred) and 1 (every point has a clear home).

PC = 1/n ∑i ∑j uij2

PC
the sharpness of the whole partition, a number from [1/c, 1]
1/n ∑i
an average over the points — so that data sets of different sizes can be compared
∑j uij2
the sharpness of a single point — the square “rewards” concentrated membership: (1, 0, 0) gives 1, (⅓, ⅓, ⅓) only ⅓; with the sum fixed at 1, the sum of squares is smallest when all parts are equal
The point M1 with memberships (0.41, 0.45, 0.15) contributes 0.412 + 0.452 + 0.152 ≈ 0.39; points from the cluster cores almost 1 — the average over all 126 points is 0.84.
00551010 feature x₁ (unitless) feature x₂ (unitless) m = 1.2 m = 2 m = 5 M1 M2 M3 M4 O1 O2
Fuzzy c-means for m = 1.2, 2 and 5

For m close to 1, fuzzy c-means approaches k-means: the partition coefficient is 0.98 and point M4 belongs to B with 0.79. For m = 2 the coefficient is 0.84 and for m = 5 only 0.42 — the colours blend and even a point from the core of cluster A has a membership of only 0.45 in A. For m → ∞ all memberships would tend to 1/3. The most common choice is m = 2: soft enough for the boundary points to show, and sharp enough for the clusters to stay distinct.

Example — a point twice as close to one of two centres

A point is at distance 1 from centre 1 and at distance 2 from centre 2. In the membership formula the term k = 1 equals 1 and the term k = 2 has the ratio 1/2, so u1 = 1/1 + (1/2)2/(m−1) (colours as in the formula for uij above):

  • m = 1.2: exponent 10, u1 = 1/1 + 1/1,024 ≈ 0.999 — practically a hard assignment,
  • m = 2: exponent 2, u1 = 1/1 + 1/4 = 0.8,
  • m = 5: exponent 0.5, u1 = 1/1 + 0.707 ≈ 0.586,
  • m → ∞: exponent → 0, (1/2)0 = 1 and u1 → 1/2.

In general: for m → 1+ the exponent 2/m − 1 goes to infinity, the ratios dij/dik < 1 go to zero and those > 1 to infinity, so the nearest centre gets 1 and the others 0 (k-means). For m → ∞ the exponent goes to zero, all c terms of the sum tend to 1 and uij → 1/c.

5. How many clusters?

The number of clusters has to be given to the algorithm. When we do not know it, we run the algorithm for different c and compare the quality of the partitions. The partition coefficient and the Xie–Beni index are useful for this.

Definition — Xie–Beni index

Let x1, …, xn ∈ ℝd, c ≥ 2, m > 1, U = (uij) an n × c membership matrix and v1, …, vc ∈ ℝd mutually distinct centres (typically the result of fuzzy c-means). The Xie–Beni index is the number

XB(U, V) = ∑i=1n ∑j=1c uijm ‖xi − vj‖2/n · minj ≠ k ‖vj − vk‖2.

The denominator is positive because the centres are distinct. Xie and Beni (1991) introduced the index with exponent 2 (i.e. for m = 2); with a general m it is commonly used in the same form. When comparing partitions, the one with the smaller XB is better.

In plain words

The numerator measures how tightly the points sit around their centres; the denominator, how far apart the two nearest centres are. A good partition has compact clusters that are far from each other.

XB = ∑i ∑j uijm ‖xi − vj‖2/n · minj ≠ k ‖vj − vk‖2

XB
the ratio of the spread within clusters to the distance between them — smaller is better
∑ ∑ uijm ‖xi − vj‖2
compactness — exactly the value of Jm that the algorithm minimised
n
the number of points — turns the numerator into an average per point, so that the index does not grow with the size of the data
minj ≠ k ‖vj − vk‖2
separation — the nearest pair of centres decides; Jm alone only decreases as clusters are added, and this term penalises a partition that splits one real cluster into two close ones
Example — the Xie–Beni index for c = 3

When the algorithm finishes, J2 ≈ 166.73. Squared distances between the centres: A–B ≈ 29.4, A–C ≈ 30.8, B–C ≈ 24.79 (B and C are the nearest). For n = 126 points (colours as in the formula above):

XB = 166.73/126 · 24.79 = 166.73/3,124 ≈ 0.053.

Number of clusters c23456
Partition coefficient (larger is better)0.7450.8410.7480.6610.609
Xie–Beni index (smaller is better)0.2280.0530.2980.6820.529

Both measures agree on the three clusters we put into the data. With real data such agreement cannot be taken for granted, and the measures are more a guide than a verdict.

6. Where fuzzy c-means fails

Look at the outliers: O1 at the top right has membership 0.45 in C and 0.39 in B; O2 at the top left even 0.58 in C. Yet they belong to no cluster. The blame lies with the constraint ∑j uij = 1: a point has to give its unit away to someone, even when it is far from everyone. Membership here means “whom it is closest to” rather than “how well it belongs here”.

Example — why O2 = (0.2, 9.5) “belongs” to C

Squared distances to the centres: A ≈ 54.07, B ≈ 91.88, C ≈ 24.29. So even the nearest centre, C, is 4.9 away — more than six times the standard deviation of 0.8 with which the cluster points are scattered around their centres. By the formula for m = 2 (colours as in the caption of the formula for uij) the reciprocals 1/54.07 ≈ 0.0185, 1/91.88 ≈ 0.0109 and 1/24.29 ≈ 0.0412 give the sum 0.0706 and the memberships

uA = 0.0185/0.0706 ≈ 0.26,   uB = 0.0109/0.0706 ≈ 0.15,   uC = 0.0412/0.0706 ≈ 0.58.

The formula sees only the ratios of the distances, not their size: the farther the point lay, the closer the ratios would get to 1 and the memberships to 1/3 — but they would never go to zero.

Definition — possibilistic c-means (Krishnapuram and Keller, 1993)

Let x1, …, xn ∈ ℝd, c ≥ 1, m > 1, v1, …, vc ∈ ℝd centres, dij = ‖xi − vj‖ and η1, …, ηc > 0 parameters chosen in advance (usually estimated from the result of fuzzy c-means). Possibilistic c-means looks for an n × c matrix U = (uij) with uij ∈ [0, 1] — without the constraint ∑j uij = 1 — and centres that minimise the cost

J(U, V) = ∑i=1n ∑j=1c uijm dij2 + ∑j=1c ηj ∑i=1n (1 − uij)m.

The second term prevents the trivial solution U = 0. With the centres fixed, the minimum is at

uij = 1/1 + (dij2/ηj)1/(m−1),

and the centres are computed as in fuzzy c-means. ηj is the “radius” of cluster j: a point at distance d2 = ηj has membership 1/2, and for m = 2 a point with d2 = 9ηj only 1/1 + 9 = 0.1. The membership now depends on the distance to a single centre, not on the ratio to the others — an outlier gets small values everywhere.

  • Possibilistic c-means (Krishnapuram and Keller, 1993) removes the sum constraint — an outlier then gets small memberships in all clusters.
  • Cluster shape. Euclidean distance produces round clusters. The Gustafson–Kessel algorithm (1979) gives each cluster its own distance matrix and finds elongated ellipses too.
  • Initial position. Just like k-means, it can end up in a worse local minimum — in practice it is run several times from different starts.

7. Fuzzy clustering in practice

  • Medical images. Segmenting magnetic resonance images of the brain into grey matter, white matter and cerebrospinal fluid is a classic application: a pixel on the boundary between tissues really does contain both.
  • Customer segmentation. A customer can belong partly to several groups, and marketing can take that into account.
  • A probabilistic relative. Gaussian mixtures trained with the EM algorithm also assign points to clusters “softly” — but by probability, not by membership. The results tend to be similar; the interpretation differs exactly as described in the article on fuzzy logic and probability.
  • Embeddings. Texts turned into vectors by a language model can be clustered the same way; the soft assignment then reveals documents that lie between topics.

8. Summary

  • K-means assigns every point to exactly one cluster and says nothing about the points on the boundary.
  • Fuzzy c-means looks for memberships uij that sum to 1 and centres as weighted means; it alternates two simple steps.
  • On our data it found the same centres as k-means and also showed that the points M1–M4 belong to two or three clusters at once.
  • The fuzzifier m controls how soft the partition is; the partition coefficient and the Xie–Beni index help choose the number of clusters.
  • The sum-to-1 constraint gives outliers high memberships; possibilistic variants fix this.

Want to get hands-on? Have an AI agent run fuzzy c-means on the pixel colours of one of your own photos and colour it by cluster — and look at which pixels lie “between” colours.

Do you see it differently? Write to support@coden-app.com.

An Agent on your computer, driven from your phone