In my last post, I wrote about the Rand index. This post will be on the Adjusted Rand index (ARI), which is the corrected-for-chance version of the Rand index:

Given the contingency table:

the adjusted index is:

As per usual, it’ll be easier to understand with an example. I’ll use R to create two random sets of elements, which represent clustering results.

set.seed(1) x <- sample(x = rep(1:3, 4), 12) x x [1] 1 2 3 3 2 1 1 3 3 1 2 2 set.seed(2) y <- sample(x = rep(1:3, 4), 12) y [1] 3 2 3 2 2 1 1 2 3 1 3 1

In this example there are 3 clusters in both sets, so our contingency table will have three rows and three columns. We just need to count the co-occurrences to build the contingency table. would be the number of times an element occurs in cluster 1 of X and cluster 1 of Y; this occurs three times: the sixth, seventh, and tenth elements. Here’s the full contingency table:

If you look closely at the ARI formula, there’s really just three different parts:

means the sum, refers to the row number, refers to the column number, refers to the row sum, and refers to the column sum. Now let’s work out each part.

Substituting the values into the ARI formula we get:

## Using R

The clues package contains the adjustedRand() function that can calculate the Rand index and the ARI.

# install if you haven't already install.packages("clues") # load package library(clues) set.seed(1) x <- sample(x = rep(1:3, 4), 12) set.seed(2) y <- sample(x = rep(1:3, 4), 12) adjustedRand(x, y) Rand HA MA FM Jaccard 0.63636364 0.08333333 0.25000000 0.33333333 0.20000000

The adjustedRand() function calculates:

the five agreement indices: Rand index, Hubert and Arabie’s adjusted Rand index, Morey and Agresti’s adjusted Rand index, Fowlkes and Mallows’s index, and Jaccard index, which measure the agreement between any two partitions for a data set.

I guess the formula shown on Wikipedia must be the Hubert and Arabie’s adjusted Rand index. Notice how different the Rand index is from the ARI, which makes sense since the example data used in this post is small and there would be a lot of overlaps just due to chance.

This work is licensed under a Creative Commons

Attribution 4.0 International License.

Hi Dave

First of all nice post and nice post on the difference between Rand index and the adjusted Rand index.

I have staring at the contigency table and try to make sense of sense of sentence:

Element occurs in cluster 1 of X and cluster 1 of Y; this occurs three times: the sixth, seventh, and tenth elementsCan you elaborate on what you mean by the sixth, seventh, and tenth elements and what define you as an element ?

best

Jon

Sorry, let me try to explain it again.

We have a list of 12 items and I refer to each as an element. x and y contain the clustering results of these 12 items. In x, four elements belong to cluster one and in y, four elements belong to cluster one.

If you examine the clustering results, you’ll see that the sixth, seventh, and tenth elements are in cluster one for both clustering results.

Thank you, Thank you, Thank you.

I have been getting bogged down trying to get my head around this (like so many my mind seems to slow down when hit with densely packed mathematical symbols that need translation) and I just needed to see it worked through. This blog did just that beautifully. Well done ?

Yello Dave!

Thank you for an interesting post, very educational and easy to follow. I’m having problem with the following statement:

“n_11 would be the number of times an element occurs in cluster 1 of X and cluster 1 of Y”

How do we know that cluster 1 of X corresponds to cluster 1 of Y? It is easy to think of a setting in which an original cluster A is split into two clusters, B and C. How does that translate into this setting?

In the case of the Rand Index we looked at two internal points a & b, and how they were clustered by two clustering methods A and B. Are we not doing the same thing here?

Best regards,

Mamod

Hi! ARI has a range value of [-1,1], where 1 stands for completely agreement between partitions ans 0 means both partitions are random. But what a negative value stands for? I mean, a value of -1 or -0.33 what does it means?

Thanks in advances. David