L1 sparsity kyun deta hai: L1 ball ke corners axes par hote hain. Jab loss contour pehli baar is ball ko touch karti hai, woh aksar corner par touch karti hai → kuch coordinates exactly 0 ho jaate hain.
L1 akela correlated features par kyun fail hota hai: agar x1≈x2 ho, toh loss w1+w2=const direction mein almost flat hoti hai. L1 ki penalty ∣w1∣+∣w2∣bhi us direction mein constant hoti hai (jab tak signs match karein), isliye solution unique nahi hota — woh arbitrarily hil-dol jaata hai.
L2 add karne se yeh kyun theek hota hai: L2 penalty w12+w22strictly convex hai aur (fixed sum ke liye) minimize hoti hai jab w1=w2 ho. Toh L2 term tie todta hai aur weight ko correlated features ke beech evenly spread karta hai. Yahi grouping effect hai.
Hum ek weight wj ke liye coordinate-descent update derive karte hain. Assume karo ki features standardized hain, yaani n1∑ixij2=1.
Step 1 — wj ko isolate karo. Baaki sab weights fix rakho. Partial residual define karo (target minus baaqi sab ka contribution):
ri=yi−∑k=jwkxik.Yeh step kyun? Coordinate descent ek waqt mein ek variable optimize karta hai; jo bhi wj se involve nahi hai woh constant hai.
Step 3 — subgradient lo aur 0 par set karo.ρj=n1∑ixijri (feature j ka partial residual ke saath correlation). n1∑xij2=1 use karte hue:
0∈−ρj+wj+λ(1−α)wj+λα∂∣wj∣Yeh step kyun? Quadratic parts cleanly differentiate hote hain; ∣wj∣ ka subgradient wj=0 ke liye sign(wj) hai aur 0 par [−1,1] hai.
Step 4 — solve karo, soft-threshold milta hai. Minimizer hai:
wj=1+λ(1−α)S(ρj,λα),S(z,γ)=sign(z)max(∣z∣−γ,0)Yeh step kyun?Ssoft-thresholding operator hai: L1 term ρj ko zero ki taraf λα se shrink karta hai (aur maar deta hai agar ∣ρj∣≤λα ho), jabki L2 term 1+λ(1−α) se divide karta hai, jo ek extra proportional shrink hai.
Recall Forecast-then-Verify: pehle predict karo, phir reveal karo
Q: Agar α=0 ho, toh kaun sa method milta hai, aur kya woh zeros produce karta hai?
A: Pure Ridge; yeh shrink karta hai lekin weights ko kabhi exactly zero nahi karta.
Q: Do perfectly correlated features — Elastic Net unke saath weight ka kya karta hai?
A: L2 term ki wajah se weight ko unke beech (roughly) equally split karta hai (grouping effect).
Recall Feynman: ek 12-saal ke bachhe ko explain karo
Socho tum ek trip ke liye backpack pack kar rahe ho aur tumhe decide karna hai ki kaun si gadgets laani hain.
Lasso ek strict dost hai: "EK flashlight lo, baaki do phenko" — chahe teeno equally achhi hon, aur agli baar woh alag wali randomly pick kar sakta hai. Ridge ek soft dost hai: "sab ki chhoti-chhoti versions laao, koi ghar nahi chhutega." Elastic Net samajhdaar dost hai: "jo cheez sacchi bekaar hai usse phenko (jaise Lasso), lekin teeno equally-achhi flashlights ke liye, teeno chhoti laao taaki fair aur stable rahe (jaise Ridge)." Equally-achhi chezon ke liye yeh fairness hi wajah hai ki yeh similar chezon se ghabrata nahi.