Accuracy vs Rand Index – Difference Between Accuracy and Rand Index in Clustering

accuracyclusteringmodel-evaluation

I'm very confused, when I read on the wikipedia "From a mathematical standpoint, Rand index is related to the accuracy, but is applicable even when class labels are not used."
Here and the formula of the Rand Index here

But when I use in R the rand.index function from fossil package and the Accuracy function from MLmetrics it doesn't give the same answer

> Accuracy(predicted, real)
[1] 0.8266667

> rand.index(predicted,real)
[1] 0.7114989

Please can someone explain to me the difference between these two and which one should I use?

NB:I use the k-medoids clustering algorithm (function pam from cluster package)

Best Answer

Rand index is accuracy computed not in the raw data (which does not work unless you have you data where class 1 is cluster 1).

Instead, it is the accuracy on pairs of points, which is invariant to renaming clusters.

In binary classification, the common definition of accuracy is: (TP+TN)/(TP+FP+FN+TN), that should make the similarity of the equations ready to see.