Question about the output results of Scikit-learn's adjusted rand index There is a problem that the calculation of ARI using the Adjusted_rand_score function in Scikit-learn does not match the results of the ARI calculation based on the paper proposed by Hubert et al1. Please point out any errors in the calculation method or Scikit-learn's handling.
The following clustering example will be used in the calculations.
ClusterX : 0, 0, 1, 1, 1
　ClusterY : 0, 0, 0, 1, 1
First, calculate the ARI using the proposed paper by Hubert et al 1.
Table　Notation for Comparing Two Partitions





Y0
Y1
Sums




X0
2
0
2


X1
1
2
3


Sums
3
2





The formula for calculating ARI is shown below.

Next, the ARI is calculated using Scikit-learn[2].
The input for ARI in scikit-learn needs the correct label to use as a reference (Ground truth class label?) and the label of the cluster.
Thus, for the above clustering, if we put the clustering labels as X = 3, Y = 4
labels_true = [0,0,0,0,0,1,1,1,1,1]
labels_pred = [3,3,4,4,4,3,3,3,4,4]
The result is Using this data to calculate ARI, we obtain
from sklearn.metrics.cluster import adjusted_rand_score

adjusted_rand_score([0,0,0,0,0,1,1,1,1,1],[3,3,4,4,4,3,3,3,4,4])

output → -0.08
The result does not match.
My English is poor because I am not a native English speaker, but please answer me.
=================================================
1 L. Hubert, P. Arabie. Comparing Partitions. Journal of Classification 2:193-218 (1985)
https://doi.org/10.1007/BF01908075
[2]https://scikit-learn.org/stable/modules/generated/sklearn.metrics.adjusted_rand_score.html

You misunderstand how to use sklearn.metrics.adjusted_rand_score.
You want to compare two clusterings, X and Y, of a set of samples. The adjusted Rand index (ARI) counts how many pairs of samples are assigned to the same clusters in both X and Y and adjusts for the probability that samples can end up in the same cluster by chance.
It's straightforward to check that scikit-learn gives the same ARI for the example X and Y clusterings.
You seem to be confused by the terms "true labels" and "predicted labels", which to be fair are not necessarily meaningful for an unsupervised clustering problem. However, the ARI is symmetric; it's irrelevant whether X or Y is the "truth".
from sklearn.metrics import adjusted_rand_score

cX = [0, 0, 1, 1, 1]
cY = [0, 0, 0, 1, 1]

adjusted_rand_score(cX, cY)
## > 0.16666666666666666
adjusted_rand_score(cY, cX)
## > 0.16666666666666666

