I am new to Unsupervised learning. I am working on a customer segmentation data (with no labels). I have done K-Means and also calculated the silhouette score for the model. Now I want to study, if the model is good or not (similarity or stability for clusters) using Adjusted Rand Index. Can anyone give an idea how to do it, as I have have only the cluster labels which I believe are 'labels'. In the formula of RAND score, we need the "labels_true, labels" what should be the first one. I have checked on the internet, but not much is available. By the way, I am using Python. Thank you.


1 Answer 1


From scikit-learn document Link-

Given the knowledge of the ground truth class assignments labels_true and our clustering algorithm assignments of the same samples labels_pred, the (adjusted or unadjusted) Rand index is a function that measures the similarity of the two assignments

labels_true = [0, 0, 0, 1, 1, 1]
labels_pred = [0, 0, 1, 1, 2, 2]
metrics.rand_score(labels_true, labels_pred) Drawbacks

Contrary to inertia, the (adjusted or unadjusted) Rand index requires knowledge of the ground truth classes which is almost never available in practice or requires manual assignment by human annotators (as in the supervised learning setting).

  • $\begingroup$ Thanks. But do you have other examples how it is done, other than Iris dataset. I knew the fact before. $\endgroup$
    – GabS
    May 27, 2021 at 17:42
  • $\begingroup$ You can try on MNIST digit. Define the clusters e.g. KMeans with K=10, use true_labels and cluster_labels. Repeat for K=20,10,100 etc. $\endgroup$
    – 10xAI
    Jun 2, 2021 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.