2.2.13 · HinglishLinear & Logistic Regression

L1 (Lasso) regularization

1,783 words8 min readRead in English

2.2.13 · AI-ML › Linear & Logistic Regression


WHY karte hain hume yeh?


WHAT hai Lasso?


HOW karta hai L1 exact zeros? (Derivation from scratch)

Ek single weight lo aur sabse simple problem lo (orthonormal features taaki features decouple ho jayein). Cost hai: jahan us feature ka OLS solution hai (woh value jo bina penalty ke leta).

Yeh step kyun? Orthonormal features ke saath har coordinate independently optimize hota hai, toh ek ko samajhna sab kuch bata deta hai.

Ab minimize karo. Absolute value par differentiable nahi hai, toh hum do cases handle karte hain.

Case 1: . Tab , aur Valid tabhi jab , matlab .

Case 2: . Tab , aur Valid tabhi jab .

Case 3: . Upar wale dono cases consistent nahi hain, aur minimum kink par baith jaata hai .

Isi setting mein Ridge se compare karo: minimize karne par milta hai — hamesha shrunk, lekin kabhi exactly zero nahi jab tak na ho.


Worked Examples


Common Mistakes (Steel-man + fix)


Active Recall

Recall Soft-threshold operator kya karta hai?

: se zero ki taraf shrink karo, aur exactly par clamp karo agar magnitude se kam ho.

Recall L1 sparsity kyun deta hai lekin L2 nahi?

L1 ka constraint region (diamond) axes par corners rakhta hai; MSE contours wahan touch karte hain, coordinates ko force karte hain. L2 ka circle smooth hai — koi corner nahi — toh weights shrink hote hain lekin nonzero rehte hain.

Recall Feynman: 12-saal ke bachche ko samjhao

Socho tum trip ke liye pack kar rahe ho lekin tumhara bag ek strict weight limit rakhta hai, aur har item jo tum add karo woh same "weight tax" leta hai chahe kitna bhi chota ho. Kyunki tax fixed hai per item, tum prefer karoge ki chote useless items bilkul baahar chod do thoda carry karne ka tax bharein. Lasso features ke saath yahi karta hai: jinhe "tax" ke laayak nahi samajhta unhe drop kar deta hai, sirf kuch important waale rakhta hai. Isliye model chota aur simple banta hai.


Flashcards

Lasso loss mein kaun sa penalty term add hota hai?
(weights ka L1 norm).
Lasso exactly-zero weights kyun produce karta hai jabki Ridge nahi?
L1 ka constraint region ek diamond hai jisme axes par corners hain; loss contours pehle ek corner (zero) par touch karte hain. Ridge ka circle smooth hai, toh exact zeros nahi.
Orthonormal features ke liye soft-thresholding solution likho.
, jahan OLS coefficient hai.
Lasso mein aur par kya hota hai?
: OLS recover hota hai. : saare penalized weights 0 ho jaate hain (model mean predict karta hai).
Lasso se pehle features standardize kyun karne chahiye?
L1 penalty saare coefficients ko equally treat karti hai; alag feature scales unequal effective penalization cause karti hai.
Plain gradient descent Lasso ke liye clean kyun nahi chal sakta?
0 par non-differentiable hai; subgradients / coordinate descent / proximal (ISTA) methods use karo.
Elastic Net kya hai aur kyun use karein?
Ek mix ; yeh correlated features ke groups ko saath rakhta hai, Lasso ki instability fix karta hai.
, ke liye Lasso weight kya hai?
, kyunki toh zero par clamp ho jaata hai.

Connections

  • Ridge (L2) Regularization — smooth shrinkage, no sparsity; complementary geometry.
  • Elastic Net — L1 aur L2 combine karta hai correlated features handle karne ke liye.
  • Bias-Variance Tradeoff seedha yeh tune karta hai.
  • Cross-Validation actually aise choose karte hain.
  • Feature Selection — Lasso ek embedded selection method hai.
  • Coordinate Descent & Proximal Gradient (ISTA/FISTA) — optimizers jo L1 kink ko respect karte hain.
  • Logistic Regression — L1 penalty seedha classification mein transfer hoti hai.

Concept Map

leads to

motivates

Lasso adds

controlled by

bigger lambda

produces

gives

derived via

clamps to zero when

contrast with

shrinks smoothly

OLS minimizes training error

Overfitting, big weights

Regularization

L1 penalty sum of abs weights

lambda strength

More shrinkage more zeros

Exact zeros, sparse model

Automatic feature selection

Soft-threshold operator

Non-differentiable kink at 0

Ridge L2 penalty

Never exactly zero