2.2.13 · D1Linear & Logistic Regression

Foundations — L1 (Lasso) regularization

2,841 words13 min readBack to topic

Before you can read the parent note, you must be able to hear every symbol in it without pausing. This page walks through each one, from the most basic to the sharpest, always attaching a picture. If the parent said "the L1 norm is a diamond," this page is where the diamond is actually drawn.


1. A data point:

Picture a spreadsheet. Each row is one example. The columns before the last are the values; the last column is the value.

  • = how many examples (rows) we have.
  • = how many features (measurement columns) each example has.

2. Weights , the bias , and the prediction

We stack all the weights into a list , one dial per feature.

Figure — L1 (Lasso) regularization

Look at the figure: each blue feature value gets scaled by its yellow dial, the scaled pieces drop into one green sum, and the baseline is added on — that green number is the prediction .


3. Error, squared error, and the (half) MSE

Figure — L1 (Lasso) regularization

The figure shows dots (real data) and a line (our guesses). Each red vertical stick is one error; we square each stick's length and add them up. A better line makes the total shorter.


4. Absolute value and the L1 norm

Figure — L1 (Lasso) regularization

The figure draws, for two weights , the set of dial settings whose tax equals a fixed budget. For the L1 recipe that set is a diamond with sharp corners sitting on the axes; for the L2 recipe it's a smooth circle. Notice: the diamond's corners are exactly the points where one weight is zero. That corner is the entire reason Lasso produces zeros — hold onto this picture, the parent note leans on it hard.


5. — the tax rate, and the full Lasso cost


6. — the un-penalized coordinate, plus sign and max


7. The kink: why has no slope at zero

Figure — L1 (Lasso) regularization

Look at the figure: the yellow V is with its sharp corner at , and the green rounded parabola is Ridge's . On the left the V has one steady slope (); on the right another (); at the very bottom there is no single slope — that abrupt change is the kink. The parabola, by contrast, glides through zero with a smooth, gentle bottom.


How these foundations feed the topic

data point x_i and y_i

prediction w0 plus w-dot-x

error = truth minus prediction

squared error then averaged = half MSE

absolute value = size

L1 norm = sum of sizes

lambda = tax rate

L1 penalty = lambda times L1 norm

cost J = half MSE plus L1 penalty

kink at zero in the V shape

soft-threshold uses sign and max

some weights become exactly zero = Feature Selection

The map reads top-to-bottom, and it is exactly the equation from Section 5 drawn as a graph: The data atom (top) builds the prediction, the prediction builds the error and half-MSE (left branch = first term); separately the absolute value builds the L1 norm which, taxed by , becomes the penalty (right branch = second term); their sum is the cost , and the kink in the V turns it into exact zeros.


Where this leads next

Once these symbols are second nature, the parent L1 (Lasso) regularization note (or its English twin) shows the full derivation of the soft-threshold, the diamond geometry, and worked examples. Related paths: Ridge (L2) Regularization uses the circle instead of the diamond, Elastic Net blends both, and the same penalty attaches to Logistic Regression. Choosing is a Bias-Variance Tradeoff settled by Cross-Validation.


Equipment checklist

What does the subscript in mean?
"Example number " — one row of the data spreadsheet.
What does compute in plain words?
A baseline plus a weighted sum: each feature times its dial, all added up onto the bias — the model's prediction.
What is the bias and is it taxed by Lasso?
A baseline offset added to every prediction; it appears as the term in and is NOT penalized.
Why do we square the error instead of just adding it?
To make every miss positive and to punish big misses far more than small ones.
What does tell you to do?
Add the following expression up over all examples.
What is the difference between the MSE and the term used in the cost?
MSE ; the cost uses , which is half the MSE — the is cosmetic and doesn't move the minimum.
What does stand for?
The objective / cost / loss — one number scoring how bad the weights are; training minimizes it.
What is ?
The L1 norm — the sum of the absolute values (sizes) of all the feature weights.
Why take absolute values before summing the weights?
So big positive and negative dials can't cancel; every large weight always raises the tax.
What shape is the L1 budget region for two weights, and why does it matter?
A diamond with corners on the axes; contours touch those corners, forcing weights to zero.
Write out the full Lasso cost .
.
What does control?
The tax rate — the balance between fitting the data and keeping weights small.
Where does in the soft-threshold come from?
It is the un-penalized (OLS) value a single weight would take with no tax — the bottom of that coordinate's data-fit bowl .
Read in words.
Keep the sign/direction, subtract the tax from the size, and clamp to zero if it would go negative.
Why does cause trouble at zero?
Its V-shape has a kink — no single slope at zero — so plain gradient descent can't cleanly land there.