Independent events add: if two independent things happen with probs p and q, the joint
prob is pq, and total surprise should add: I(pq)=I(p)+I(q).
The only continuous function turning multiplication into addition is the logarithm:
I(p)=−logbp.
The minus sign makes it positive (since p≤1⇒logp≤0). Choosing base b=2
gives bits.
Entropy is just the average surprise over the distribution:
H(S)=E[I]=∑ipi(−log2pi)=−∑ipilog2pi.
WHY the weights ∣Sv∣/∣S∣? After splitting, a random example lands in child v with
probability ∣Sv∣/∣S∣. The expected leftover entropy is the weighted average of child
entropies. Gain = parent entropy − expected child entropy. It can never be negative
(splitting cannot increase uncertainty, by concavity of H).
Because we want independent information to add: I(pq)=I(p)+I(q). Only −log turns the
multiplication of independent probabilities into a sum. Base 2 ⇒ bits.
Recall Can information gain be negative?
No.H is concave, so the weighted average of child entropies never exceeds the parent's.
Worst case IG =0 (a useless split).
Recall What value maximizes binary entropy and what is it?
p=0.5, giving H=1 bit.
Recall Explain like I'm 12
Imagine a bag of red and blue marbles. If they're all red, you're never surprised pulling one
— that's zero mess (entropy 0). If it's half-and-half, every pull is a coin flip — maximum
mess (1 bit). A good "question" splits the bag so each smaller bag is mostly one color.
Information gain is how much messiness you removed by asking. The tree keeps asking the
question that removes the most mess first.
Socho ek node ke andar Yes/No labels ka mixture pada hai. Entropy batati hai ki ye
mixture kitna "messy" hai. Agar saare same class ke hain (all Yes ya all No), entropy = 0,
matlab bilkul pure, koi confusion nahi. Agar 50-50 hai, entropy = 1 bit — maximum confusion,
jaise fair coin flip. Formula hai H=−∑pilog2pi, aur log isliye aata hai kyunki
hum chahte hain ki independent information add ho — sirf log hi multiplication ko addition
mein badalta hai.
Information gain ka matlab: koi feature (question) puchhne se entropy kitni kam hui.
Gain = parent ki entropy minus children ki weighted average entropy. Weight isliye kyunki
bada child zyada matter karta hai. Decision tree har step pe wahi split chunta hai jiska
gain sabse zyada ho — matlab jo sabse zyada confusion saaf kare.
Ek dhyan dene wali baat: information gain high-cardinality features (jaise ID number) ki
taraf biased hai, kyunki wo har row ko alag pure group mein daal deta hai — fake high gain.
Iska fix hai Gain Ratio, jo split ke size ko penalize karta hai. Aur agar speed chahiye
to Gini use karo — log nahi lagta, fast hota hai, aur usually same split choose karta hai.