Skip to content

Goodman–Kruskal λ

CatScorer.goodman_kruskal_lambda() · directional · range \([0, 1]\) · statistical

Goodman and Kruskal's λ (Goodman & Kruskal, 1954) is the proportional reduction in prediction errors: if you must guess \(Y\), how many fewer mistakes do you make by knowing \(X\)? Without \(X\), the best guess is always the most frequent \(y\); with it, the most frequent \(y\) for each \(x\).

Definition

With \(n(x, y)\) the counts of a table, \(n(y)\) its column totals and \(N\) its total,

\[ \lambda(Y \mid X) = \frac{\sum_x \max_y n(x, y) - \max_y n(y)}{N - \max_y n(y)}, \]

with \(\lambda = 1\) by convention when the denominator is 0 (when \(Y\) takes a single value, so that there are no errors to reduce), as for Theil's U. In ASymCat, the table is the pair subset \(S(x, y)\):

\[ \texttt{goodman_kruskal_lambda}(x, y) = \big(\lambda(Y_S \mid X_S),\ \lambda(X_S \mid Y_S)\big) \]

Example

With the example data:

>>> from asymcat import CatScorer
>>> pairs = [("q", "k")] * 2 + [("c", "k")] * 6 + [("k", "k")] * 3 + [("c", "s")] * 4
>>> gk_lambda = CatScorer(pairs).goodman_kruskal_lambda()
>>> gk_lambda[("c", "k")]
(0.0, 0.0)
>>> gk_lambda[("k", "s")]
(1.0, 1.0)

For c and /k/, the subset is the whole dataset. Without the letter, the best guess for the sound is /k/, right 11 times in 15. Knowing the letter does not change any guess, since /k/ is also the most frequent sound for each letter, so λ is 0, although Theil's U finds that the letter carries information about the sound (0.23). In the subset of k and /s/, each variable determines the other.

Properties

  • Directional. \(\lambda(Y \mid X) \neq \lambda(X \mid Y)\) in general.
  • Zero despite association. λ only registers associations that change the modal guess. When one value dominates every row, λ is 0 whatever the association; Theil's U is more sensitive.
  • A convention on degenerate subsets. When the predicted variable takes a single value in the subset, λ is 1, as is Theil's U: for ("q", "k"), both give 1 and 0.
  • Unsigned, as for the other measures on the pair subset: see Pitfalls.

API

goodman_kruskal_lambda

goodman_kruskal_lambda() -> dict[tuple[Any, Any], tuple[float, float]]

Return a Goodman-Kruskal Lambda scorer.

Computes λ(Y|X) and λ(X|Y) for each symbol pair, measuring the proportional reduction in error when predicting one variable from another. Like theil_u, it is computed on the subset of co-occurrences where pair[0] == x or pair[1] == y; when the predicted variable takes a single value in that subset, the score is 1.0, as for theil_u.

Returns:

Type Description
Dict[Tuple[Any, Any], Tuple[float, float]]

Dictionary mapping symbol pairs to (λ(Y|X), λ(X|Y)) tuples.

References