Metrics 0.2.0 vmeasure score - CyrilB1531/lodestar GitHub Wiki

Lodestar.Metrics 0.2.0. This page is frozen at that release. Read the current documentation for what main says now. A link to a decision or a migration page follows main, and leaves the archive.

VMeasure.Score

Homogeneity and completeness as one number, their harmonic mean.

public static double Score(ReadOnlySpan<int> labelsTrue, ReadOnlySpan<int> labelsPred)

Parameters โ€” labelsTrue is the reference partition and labelsPred the one being scored, one label per sample and the same length. The label values carry no meaning: only which samples share one does.

Returns โ€” double in [0, 1], 0 when homogeneity and completeness are both 0.

Exceptions โ€” ArgumentException when the two labellings disagree in length. An empty input is not an error: it scores 1.

Example โ€” one number for a clustering that splits one class and merges nothing.

using Lodestar.Metrics;

int[] truth = [0, 0, 0, 1, 1, 1];
int[] split = [0, 0, 1, 2, 2, 2];

double score = VMeasure.Score(truth, split);   // => 0.8132โ€ฆ

Remarks โ€” this returns exactly what NormalizedMutualInformation.Score returns, on every input. That is not a coincidence and it is worth deriving once, because a reader who reports both numbers thinks they have two: homogeneity is MI / H(true) and completeness is MI / H(pred), so their harmonic mean 2hc / (h + c) cancels down to 2ยทMI / (H(true) + H(pred)) โ€” mutual information divided by the arithmetic mean of the two entropies, which is precisely the normalizer normalized_mutual_info_score applies by default. Two names, one quantity.

The number that does say something different is AdjustedRand.Score, and the gap between the two is the correction for chance: a clustering that invents clusters scores well here and near zero there.

scikit-learn's beta, which would weigh homogeneity against completeness rather than averaging them evenly, is not a parameter here: its default of 1 is the plain harmonic mean above, and no oracle row exists for any other value.

Applies to โ€” net10.0, netstandard2.0.

See also โ€” AdjustedRand.Score, Homogeneity.Score, Completeness.Score, the Python equivalence table.

โš ๏ธ **GitHub.com Fallback** โš ๏ธ