induwara.lk
induwara.lkAI · Clustering Metrics

V-Measure Calculator (Homogeneity, Completeness & V-Measure)

Paste your ground-truth classes and predicted cluster IDs to get the homogeneity, completeness and V-measure of a clustering — with the full conditional-entropy working and contingency table. Runs in your browser, no signup, matched to scikit-learn.

By Induwara AshinsanaUpdated Jul 12, 2026
V-measure calculator
6 labels

One label per point — comma, space or newline separated.

6 labels

Same order and length as the true classes.

Examples
V-measure
0.5158
Moderate · 51.58%
Homogeneity h
0.6667
1 − H(C|K)/H(C)
Completeness c
0.4206
1 − H(K|C)/H(K)
Points / classes / clusters
6 · 2 · 3
N · true classes · clusters
Decimals

Moderate. Moderate — the clusters clearly track the classes but blur several. Homogeneity leads completeness — a single class is split across several clusters.

Entropies (nats)H(C) = 0.6931H(K) = 1.0986H(C|K) = 0.2310H(K|C) = 0.6365I(C;K) = 0.4621

Cross-check. The mutual information from the contingency table is 0.4621 nats; the two independent identities H(C) − H(C|K) = 0.4621 and H(K) − H(K|C) = 0.4621 agree, so h = I/H(C) and c = I/H(K) — the same quantities scikit-learn returns. All three reconcile, as they must.

Contingency table

class \ cluster012n_c
02103
10123
n_k2226
Full working, ready to paste into a report

Method: h = 1 − H(C|K)/H(C), c = 1 − H(K|C)/H(K), V_β = (1+β)·h·c / (β·h + c)— the same definitions as scikit-learn's homogeneity_completeness_v_measure (natural log, 0·ln0 = 0). Sources cited below the tool. No data leaves this page.

How it works

V-measure is an external clustering-evaluation metric: it scores a predicted clustering against known class labels. Rosenberg and Hirschberg defined it in 2007 from two complementary criteria — homogeneity and completeness — each expressed through conditional entropy. Let C be the true classes, K the predicted clusters, N the number of points, and a(c,k) the count of points in class c and cluster k. All logarithms are natural; the base cancels in every ratio, exactly as scikit-learn does.

h = 1 − H(C|K)/H(C)  ·  c = 1 − H(K|C)/H(K)  ·  V_β = (1+β)·h·c / (β·h + c)

  1. Build the contingency table a(c,k). Its row sums are the class sizes n_c and its column sums are the cluster sizes n_k.
  2. Compute the class and cluster entropies with the 0·ln0 = 0 convention: H(C) = −Σ (n_c/N)·ln(n_c/N) and H(K) = −Σ (n_k/N)·ln(n_k/N).
  3. Compute the conditional entropies H(C|K) = −Σ (a/N)·ln(a/n_k) and H(K|C) = −Σ (a/N)·ln(a/n_c), summing only over the non-empty cells.
  4. Homogeneity h = 1 − H(C|K)/H(C) rewards clusters that each hold a single class; completeness c = 1 − H(K|C)/H(K) rewards keeping each class in one cluster. When H(C) = 0 (only one class present) homogeneity is set to 1 by convention, and likewise completeness when H(K) = 0.
  5. Combine them: V_β = (1+β)·h·c/(β·h + c). With β = 1 this is the harmonic mean 2hc/(h+c). β above 1 weights completeness; below 1 weights homogeneity.

As a built-in correctness check the tool also computes the mutual information straight from the contingency table, I(C;K) = Σ (a/N)·ln((a·N)/(n_c·n_k)), and reconciles it with both H(C) − H(C|K) and H(K) − H(K|C). Because homogeneity is I/H(C) and completeness is I/H(K), this is the identity scikit-learn relies on — so V-measure equals normalized mutual information under arithmetic-mean normalization. Two facts double as sanity signals: every score sits in [0, 1], and V-measure is symmetric in the two label columns.

Worked examples

Over-clustering — each point its own cluster

True [0,0,1,1], Predicted [0,1,2,3], β = 1

  1. Contingency: class 0 → [1,1,0,0]; class 1 → [0,0,1,1]
  2. n_c = [2, 2]; n_k = [1, 1, 1, 1]; N = 4
  3. H(C) = ln 2 = 0.6931; H(K) = ln 4 = 1.3863
  4. H(C|K) = 0 (every non-zero cell has a = n_k = 1) ⇒ h = 1
  5. H(K|C) = 0.6931 ⇒ c = 1 − 0.6931/1.3863 = 0.5
  6. V = 2·1·0.5/(1 + 0.5) = 0.6667 (matches sklearn 1.0/0.5/0.6667)

Two boundary swaps

True [0,0,0,1,1,1], Predicted [0,0,1,1,2,2], β = 1

  1. Contingency: class 0 → [2,1,0]; class 1 → [0,1,2]
  2. n_c = [3, 3]; n_k = [2, 2, 2]; N = 6
  3. H(C) = ln 2 = 0.6931; H(K) = ln 3 = 1.0986
  4. H(C|K) = 0.2310 ⇒ h = 1 − 0.2310/0.6931 = 0.6667
  5. H(K|C) = 0.6365 ⇒ c = 1 − 0.6365/1.0986 = 0.4206
  6. V = 2·0.6667·0.4206/(0.6667 + 0.4206) = 0.5158

Single true class (H(C) = 0 edge case)

True [0,0,0,0], Predicted [0,1,0,1], β = 1

  1. All points share one class ⇒ H(C) = 0 ⇒ h = 1 by convention
  2. H(K) = ln 2 = 0.6931; H(K|C) = 0.6931
  3. c = 1 − 0.6931/0.6931 = 0
  4. V = 2·1·0/(1 + 0) = 0 (matches sklearn 1.0/0.0/0.0)

Frequently asked questions

Sources & references

The formulas and conventions on this page were last cross-checked against Rosenberg & Hirschberg and scikit-learn on 2026-07-12. The worked examples reproduce to the displayed precision against sklearn.metrics.homogeneity_completeness_v_measure.

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, edge case, or want to suggest an improvement?

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