Fowlkes-Mallows Index Calculator
Paste your ground-truth labels and a clustering's predicted labels — or the raw pair counts — and get the Fowlkes-Mallows Index, the pairwise precision and recall, and the full pair-confusion working. Matches scikit-learn. Free, no signup, runs in your browser.
How it works
The Fowlkes-Mallows Index (FMI) measures how well a predicted clustering reproduces a known reference grouping of the same items — for example the clusters a k-means run produced versus the true class labels. It is an external metric: it needs ground truth, unlike the Silhouette, Davies-Bouldin or Calinski-Harabasz scores, which judge a clustering from the feature vectors alone. FMI works at the level of pairs of items.
Consider all C(n,2) = n(n−1)/2 unordered item pairs. Each pair is classified by whether the two items share a cluster in the true labeling and in the predicted labeling (Fowlkes & Mallows 1983; scikit-learn User Guide §2.3.11):
- TP — same cluster in both true and predicted.
- FP — same predicted cluster, different true cluster.
- FN — same true cluster, different predicted cluster.
- TN — different cluster in both.
The index is the number of true positives divided by the geometric mean of the two “together” totals:
- precision P = TP / (TP + FP)
- recall R = TP / (TP + FN)
- FMI = TP / √((TP + FP)(TP + FN)) = √(P · R)
So FMI is the geometric mean of pairwise precision and recall. It ranges over [0, 1]: 1 means the two clusterings are identical up to relabeling, and a value near what independent labelings would score means no meaningful agreement. Because the comparison only depends on which items share a cluster, it is permutation-invariant — renaming clusters changes nothing. In practice the tool builds a contingency table where n_ij is the count of items in true cluster i and predicted cluster j, then uses the closed-form TP = Σ C(n_ij, 2) with the row-sum and column-sum totals to get FP and FN — so it stays fast even for large inputs.
One edge case: if TP + FP = 0 or TP + FN = 0 (a degenerate clustering with no co-clustered pairs), the formula would divide by zero, so scikit-learn returns 0.0 and this tool mirrors that and flags it. All pair counts stay exact integers, so results match scikit-learn to full double precision, and in label mode every FMI is independently re-derived from a distinct sum-of-squares formula before it is shown.
Worked examples
Frequently asked questions
Sources & references
- scikit-learn — fowlkes_mallows_score: the reference implementation and the FMI = TP / √((TP+FP)(TP+FN)) formulation this tool matches, including the degenerate → 0.0 convention.
- scikit-learn User Guide §2.3.11 — Clustering performance evaluation (Fowlkes-Mallows scores): the precision/recall geometric-mean interpretation and the 'requires ground truth' note.
- Fowlkes, E. B. & Mallows, C. L. (1983). A Method for Comparing Two Hierarchical Clusterings. JASA, 78(383), 553–569 — the original definition of the index.
Every formula on this page was cross-checked against these sources on 2026-07-13, and each FMI is verified against an independent sum-of-squares formula inside the tool. Your label lists never leave your browser.
Related tools
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 another clustering metric added next?
Email me at [email protected] — most fixes ship within 24 hours.