- Introduced by
- Brendan Frey & Delbert Dueck
- Year
- 2007
- Type
- Exemplar-based clustering via message passing
What does it do?
Affinity propagation, introduced by Brendan Frey and Delbert Dueck in 2007, is a clustering algorithm that identifies representative 'exemplars' among the data by exchanging messages between every pair of points until a consistent set of clusters emerges.
Unlike k-means it does not require the number of clusters to be specified in advance — that number arises from the data and a 'preference' parameter — and it works directly from pairwise similarities, which need not be a metric.
The intuition behind the method
Picture every data point as both a candidate cluster centre and a voter. Through two kinds of message, the points negotiate. A 'responsibility' message from point i to candidate k says how well-suited k is to be i's exemplar compared with the alternatives. An 'availability' message from k back to i says how appropriate it would be for k to take on i, given the support k is getting from everyone else. These messages are passed back and forth and updated until they settle, at which point each point picks the candidate that best combines suitability and availability. Points that end up choosing themselves become the exemplars, and everyone clustered to the same exemplar forms a cluster.
History
Brendan Frey and Delbert Dueck introduced affinity propagation in Science in 2007. Instead of starting from a random subset of candidate exemplars and refining it, the method takes pairwise similarities as input and exchanges real-valued messages between data points until a set of exemplars and clusters emerges. In the paper's experiments on face images, microarray data, sentences and airline-accessible cities, the authors reported much lower clustering error than other methods and far less running time.
When to use it
Choose affinity propagation when the number of clusters is unknown and you would rather have it inferred from a preference value than fixed in advance, when cluster representatives should be actual observations, or when your input is a pairwise similarity matrix that is not a metric. The original paper applied it to face images, microarray data, sentences and airline-accessible cities, all cases where a similarity matrix is the natural input. Avoid it for very large datasets: it keeps N × N responsibility and availability matrices, so memory and time grow roughly quadratically with the number of points. If the data are large or the number of clusters is known in advance, k-means or DBSCAN are usually more practical. Expect to tune the preference and the damping, since the result depends on both.
Limitations and considerations
- Responsibility and availability are N × N matrices, so memory and per-iteration cost grow roughly quadratically with the number of points.
- The diagonal preference strongly shapes how many exemplars emerge, so the cluster count depends heavily on this single choice.
- The alternating updates need damping; without it they can oscillate rather than settle on a stable set of exemplars.
- Clusters are formed only through the similarity matrix, so an uninformative similarity measure gives poor clusters, and clusters of very different sizes or densities may be hard to recover.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Infers the number of clusters from the data together with the preference value, rather than requiring it as an input.
- Returns actual data points as exemplars, so each cluster can be inspected through a real observation.
- Needs only pairwise similarities; the update formulas do not require a feature space or a metric, so non-metric similarities can be used.
- There is no random initialization step, so the results depend on the similarity matrix, the preference and the damping setting; tie-breaking and the order of updates can also affect the outcome.
Applications
- Clustering face images from pairwise similarities, a setting used in the original paper.
- Detecting groups of genes in microarray expression data.
- Identifying representative sentences within a document.
- Selecting cities that are efficiently accessed by air travel, as in the original experiments.
- Grouping items when only a non-metric similarity matrix is available and the number of groups is unknown.
How it works
How it works
The input is a matrix of pairwise similarities s(i, k) indicating how well point k would serve as the exemplar for point i (often the negative squared distance). The diagonal s(k, k), called the preference, sets how likely each point is to become an exemplar; higher preferences yield more clusters, and a common default is the median similarity.
Formula
s(i,k)\ \text{similarity};\quad s(k,k)=\text{preference (self-similarity)}Responsibility r(i, k) is sent from point i to candidate exemplar k, measuring how suited k is to be i's exemplar relative to the best competing candidate. It subtracts the strongest alternative (availability plus similarity) from k's own similarity, so candidates compete to represent each point.
Formula
r(i,k) \leftarrow s(i,k) - \max_{k'\neq k}\big\{ a(i,k') + s(i,k') \big\}Availability a(i, k) is sent from candidate k back to point i. For i ≠ k it adds the positive responsibilities that other points send to k, together with k's self-responsibility r(k, k), and caps the total at zero, so these off-diagonal availabilities are never positive. The more support k receives from other points, the closer its availability gets to that cap, which makes k a more credible exemplar for i. The self-availability a(k, k) is updated by a different rule, so the non-positivity statement does not apply to it.
Formula
a(i,k) \leftarrow \min\!\Big\{0,\ r(k,k) + \sum_{i'\notin\{i,k\}} \max(0, r(i',k)) \Big\}Responsibilities and availabilities are updated alternately (with damping for stability) until they converge. Each point is then assigned to the candidate maximizing the sum a(i, k) + r(i, k); points that select themselves are the exemplars, and the assignments define the clusters. The number of clusters emerges from this process rather than being preset.
Formula
\text{point } i \to \arg\max_k\big[a(i,k)+r(i,k)\big];\ \text{exemplar if it chooses itself}Common pitfalls
- Accepting the default median preference without varying it, and reporting the resulting cluster count as if it were found from the data alone.
- Running the method on a large N, where the N × N message matrix becomes infeasible.
- Using too little damping, so the updates oscillate and the final exemplars are not stable.
- Treating exemplars as centroids: they are actual data points, not averages, and need not lie at the centre of their clusters.
Frequently asked questions
How does affinity propagation choose the number of clusters?
It does not take the number of clusters as input. Instead, the 'preference' value on the diagonal of the similarity matrix controls how readily points become exemplars: higher preferences produce more clusters. The actual count emerges from the message-passing process, so tuning the preference (for example, starting from the median similarity) is how you influence it.
What is an exemplar?
An exemplar is an actual data point chosen to represent a cluster; every other point in the cluster is assigned to it. Unlike k-means centroids, which are averages that may not correspond to any real observation, exemplars are real data points, which aids interpretability.
Why is affinity propagation slow on large datasets?
It maintains and updates responsibility and availability messages between all pairs of points, so it needs an N × N matrix and roughly quadratic time and memory. This makes it impractical for very large N; k-means, mini-batch variants, or DBSCAN are better choices at scale.
Related methods
Sources
Frey, B. J., & Dueck, D. (2007). Clustering by passing messages between data points. Science, 315(5814), 972–976.
Open DOI reference