§5.1.3–5.1.4The Experience, E · Example: Linear Regression

Part I DL pp. 104–109 · ~4 min read

§5.1.3 The experience, E

What the algorithm gets to see splits machine learning into its two broad families. Unsupervised algorithms experience a dataset of features and learn useful properties of its structure — in deep learning, usually the whole distribution p(x)p(\boldsymbol{x}) (explicitly, as density estimation, or implicitly, for synthesis and denoising), or other roles like clustering. Supervised algorithms additionally see a label (or target) with each example — learning to predict y\boldsymbol{y} from x\boldsymbol{x}, usually by estimating p(yx)p(\boldsymbol{y} \mid \boldsymbol{x}). The name pictures an instructor showing the system what to do; unsupervised learning has no teacher.

The classic Iris dataset (Fisher, 1936) illustrates both: 150 plants, four measurements each (sepal length/width, petal length/width) — and a species annotation that turns it supervised.

Aside — the blurred line

The two families are not formally distinct. The chain rule (p(x)=ip(xix1,,xi1)p(\boldsymbol{x}) = \prod_i p(x_i \mid x_1, \dots, x_{i-1}), eq 5.1) splits the “unsupervised” problem of modeling p(x)p(\boldsymbol{x}) into nn supervised prediction problems; and the “supervised” p(yx)p(y \mid \boldsymbol{x}) can be recovered from unsupervised modeling of the joint via p(yx)=p(x,y)/yp(x,y)p(y \mid \boldsymbol{x}) = p(\boldsymbol{x}, y) / \sum_{y'} p(\boldsymbol{x}, y') (eq 5.2). Other variants exist too: semi-supervised (some targets missing), multi-instance (only collections labeled), and reinforcement learning (a feedback loop with an environment — outside this book’s scope).

Most datasets are described by the design matrix : one example per row, one feature per column — Iris is XR150×4\boldsymbol{X} \in \mathbb{R}^{150 \times 4}, with Xi,1X_{i,1} the sepal length of plant ii. (When examples have different sizes — photos of different resolutions — we fall back to a set {x(1),,x(m)}\{\boldsymbol{x}^{(1)}, \dots, \boldsymbol{x}^{(m)}\}; chs. 9–10 handle such data.) Supervised datasets add a label vector y\boldsymbol{y} with yiy_i the label of example ii (labels can be richer — a whole sentence for speech transcription).

§5.1.4 Example: linear regression

The abstract definition, made concrete by the simplest interesting learner. Task T: predict scalar yy from xRn\boldsymbol{x} \in \mathbb{R}^n by outputting

Term by term

y^=wx\hat{y} = \boldsymbol{w}^\top \boldsymbol{x}
w\boldsymbol{w}the PARAMETERS — weights deciding how each feature affects the prediction: positive weight = feature pushes ŷ up; large magnitude = large effect; zero = no effectn×1
y^\hat{y}the model’s prediction of y — a linear function of the inputscalar

Measure P: mean squared error on a held-out test set, MSEtest=1mi(y^(test)y(test))i2=1my^(test)y(test)22\mathrm{MSE}_{\mathrm{test}} = \frac{1}{m}\sum_i (\hat{y}^{(\mathrm{test})} - y^{(\mathrm{test})})_i^2 = \frac{1}{m}\|\hat{\boldsymbol{y}}^{(\mathrm{test})} - \boldsymbol{y}^{(\mathrm{test})}\|_2^2 — zero exactly when predictions equal targets, growing with their Euclidean distance. Experience E: a training set (X(train),y(train))(\boldsymbol{X}^{(\mathrm{train})}, \boldsymbol{y}^{(\mathrm{train})}). The algorithm: minimize MSEtrain\mathrm{MSE}_{\mathrm{train}} (justified properly by maximum likelihood in §5.5) — and for this model the minimum has a closed form:

The normal equations (eqs 5.6 → 5.12)
wMSEtrain=0\nabla_{\boldsymbol{w}} \mathrm{MSE}_{\mathrm{train}} = 0

step 1/5: The MSE is a convex quadratic bowl in w — its minimum is exactly where the gradient vanishes (§4.3: solve ∇f = 0 directly instead of iterating).

Fig 5.1 (interactive) — slide w₁ along the MSE bowl, or jump straight to the normal-equations solution
data & the line ŷ = w₁xMSE(w₁) — the bowl being descendedw* (normal eqs)w₁

MSE = 0.229

red segments: the residuals whose squares the MSE averages

Aside — the bias parameter

“Linear regression” usually means the affine model y^=wx+b\hat{y} = \boldsymbol{w}^\top\boldsymbol{x} + b: still linear in the parameters, but the line no longer must pass through the origin. The intercept bb is called the bias parameter — the output is biased toward bb absent any input. (Distinct from a statistical bias, §5.4.2!) Trick: instead of adding bb, append a constant feature 1 to x\boldsymbol{x} — its weight plays the role of bb. The book says “linear” for affine throughout.

Linear regression is limited, but it is a complete T/P/E loop with a provably optimal learner — the reference point for every principle that follows: capacity, overfitting and underfitting.

Check yourself — experience and linear regression

1.Why does the book call the supervised/unsupervised line 'blurred'?

2.In the design matrix X ∈ ℝ¹⁵⁰ˣ⁴ for Iris, what are rows and columns — and when does the design-matrix description fail?

3.In LinRegLab you press 'solve normal equations'. What just happened, mathematically?

4.What does the 'bias parameter' b do, and how does it differ from statistical bias?

5.Which learning paradigm involves a feedback loop with an environment rather than a fixed dataset?

5 questions