Affinity Propagation

Affinity Propagation

Affinity Propagation is a machine learning algorithm used for clustering data points. Unlike traditional clustering methods such as K-means or hierarchical clustering, Affinity Propagation does not require the number of clusters to be determined in advance. Instead, it uses a message-passing mechanism to identify exemplars among the data points, which become the centers of the clusters.


Affinity Propagation, introduced by Brendan J. Frey and Delbert Dueck in 2007, is a clustering algorithm based on the concept of “message passing” between data points. It operates by sending messages between pairs of data points until a set of high-quality exemplars - representative data points that best typify each cluster - emerges.

How it Works

Affinity Propagation begins by constructing a similarity matrix for all pairs of data points. The similarity is typically measured as the negative Euclidean distance between points, but other measures can also be used depending on the nature of the data.

The algorithm then proceeds through two main steps: the responsibility update step and the availability update step. In the responsibility update step, each data point sends a “responsibility” message to every other data point, indicating how well-suited that point is to be its exemplar. In the availability update step, each data point sends an “availability” message to every other data point, indicating how appropriate it would be for the other point to choose it as its exemplar.

These two steps are iterated until the algorithm converges, resulting in a set of exemplars and corresponding clusters.


Affinity Propagation has been used in a variety of applications, including image recognition, gene expression analysis, and network routing. Its ability to automatically determine the number of clusters makes it particularly useful in situations where the structure of the data is not known in advance.


  1. Automatic determination of clusters: Unlike many clustering algorithms, Affinity Propagation does not require the user to specify the number of clusters in advance.

  2. Identification of exemplars: The algorithm identifies representative data points for each cluster, which can provide additional insights into the structure of the data.


  1. Computational complexity: Affinity Propagation has a time complexity of O(N^2*T), where N is the number of data points and T is the number of iterations. This makes it less suitable for large datasets.

  2. Sensitivity to parameter settings: The algorithm’s performance can be highly sensitive to the choice of its damping factor and preference parameter.

Key Takeaways

Affinity Propagation is a powerful clustering algorithm that can automatically determine the number of clusters and identify representative data points. However, its computational complexity and sensitivity to parameter settings can limit its applicability in certain scenarios. Despite these limitations, it remains a valuable tool in the data scientist’s toolkit for exploratory data analysis and pattern recognition tasks.