2.3.8 · HinglishTree-Based & Instance Methods

Feature importance from trees

1,558 words7 min readRead in English

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


KYA compute kar rahe hain hum?

Teen ingredients:

  • Impurity : ek node kitna mixed hai (classification ke liye Gini ya entropy, regression ke liye variance/MSE).
  • Impurity decrease : split ne node ko kitna saaf kiya.
  • Weighting : tree mein upar ka split zyada samples affect karta hai → zyada count hota hai.

KAISE: first principles se derive karo

WHY children ko weight karte hain? Ek parent node jisme samples hain woh ek left child () aur right child () mein split hota hai. Hum parent ki impurity ko children ki average impurity se compare karte hain — lekin jis child mein zyada samples hain woh zyada count karna chahiye. Isliye hum children ko unke sample fractions se weight karte hain:

Yeh hamesha kyun hai: Greedy tree algorithms woh split choose karte hain jo is drop ko maximize kare, aur impurity ek concave function hai, isliye splitting kabhi (weighted) impurity badha nahi sakti. Isliye importances non-negative hoti hain.

Ab arrival weight se multiply karo (fraction of all data jo node tak pahunchta hai) aur par split karne wale har node pe sum karo → is se upar wala milta hai.

Forests: trees par average karo

Ek Random Forest / GBM jisme trees hain, importance trees ka mean hoti hai, usually 1 sum karne ke liye normalize ki gayi:

Figure — Feature importance from trees

Worked Example 1 — ek split, Gini

Root mein 10 samples hain: 5 positive, 5 negative. Feature par split se milta hai:

  • Left: 4 samples (4 pos, 0 neg)
  • Right: 6 samples (1 pos, 5 neg)

Step 1 — parent impurity. Kyun? Baseline mixed-ness.

Step 2 — child impurities. Kyun? Measure karo ki har side kitni clean hui.

Step 3 — weighted child impurity. Kyun? Bada child zyada count karta hai.

Step 4 — impurity decrease. Kyun? Jo cleanup achieve hua.

Step 5 — arrival weight. Root sabhi data dekhta hai, .


Worked Example 2 — deeper node weighting

Maan lo ek aisi node par split karta hai jo sirf 10 mein se 3 samples tak pahunchi hai, aur hai.

Step — arrival weight lagao. Kyun? Jo split thode samples affect kare woh dominate nahi karni chahiye.

Zyada local hone ke bawajood (0.4 > 0.3333), (0.12) ka rank (0.3333) se neeche hai kyunki ki split ne sabko touch kiya. Yahi reason hai ka.

Normalized: , .


Worked Example 3 — regression (variance drop)

Node jisme , hai. Split into aur .

Step 1 — parent variance. Step 2 — child variances. Har child: ya , var . Step 3 — weighted. Step 4 — decrease. . Bada drop → yeh feature ko achhi tarah separate karta hai.



Recall Feynman: 12-saal ke bachche ko samjhao

Socho tum ek messy box mein red aur blue marbles ko saaf piles mein sort kar rahe ho. Har "sawaal" jo tum poochho (jaise kya yeh ek coin se bada hai?) jo piles ko neater banaye, woh points earn karta hai. Ek sawaal jo SAARE marbles ko perfect red-only aur blue-only piles mein split kare woh bahut points earn karta hai; ek sawaal jo sirf 3 marbles ki help kare woh kam points paata hai. Puri game mein har sawaal-type ke points add karo — sabse zyada points wale sawaal most important features hain. Lekin savdhan raho: ek sawaal jiske bahut saare possible answers hain (jaise grams mein exact weight) "cheat" kar sakta hai aur important lag sakta hai jab woh sirf memorize kar raha ho.


Flashcards

MDI (Mean Decrease in Impurity) kya measure karta hai?
Ek feature ka use karne wale sabhi splits se total weighted impurity reduction, tree(s) par sum ki gayi.
Node par weighted impurity decrease likhो.
Har node ke ko se multiply kyun karte hain?
Taaki zyada samples tak pahunchne wale splits (usually tree mein upar) thode samples affect karne wale deep splits se zyada count karein.
Gini impurity formula do aur kyun kaam karta hai.
; yeh woh probability hai ki node se do random draws class mein disagree karein — mixedness ka ek measure.
Impurity decrease hamesha non-negative kyun hoti hai?
Greedy algorithm woh split choose karta hai jo (concave) impurity drop maximize kare; splitting weighted impurity badha nahi sakti.
Regression trees mein kaun si impurity use hoti hai?
Node mean ke baare mein Variance / MSE: .
MDI feature importance ka main bias kya hai?
High-cardinality/continuous features ke liye inflated (zyada split points → noise fit kar sakta hai); training data par compute hone par bhi biased.
MDI ke biases ka fix kya hai?
Permutation importance use karo (feature ko held-out data par shuffle karo) ya SHAP values.
Do correlated features ki importance mein kya hota hai?
Ek baar ek use ho jaye, doosra redundant ho jaata hai aur near-zero MDI paata hai, ek real predictor chhupa leta hai.
Trees ki importances se forest importance kaise milti hai?
Sabhi trees par per-tree importances ka average lo, phir 1 sum karne ke liye normalize karo.

Connections

  • Decision Trees — MDI usi impurity ka byproduct hai jo tree grow karne mein use hoti hai.
  • Gini vs Entropy ka choice importance values badalta hai.
  • Random Forests — stability ke liye bahut saare trees par importance average ki jaati hai.
  • Gradient Boosting — split-based importances bhi expose karta hai (gain/cover/frequency).
  • Permutation Importance — unbiased, model-agnostic alternative.
  • SHAP Values — MDI biases fix karne wala game-theoretic attribution.
  • Bias-Variance Tradeoff — training MDI overfitting ki wajah se overestimate karta hai.

Concept Map

classification form of

regression form of

parent minus weighted children

weighted by

summed over splits on f

scales contribution

maximizes

ensures

averaged over trees

divided by total

Impurity i of t

Impurity decrease delta i

Arrival weight Nt over N

Feature importance MDI

Gini impurity

Variance impurity MSE

Greedy split choice

Importance non-negative

Forest importance

Normalized to sum 1