Information gain in decision trees
DefinitionInformation gain of a split#✓fully proved
Let \(p\) be a joint probability law on \(\alpha \times \beta\) with \(\alpha\) and \(\beta\) finite, the law of an attribute \(X\) (first coordinate) and a label \(Y\) (second coordinate). The information gain of splitting on \(X\) for predicting \(Y\) is the real number \(H(Y) - H(Y \mid X)\), where \(H(Y)\) is the Shannon entropy in bits of the marginal law of \(Y\) and \(H(Y \mid X)\) is the conditional entropy in bits of \(Y\) given \(X\) under \(p\).
noncomputable def infoGain (p : PMF (α × β)) : ℝ :=
shannonEntropy (p.map Prod.snd) - finiteConditionalEntropy p
noncomputable def shannonEntropy {α : Type*} [Fintype α] (p : PMF α) : ℝ :=
(∑ a, Real.negMulLog (p a).toReal) / Real.log 2
MathlibExt/InformationTheory/FiniteEntropy.lean:44
noncomputable def finiteConditionalEntropy [Fintype α] [Fintype β] (p : PMF (α × β)) : ℝ :=
-∑ a, ∑ b, (p (a, b)).toReal * logb 2 ((p (a, b)).toReal / ((p.map Prod.fst) a).toReal)
MathlibExt/InformationTheory/ConditionalEntropy.lean:246
Uses 2 · Used by 4
TheoremInformation gain in terms of entropies#✓fully proved
Let \(p\) be a joint probability law on \(\alpha \times \beta\) with \(\alpha\) and \(\beta\) finite, and let \(p_X\) and \(p_Y\) be its marginal laws on \(\alpha\) and on \(\beta\). Writing \(H\) for Shannon entropy in bits, the information gain of \(p\) equals \(H(p_X) + H(p_Y) - H(p)\).
theorem infoGain_eq (p : PMF (α × β)) :
infoGain p = shannonEntropy (p.map Prod.fst) + shannonEntropy (p.map Prod.snd) -
shannonEntropy p
noncomputable def infoGain (p : PMF (α × β)) : ℝ :=
shannonEntropy (p.map Prod.snd) - finiteConditionalEntropy p
CSLibExt/MachineLearning/InformationTheory/InformationGain.lean:47
noncomputable def shannonEntropy {α : Type*} [Fintype α] (p : PMF α) : ℝ :=
(∑ a, Real.negMulLog (p a).toReal) / Real.log 2
MathlibExt/InformationTheory/FiniteEntropy.lean:44
Uses 4 · Used by 1
TheoremNo split has negative information gain#✓fully proved
For every joint probability law \(p\) on \(\alpha \times \beta\) with \(\alpha\) and \(\beta\) finite, the information gain of \(p\) is at least \(0\).
theorem infoGain_nonneg (p : PMF (α × β)) : 0 ≤ infoGain p
noncomputable def infoGain (p : PMF (α × β)) : ℝ :=
shannonEntropy (p.map Prod.snd) - finiteConditionalEntropy p
CSLibExt/MachineLearning/InformationTheory/InformationGain.lean:47
Uses 4 · Used by 1
TheoremInformation gain is mutual information#✓fully proved
Let \(\alpha\) and \(\beta\) be finite sets carrying σ-algebras in which singletons are measurable, and let \(p\) be a joint probability law on \(\alpha \times \beta\). The information gain of \(p\), regarded as an element of \([0, \infty]\), equals the mutual information in bits of \(p\) viewed as a probability measure on \(\alpha \times \beta\).
theorem ofReal_infoGain (p : PMF (α × β)) :
ENNReal.ofReal (infoGain p) =
measureMutualInformation (⟨p.toMeasure, inferInstance⟩ : ProbabilityMeasure (α × β))
noncomputable def infoGain (p : PMF (α × β)) : ℝ :=
shannonEntropy (p.map Prod.snd) - finiteConditionalEntropy p
CSLibExt/MachineLearning/InformationTheory/InformationGain.lean:47
noncomputable def measureMutualInformation {X Y : Type*}
[MeasurableSpace X] [MeasurableSpace Y] (μ : ProbabilityMeasure (X × Y)) : ℝ≥0∞ :=
klDiv (μ : Measure (X × Y))
(((μ : Measure (X × Y)).map Prod.fst).prod ((μ : Measure (X × Y)).map Prod.snd)) /
ENNReal.ofReal (Real.log 2)
MathlibExt/InformationTheory/ConditionalEntropy.lean:88
Uses 5 · Used by 1
TheoremZero information gain means independence#✓fully proved
Let \(\alpha\) and \(\beta\) be finite sets carrying σ-algebras in which singletons are measurable, and let \(p\) be a joint probability law on \(\alpha \times \beta\). The information gain of \(p\) is zero if and only if \(p\), as a measure, equals the product of its marginal law on \(\alpha\) and its marginal law on \(\beta\); that is, exactly when the attribute (first coordinate) and the label (second coordinate) are independent.
theorem infoGain_eq_zero_iff (p : PMF (α × β)) :
infoGain p = 0 ↔
p.toMeasure = (p.map Prod.fst).toMeasure.prod (p.map Prod.snd).toMeasure
noncomputable def infoGain (p : PMF (α × β)) : ℝ :=
shannonEntropy (p.map Prod.snd) - finiteConditionalEntropy p
CSLibExt/MachineLearning/InformationTheory/InformationGain.lean:47
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.