Conditional entropy¶
CatScorer.cond_entropy() · directional · range \([0, \infty)\) nats ·
information-theoretic
The conditional entropy \(H(Y \mid X)\) is the uncertainty about \(Y\) that remains once \(X\) is known. Unlike most measures, lower means stronger: 0 means that \(X\) determines \(Y\). It is the unnormalized quantity behind Theil's U.
Definition¶
As for Theil's U, the variables are the first and second elements of the pair subset \(S(x, y)\):
The entropies follow the scorer's entropy_estimator; with "chao_shen" or
"nsb", the two terms of \(H(X, Y) - H(X)\) are corrected separately.
Example¶
With the example data:
>>> from asymcat import CatScorer
>>> pairs = [("q", "k")] * 2 + [("c", "k")] * 6 + [("k", "k")] * 3 + [("c", "s")] * 4
>>> cond_entropy = CatScorer(pairs).cond_entropy()
>>> [round(h, 3) for h in cond_entropy[("c", "k")]]
[0.449, 0.73]
>>> [round(h, 3) for h in cond_entropy[("q", "k")]]
[0.0, 0.995]
Once the letter is known, 0.449 nats of uncertainty about the sound remain
across the whole dataset (the subset of c and /k/). In the subset of q and
/k/, the sound is always /k/, so nothing remains to predict (\(0\)), while the
letter keeps almost all its uncertainty (0.995 nats, close to
\(\ln 3 \approx 1.10\) for three letters).
Properties¶
- Directional, and lower is stronger: rank pairs in ascending order,
and use
alternative="less"withpermutation_pvalue. - Not normalized. Its scale depends on the number of values in the subset; Theil's U divides it out, which makes pairs comparable.
- Unsigned, as for the other measures on the pair subset: see Pitfalls.
API¶
cond_entropy ¶
Return a corrected conditional entropy scorer.
For every pair (x, y) this computes the conditional entropy in both
directions over the subset of co-occurrences where pair[0] == x or
pair[1] == y, matching conditional_entropy(Y, X) and
conditional_entropy(X, Y) on that subset. The entropies come from
the same computation as theil_u (see
_subset_entropy_components) and follow the scorer's
entropy_estimator.
The whole-variable version is
asymcat.correlation.conditional_entropy.
References¶
- Shannon (1948); Cover & Thomas (2006). See References.