Rand index

From HandWiki
Short description: Measure of similarity between two data clusterings
Example clusterings for a dataset with the kMeans (left) and Mean shift (right) algorithms. The calculated Adjusted Rand index for these two clusterings is [math]\displaystyle{ ARI \approx 0.94 }[/math]

The Rand index[1] or Rand measure (named after William M. Rand) in statistics, and in particular in data clustering, is a measure of the similarity between two data clusterings. A form of the Rand index may be defined that is adjusted for the chance grouping of elements, this is the adjusted Rand index. The Rand index is the accuracy of determining if a link belongs within a cluster or not.

Rand index

Definition

Given a set of [math]\displaystyle{ n }[/math] elements [math]\displaystyle{ S = \{o_1, \ldots, o_n\} }[/math] and two partitions of [math]\displaystyle{ S }[/math] to compare, [math]\displaystyle{ X = \{X_1, \ldots, X_r\} }[/math], a partition of S into r subsets, and [math]\displaystyle{ Y = \{Y_1, \ldots, Y_s\} }[/math], a partition of S into s subsets, define the following:

  • [math]\displaystyle{ a }[/math], the number of pairs of elements in [math]\displaystyle{ S }[/math] that are in the same subset in [math]\displaystyle{ X }[/math] and in the same subset in [math]\displaystyle{ Y }[/math]
  • [math]\displaystyle{ b }[/math], the number of pairs of elements in [math]\displaystyle{ S }[/math] that are in different subsets in [math]\displaystyle{ X }[/math] and in different subsets in [math]\displaystyle{ Y }[/math]
  • [math]\displaystyle{ c }[/math], the number of pairs of elements in [math]\displaystyle{ S }[/math] that are in the same subset in [math]\displaystyle{ X }[/math] and in different subsets in [math]\displaystyle{ Y }[/math]
  • [math]\displaystyle{ d }[/math], the number of pairs of elements in [math]\displaystyle{ S }[/math] that are in different subsets in [math]\displaystyle{ X }[/math] and in the same subset in [math]\displaystyle{ Y }[/math]

The Rand index, [math]\displaystyle{ R }[/math], is:[1][2]

[math]\displaystyle{ R = \frac{a+b}{a+b+c+d} = \frac{a+b}{{n \choose 2 }} }[/math]

Intuitively, [math]\displaystyle{ a + b }[/math] can be considered as the number of agreements between [math]\displaystyle{ X }[/math] and [math]\displaystyle{ Y }[/math] and [math]\displaystyle{ c + d }[/math] as the number of disagreements between [math]\displaystyle{ X }[/math] and [math]\displaystyle{ Y }[/math].

Since the denominator is the total number of pairs, the Rand index represents the frequency of occurrence of agreements over the total pairs, or the probability that [math]\displaystyle{ X }[/math] and [math]\displaystyle{ Y }[/math] will agree on a randomly chosen pair.

[math]\displaystyle{ {n \choose 2 } }[/math] is calculated as [math]\displaystyle{ n(n-1)/2 }[/math].

Similarly, one can also view the Rand index as a measure of the percentage of correct decisions made by the algorithm. It can be computed using the following formula:

[math]\displaystyle{ RI = \frac {TP + TN} {TP + FP + FN + TN} }[/math]
where [math]\displaystyle{ TP }[/math] is the number of true positives, [math]\displaystyle{ TN }[/math] is the number of true negatives, [math]\displaystyle{ FP }[/math] is the number of false positives, and [math]\displaystyle{ FN }[/math] is the number of false negatives.

Properties

The Rand index has a value between 0 and 1, with 0 indicating that the two data clusterings do not agree on any pair of points and 1 indicating that the data clusterings are exactly the same.

In mathematical terms, a, b, c, d are defined as follows:

  • [math]\displaystyle{ a = |S^{*}| }[/math], where [math]\displaystyle{ S^{*} = \{ (o_{i}, o_{j}) \mid o_{i}, o_{j} \in X_{k}, o_{i}, o_{j} \in Y_{l}\} }[/math]
  • [math]\displaystyle{ b = |S^{*}| }[/math], where [math]\displaystyle{ S^{*} = \{ (o_{i}, o_{j}) \mid o_{i} \in X_{k_{1}}, o_{j} \in X_{k_{2}}, o_{i} \in Y_{l_{1}}, o_{j} \in Y_{l_{2}}\} }[/math]
  • [math]\displaystyle{ c = |S^{*}| }[/math], where [math]\displaystyle{ S^{*} = \{ (o_{i}, o_{j}) \mid o_{i}, o_{j} \in X_{k}, o_{i} \in Y_{l_{1}}, o_{j} \in Y_{l_{2}}\} }[/math]
  • [math]\displaystyle{ d = |S^{*}| }[/math], where [math]\displaystyle{ S^{*} = \{ (o_{i}, o_{j}) \mid o_{i} \in X_{k_{1}}, o_{j} \in X_{k_{2}}, o_{i}, o_{j} \in Y_{l}\} }[/math]

