Information Theory of Bayesian network
- class pyagrum.InformationTheory(*args)
This class gathers information theory concepts for subsets named X,Y and Z computed with only one (optimized) inference.
it=pyagrum.InformationTheory(ie,X,Y,Z)
- Parameters:
ie (
InferenceEngine) – the inference algorithme to use (for instance,pyagrum.LazyPropagation)X (
int | str | list[int | str]) – a first nodesetY (
int | str | list[int | str]) – a second nodesetZ (
int | str | list[int | str], optional) – a third (an optional) nodeset
Example
import pyagrum as gum
gum.initRandom(42)
bn = gum.fastBN("A->B<-C<-D->E<-F->G->A")
ie = gum.LazyPropagation(bn)
it = gum.InformationTheory(ie, "A", ["B", "G"], ["C"])
print(f"Entropy(A)={it.entropyX():.4f}")
# Entropy(A)=0.8999
print(f"MutualInformation(A;B,G)={it.mutualInformationXY():.4f}")
# MutualInformation(A;B,G)=0.0244
print(f"MutualInformation(A;B,G|C)={it.mutualInformationXYgivenZ():.4f}")
# MutualInformation(A;B,G|C)=0.0872
print(f"VariationOfInformation(A;B,G)={it.variationOfInformationXY():.4f}")
# VariationOfInformation(A;B,G)=2.5890
Scientific notes
InformationTheory computes the usual quantities of information theory [1] for three disjoint sets of variables \(X\), \(Y\) and \(Z\), from a single joint posterior \(P(X, Y, Z \mid e)\) given by the inference passed as argument (so under its evidence \(e\)). All the logarithms are in base 2 (bits), with \(0 \log 0 = 0\): \(H(X) = -\sum_x p(x)\log_2 p(x)\), \(H(X \mid Y) = -\sum_{x,y} p(x,y)\log_2 p(x \mid y)\), \(I(X;Y) = \sum_{x,y} p(x,y)\log_2 \frac{p(x,y)}{p(x)p(y)}\) and \(I(X;Y \mid Z) = \sum_{x,y,z} p(x,y,z)\log_2 \frac{p(z)\,p(x,y,z)}{p(x,z)\,p(y,z)}\).
The variation of information of [2] is \(VI(X,Y) = H(X \mid Y) + H(Y \mid X) = H(X) + H(Y) - 2\,I(X;Y)\), a distance between the two sets of variables.
Methods