Metrics fowlkesmallows score - CyrilB1531/lodestar GitHub Wiki

Development build. This page describes main, not a released package. The latest published Lodestar.Metrics is 0.3.0 โ€” read its documentation.

Home โ€บ Metrics โ€บ Clustering metrics

FowlkesMallows.Score

The geometric mean of pair precision and pair recall for two labellings.

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

Parameters โ€” labelsTrue is the reference labelling and labelsPred the one being scored; they must be the same length. The label values carry no meaning โ€” only which samples share one.

Returns โ€” double in [0, 1]. 1 when both labellings put exactly the same pairs together, 0 when they share no pair at all.

Exceptions โ€” ArgumentException when the two labellings disagree in length.

Example โ€” a renaming, a disagreement, and the degenerate case that surprises.

using Lodestar.Metrics;

double renamed = FowlkesMallows.Score([0, 0, 1, 1], [2, 2, 0, 0]);  // => 1
double independent = FowlkesMallows.Score([0, 0, 1, 1], [0, 1, 0, 1]);  // => 0
double empty = FowlkesMallows.Score([], []);  // => 0

Remarks โ€” an empty input and a single sample score 0 here, where the other five metrics in this namespace score 1. That is not an inconsistency to route around: those five ask whether the two labellings disagree anywhere, and agreeing about nothing is agreeing. This one counts agreeing pairs, and an input with no pairs has none. The value is scikit-learn's.

Nothing here is corrected for chance, which is the difference from AdjustedMutualInformation.Score and AdjustedRand.Score. Splitting a labelling into more clusters can raise this score without the clustering having improved.

The result is grouped as sqrt(tk/pk) ยท sqrt(tk/qk) rather than tk / sqrt(pkยทqk), following the reference's own associativity โ€” the two disagree in the last places, and the frozen corpus reads them at 1e-9.

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

See also โ€” FowlkesMallows, AdjustedRand.Score, the clustering index.

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