2.3.2 · HinglishTree-Based & Instance Methods

Entropy and information gain

1,600 words7 min readRead in English

2.3.2 · AI-ML › Tree-Based & Instance Methods


HUM KYA MEASURE KAR RAHE HAIN?

YE EXACT FORMULA KYUN? Hum ek aisa number chahte hain jo:

  1. ho jab hum certain hon (ek class ki ho),
  2. bada ho jab hum maximally confused hon,
  3. independent information ke liye additive ho.

Ye teeno requirements milke ek shape ko force karti hain. Chaliye isse derive karte hain.


ENTROPY KO SCRATCH SE KAISE DERIVE KAREIN

Hum do properties demand karte hain:

  • Certainty mein koi info nahi: .
  • Independent events add hote hain: agar do independent cheezein probs aur se hoti hain, to joint prob hogi, aur total surprise add honi chahiye: .

Sirf ek hi continuous function hai jo multiplication ko addition mein convert karta hai — logarithm: Minus sign ise positive banata hai (kyunki ). Base chunne se bits milte hain.

Entropy sirf distribution par average surprise hai:

Figure — Entropy and information gain

Information Gain

WEIGHTS KYUN? Splitting ke baad, ek random example child mein probability se land karta hai. Expected leftover entropy, child entropies ka weighted average hai. Gain = parent entropy − expected child entropy. Ye kabhi negative nahi ho sakta (splitting uncertainty badha nahi sakti, ki concavity ki wajah se).


Worked Example 1 — ek single split

Dataset: 14 examples, 9 "Yes", 5 "No". Attribute Wind ∈ {Weak, Strong}.

  • Weak (8 examples): 6 Yes, 2 No
  • Strong (6 examples): 3 Yes, 3 No

Step 1 — parent entropy. Ye step kyun? Humein question se pehle ka "mess" ek baseline ki tarah chahiye.

Step 2 — child entropies. Kyun? Strong 50/50 mess hai → maximal 1 bit; Weak Yes ki taraf jhukta hai → kam messy.

Step 3 — weighted child entropy. Weight kyun? Bade children average outcome par zyada matter karte hain.

Step 4 — gain. Itna chhota kyun? Wind ne cheezein barely saaf ki — shayad best split nahi hai ye.


Worked Example 2 — ek perfect split

3 Yes, 3 No. Attribute split karta hai: {3 Yes} aur {3 No} mein.

  • bit (perfect 50/50).
  • Har child pure hai → .
  • Weighted child entropy .
  • bit.

Maximal kyun? Ek question ne saari uncertainty remove kar di — dream split.


Forecast-then-Verify


Common Mistakes (Steel-manned)


Gini — fast cousin (YE KYUN EXIST KARTA HAI)


Active Recall

Recall Entropy logarithm kyun use karta hai?

Kyunki hum chahte hain independent information add ho: . Sirf hi independent probabilities ke multiplication ko sum mein convert karta hai. Base 2 ⇒ bits.

Recall Kya information gain negative ho sakta hai?

Nahi. concave hai, isliye child entropies ka weighted average kabhi parent se zyada nahi hota. Worst case IG (ek useless split).

Recall Kaunsi value binary entropy maximize karti hai aur wo kya hai?

, jo bit deta hai.

Recall 12 saal ke bachche ko explain karo

Socho ek bag mein laal aur neele marbles hain. Agar sab laal hain, to ek nikaalte waqt kabhi surprise nahi hoga — ye hai zero mess (entropy 0). Agar aadhe-aadhe hain, to har baar nikalna ek coin flip hai — maximum mess (1 bit). Ek accha "question" bag ko aisa split karta hai ki har chhota bag mostly ek color ka ho. Information gain ye hai ki poochh ke kitna messiness remove hua. Tree pehle wahi question poochna rakhta hai jo sabse zyada mess remove karta hai.


Mnemonic


Flashcards

Decision tree node mein entropy kya measure karta hai?
Class distribution ki impurity/uncertainty; 0 = pure, max jab classes equally likely hon.
Entropy formula likho.
(bits).
Entropy mein logarithm kyun?
Taaki independent information add ho: , jo uniquely se satisfy hota hai.
p=0.5 par binary entropy?
1 bit (maximum).
Information gain formula?
.
Child entropies ko se weight kyun karte hain?
Ye expected leftover entropy hai — probability ki ek example us child mein girega.
Kya information gain negative ho sakta hai?
Nahi; entropy ki concavity se, minimum gain 0 hai.
Information gain mein kaunsa bias hai aur iska fix kya hai?
High-cardinality attributes ki taraf bias; Gain Ratio (IG / SplitInfo) se fix karo.
Gini impurity formula?
; log-free, CART use karta hai.
SplitInfo formula?
.

Connections

  • Decision Trees — entropy/IG node splitting drive karte hain.
  • Gini Impurity — alternative impurity measure (CART).
  • ID3 and C4.5 Algorithms — IG aur Gain Ratio use karte hain.
  • Cross-Entropy Loss — neural nets mein same shape.
  • KL Divergence — entropy generalized to compare distributions.
  • Overfitting and Pruning — IG se pure leaves overfit kar sakti hain.

Concept Map

I(pq)=I(p)+I(q)

self-info

average over p_i

base 2 log

max when equal

one class only

2-class version

baseline mess

subtract weighted

weight Sv over S

pick highest

never negative

Surprise I(p)

Logarithm shape

I(p) = -log2 p

Entropy H(S)

Units in bits

Maximal uncertainty

H = 0 pure

Binary entropy H(p)

Information Gain

Weighted child entropy

Child landing prob

Chosen tree split

Concavity of H