for some [math]\displaystyle{ 1 \leq i,j \leq n, i \neq j, 1 \leq k, k_{1}, k_{2} \leq r, k_{1} \neq k_{2}, 1 \leq l, l_{1},l_{2} \leq s, l_{1} \neq l_{2} }[/math]

Relationship with classification accuracy

The Rand index can also be viewed through the prism of binary classification accuracy over the pairs of elements in [math]\displaystyle{ S }[/math]. The two class labels are "[math]\displaystyle{ o_{i} }[/math] and [math]\displaystyle{ o_{j} }[/math] are in the same subset in [math]\displaystyle{ X }[/math] and [math]\displaystyle{ Y }[/math]" and "[math]\displaystyle{ o_{i} }[/math] and [math]\displaystyle{ o_{j} }[/math] are in different subsets in [math]\displaystyle{ X }[/math] and [math]\displaystyle{ Y }[/math]".

In that setting, [math]\displaystyle{ a }[/math] is the number of pairs correctly labeled as belonging to the same subset (true positives), and [math]\displaystyle{ b }[/math] is the number of pairs correctly labeled as belonging to different subsets (true negatives).

Adjusted Rand index

The adjusted Rand index is the corrected-for-chance version of the Rand index.[1][2][3] Such a correction for chance establishes a baseline by using the expected similarity of all pair-wise comparisons between clusterings specified by a random model. Traditionally, the Rand Index was corrected using the Permutation Model for clusterings (the number and size of clusters within a clustering are fixed, and all random clusterings are generated by shuffling the elements between the fixed clusters). However, the premises of the permutation model are frequently violated; in many clustering scenarios, either the number of clusters or the size distribution of those clusters vary drastically. For example, consider that in K-means the number of clusters is fixed by the practitioner, but the sizes of those clusters are inferred from the data. Variations of the adjusted Rand Index account for different models of random clusterings.[4]

Though the Rand Index may only yield a value between 0 and +1, the adjusted Rand index can yield negative values if the index is less than the expected index.[5]

The contingency table

Given a set S of n elements, and two groupings or partitions (e.g. clusterings) of these elements, namely [math]\displaystyle{ X = \{ X_1, X_2, \ldots , X_r \} }[/math] and [math]\displaystyle{ Y = \{ Y_1, Y_2, \ldots , Y_s \} }[/math], the overlap between X and Y can be summarized in a contingency table [math]\displaystyle{ \left[n_{ij}\right] }[/math] where each entry [math]\displaystyle{ n_{ij} }[/math] denotes the number of objects in common between [math]\displaystyle{ X_i }[/math] and [math]\displaystyle{ Y_j }[/math] : [math]\displaystyle{ n_{ij}=|X_i \cap Y_j| }[/math].

[math]\displaystyle{ \begin{array}{c|cccc|c} {{} \atop X}\!\diagdown\!^Y & Y_1& Y_2& \cdots& Y_s& \text{sums} \\ \hline X_1& n_{11}& n_{12}& \cdots& n_{1s}& a_1 \\ X_2& n_{21}& n_{22}& \cdots& n_{2s}& a_2 \\ \vdots& \vdots& \vdots& \ddots& \vdots& \vdots \\ X_r& n_{r1}& n_{r2}& \cdots& n_{rs}& a_r \\ \hline \text{sums}& b_1& b_2& \cdots& b_s& \end{array} }[/math]

Definition

The original Adjusted Rand Index using the Permutation Model is

[math]\displaystyle{ ARI = \frac{ \left. \sum_{ij} \binom{n_{ij}}{2} - \left[\sum_i \binom{a_i}{2} \sum_j \binom{b_j}{2}\right] \right/ \binom{n}{2} }{ \left. \frac{1}{2} \left[\sum_i \binom{a_i}{2} + \sum_j \binom{b_j}{2}\right] - \left[\sum_i \binom{a_i}{2} \sum_j \binom{b_j}{2}\right] \right/ \binom{n}{2} } }[/math]

where [math]\displaystyle{ n_{ij}, a_i, b_j }[/math] are values from the contingency table.

See also

References

  1. 1.0 1.1 1.2 W. M. Rand (1971). "Objective criteria for the evaluation of clustering methods". Journal of the American Statistical Association (American Statistical Association) 66 (336): 846–850. doi:10.2307/2284239. 
  2. 2.0 2.1 Lawrence Hubert and Phipps Arabie (1985). "Comparing partitions". Journal of Classification 2 (1): 193–218. doi:10.1007/BF01908075. 
  3. Nguyen Xuan Vinh, Julien Epps and James Bailey (2009). "Information Theoretic Measures for Clustering Comparison: Is a Correction for Chance Necessary?". ACM. pp. 1073–1080. PDF.
  4. Alexander J Gates and Yong-Yeol Ahn (2017). "The Impact of Random Models on Clustering Similarity". Journal of Machine Learning Research 18: 1–28. 
  5. "Comparing Clusterings - An Overview". https://i11www.iti.kit.edu/extra/publications/ww-cco-06.pdf. 

External links