2.2.15 · D1Linear & Logistic Regression

Foundations — Elastic Net regularization

2,280 words10 min readBack to topic

Before you can read the parent note, you need a toolbox. Below is every symbol and idea it uses, built from nothing, each one leaning on the one before it. Read top to bottom.


1. Data: the rows and the columns

The little below a letter is just an index — a row number, like a seat number. When you see it means "walk through every seat from to and add up."

Figure — Elastic Net regularization

Look at the figure: each row is one example (one cyan dot with its answer ). Each column is one feature — a property measured for every row. This row/column split is the whole game: rows are examples, columns are features.

  • = the value in row , column . Two indices: first says which row, second says which feature.

2. Vectors and the weighted sum

= the number of features (columns). So has one dial for each column.

Why weights? To predict, we take each feature, multiply by its dial, and add them all up: A big = "this feature strongly pushes the prediction"; = "ignore this feature completely." Deleting a feature just means setting its weight to zero — remember that, it is the heart of sparsity.

Why this tool and not another? A weighted sum is the simplest way to combine many numbers into one prediction where each feature's influence is a single tunable strength. That simplicity is why linear regression uses it — and Elastic Net is linear regression with a penalty bolted on.


3. Measuring the miss: the squared error

We have a guess and a truth . How wrong are we?

Why square it? Two reasons, both visible in the figure below. First, squaring makes every miss positive, so overshoots and undershoots don't cancel out. Second, it punishes big misses far more than small ones (a miss of costs , a miss of costs ), which pushes the line to avoid large blunders.

Figure — Elastic Net regularization

This is the term labelled "data fit" in the parent note. Small MSE = the line hugs the data.


4. The two rulers: L1 and L2 norms

A "norm" is a way to measure how big a vector is — how far the whole set of weights is from all-zero. Elastic Net uses two different rulers.

Why two rulers, and why do their shapes differ? Draw all weight-pairs that a ruler rates as "the same size." For L1 you get a diamond (corners on the axes); for L2 you get a circle. Those shapes are the secret to everything, so look carefully:

Figure — Elastic Net regularization

Why absolute value for L1 specifically? Absolute value has a sharp kink at zero, and that kink is precisely what creates the corner that snaps weights to . A smooth ruler (like L2) has no kink, hence no snapping. This is the whole reason the two behave differently.


5. Convexity: why the answer is unique (usually)

Why we care: if the whole objective is a bowl, there is one lowest point, and rolling downhill always finds it — no getting stuck in a fake dip. MSE is a bowl, L2 is a strict bowl, L1 is a bowl (with a crease). Their sum is a bowl, so Elastic Net has a well-defined best answer.


6. The knobs: and

These two knobs are independent: is how much penalty, is which flavour. Do not confuse them.


7. Two symbols from the derivation

The parent's "HOW to derive" section introduces two more pieces — meet them now so nothing is new later.

You'll meet these fully in Soft-Thresholding Operator and Coordinate Descent; here you only need to recognize the symbols.


Prerequisite map

Dataset rows and columns

Vectors x and weights w

Dot product = weighted sum = prediction

Residual and squared error

Mean Squared Error data fit

L1 norm diamond gives sparsity

L2 norm circle gives shrinkage

Convexity single best answer

Knobs lambda strength and alpha mix

Elastic Net objective J

Subgradient and soft threshold update

Everything on the left feeds the single node — the Elastic Net objective. Master the left side and the parent note reads like a story.


Equipment checklist

Self-test: cover the right side, answer, then reveal.

What does the index in mean?
A row number — which example we are talking about.
What does the double index in mean?
Row , column (feature) — the value of feature for example .
What is a weight in plain words?
A dial saying how strongly feature influences the prediction; means the feature is ignored/deleted.
What does compute?
The dot product — pair up matching entries, multiply, and sum — giving the prediction .
Why do we square the residual instead of just using it?
To make every miss positive (so they don't cancel) and to punish large misses more heavily.
Why the in MSE?
It averages, so the error size doesn't automatically grow just because there are more rows.
What is the L1 norm and what shape does it draw?
Sum of absolute values ; its constant-size curve is a diamond with corners on the axes.
What is the L2 norm squared and its shape?
Sum of squares ; its constant-size curve is a smooth circle.
Which ruler creates exact zeros and why?
L1 — its diamond corners sit on the axes (where a coordinate is zero), so solutions snap onto them.
What does convex mean and why does it matter?
Bowl-shaped with a single lowest point, so downhill search always finds the one best answer.
What does control vs what does control?
= how much total penalty; = the flavour/mix between L1 and L2.
What is doing in the soft-threshold?
Shrinking by but clamping at zero, so a too-small value gets deleted.

Connections