induwara.lk
induwara.lkAI · Clustering evaluation

Adjusted Rand Index (ARI) Calculator

Paste two clustering label lists — a clustering and its ground truth, or two clusterings — and get the Adjusted Rand Index, the raw Rand Index and the Fowlkes–Mallows index, with the full pair-count and contingency working shown. Matches scikit-learn. Free, no signup, runs in your browser.

By Induwara AshinsanaUpdated Jun 11, 2026
Adjusted Rand Index
One label per item — commas, spaces or new lines.6 items
Must match the item count of list A.6 items
Examples
Adjusted Rand Index
Weak
0.2424

Weak agreement — only a little better than random.

Rand Index (RI)
0.6667
Share of pairs the two clusterings treat the same. Not chance-corrected.
Fowlkes–Mallows (FM)
0.4714
Geometric mean of pair precision and recall.

Pair-count breakdown

aTogether in both A and B2
bTogether in A only4
cTogether in B only1
dSeparated in both8
Total pairs C(6, 2)15

Contingency table

A \ B012Row Σ
02103
10123
Col Σ2226

Rows = clusters of A, columns = clusters of B. Grand total n = 6 items.

Computed entirely in your browser — nothing is uploaded. Formulas per scikit-learn and Hubert & Arabie (1985); last verified 2026-06-11.

How it works

The Adjusted Rand Index compares two ways of grouping the same set of items — for example the clusters a k-means run produced versus the true class labels. It works at the level of pairs of items. For every one of the C(n,2) pairs, the two clusterings either place the pair in the same cluster or in different clusters, and the metric counts how often they make the same call.

Concretely, you build a contingency table where n_ij is the number of items in cluster i of partition A and cluster j of partition B. Writing the row sums as a_i, the column sums as b_j, and C(x,2) = x(x−1)/2, the calculation follows scikit-learn and Hubert & Arabie (1985):

  • Index = Σ C(n_ij, 2)
  • sumA = Σ C(a_i, 2), sumB = Σ C(b_j, 2)
  • Expected = sumA · sumB / C(n, 2)
  • Max = ½ (sumA + sumB)
  • ARI = (Index − Expected) / (Max − Expected)

The subtraction of Expectedis what makes the index “adjusted”: it removes the agreement you would get from random labeling, so a chance clustering scores about 0 instead of the inflated value a raw Rand Index gives. The raw Rand Index itself is RI = (a + d) / C(n,2), where a = Index (pairs together in both) and d = C(n,2) − sumA − sumB + Index (pairs apart in both). The Fowlkes–Mallows index is the geometric mean of pair precision and recall, FM = Index / √(sumA · sumB).

ARI ranges from −0.5 to 1: 1 is a perfect match (identical partitions up to relabeling), 0 is what chance predicts, and negative values mean the two clusterings disagree more than random. Because the comparison only depends on which items share a cluster, it is permutation-invariant — renaming clusters changes nothing. One special case: when both partitions are structureless (every item alone, or all items together), the formula is 0/0 and scikit-learn defines the result as 1.0; this tool follows the same convention and flags it. All pair counts stay exact integers, so the results match scikit-learn to full double precision, and every ARI is independently re-derived from the four pair counts before it is shown.

Worked examples

Example 1 — partial agreement, n = 6

  1. A = [0,0,0,1,1,1], B = [0,0,1,1,2,2]; contingency rows [2,1,0] and [0,1,2].
  2. Index = C(2,2)+C(1,2)+C(1,2)+C(2,2) = 1+0+0+1 = 2
  3. sumA = C(3,2)·2 = 6; sumB = C(2,2)·3 = 3; C(6,2) = 15
  4. Expected = 6·3/15 = 1.2; Max = (6+3)/2 = 4.5
  5. ARI = (2 − 1.2)/(4.5 − 1.2) = 0.8/3.3 = 0.2424
  6. RI = (2 + 8)/15 = 0.6667; FM = 2/√18 = 0.4714

Example 2 — identical partitions under relabeling, n = 4

  1. A = [0,0,1,1], B = [1,1,0,0] — same grouping, different cluster names.
  2. Index = C(2,2)+C(2,2) = 2; sumA = 2; sumB = 2; C(4,2) = 6
  3. Expected = 2·2/6 = 0.6667; Max = (2+2)/2 = 2
  4. ARI = (2 − 0.6667)/(2 − 0.6667) = 1.0 → Near-identical
  5. RI = 1.0; FM = 2/√4 = 1.0 — relabeling does not affect the score.

Example 3 — edge case, independent labelings (the ARI minimum), n = 4

  1. A = [0,0,1,1], B = [0,1,0,1] — every cluster of A is split evenly across B.
  2. Index = 0; sumA = 2; sumB = 2; C(4,2) = 6
  3. Expected = 2·2/6 = 0.6667; Max = 2
  4. ARI = (0 − 0.6667)/(2 − 0.6667) = −0.6667/1.3333 = −0.5 → Worse than random
  5. RI = (0 + 2)/6 = 0.3333, yet ARI exposes that this is the worst possible case.

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, an edge case, or want Normalized Mutual Information added next?

Email me at [email protected] — most fixes ship within 24 hours.