🌏 中文版
Video status: Videos included. This article is written from the official MOOC handout 13_handout.pdf and transcripts of this lecture's four official videos, with formulas and numbers following the handout. The transcripts are machine transcripts made for this article (Whisper), not official captions, and no human has proofread them. The videos are taught in Mandarin; the slides are in English. Each section opens with its official video and the approximate time ranges. Page numbers refer to the number at the lower right of each slide (0/22 to 22/22), and wherever the text says "in the lecture" it is paraphrasing what is said in the video.
This is Foundations Lecture 13 in Reading NTU Hsuan-Tien Lin Machine Learning Foundations & Techniques. The Roadmap on page 1 of the handout divides Foundations into four questions. The first three (when can machines learn, why can they learn, how can they learn) ended with the previous lecture, and this one starts answering the fourth: How Can Machines Learn Better? The summary of the previous lecture, Foundations Lecture 12: Nonlinear Transformation, on that same page is: a nonlinear feature transform plus a linear model gives a nonlinear model, at the price of model complexity. This lecture starts from that price and looks at the trouble it causes.
There are three prerequisites: the figure from Foundations Lecture 7: The VC Dimension in which falls as the VC dimension grows while falls and then rises; the least-squares solution and the learning curves from Foundations Lecture 9: Linear Regression; and the polynomial transform and nested hypothesis sets from the previous lecture. Basic manipulation of expectations and variances is also used.
After reading, you should be able to tell bad generalization apart from overfitting, say which figure in the handout shows each of the four causes of overfitting, compute how large the deterministic noise is for a simple target function, and judge whether a virtual example has been added correctly. This lecture is light on formulas and heavy on experiments, so this article adds three small examples that can be worked by hand, each computing once a phenomenon the handout presents as a figure.
What overfitting is: E_in goes down, E_out goes up
(Video 00:19–01:10 reviews the previous lecture, 01:10–03:18 is the five-point example, 03:18–06:38 separates bad generalization, overfitting, and underfitting, 06:38–10:01 is the driving analogy, and Fun Time follows.)
Five points fit with a 4th-order polynomial
The example on page 2 of the handout is small. It is a one-dimensional regression problem, , with only examples. The target function is a 2nd-order polynomial, and the label is plus very small noise. The learner does not know the target is 2nd order and picks a 4th-order polynomial: following the previous lecture, apply the 4th-order feature transform and then run linear regression in -space.
The handout says this yields a unique solution passing all 5 examples, so . This article fills in the reason. A 4th-order polynomial has 5 coefficients , and passing through 5 points means 5 equations:
That is 5 unknowns and 5 linear equations. As long as the 5 values are pairwise distinct, the coefficient matrix of this system (each row is , which makes it the data matrix of linear regression) is invertible, and there is exactly one solution. That solution makes every residual 0. Squared error cannot go below 0, so it is the one linear regression finds.
The problem shows in the figure: the right side of the slide draws the target curve in blue and in red. One of the 5 points is on the left and the other 4 are in the right half. To pass through every point, the red curve arches high in the middle where there is no data and then drops steeply at the right end, far from the blue curve. , yet is huge. In the lecture, Lin says the red curve looks nothing like the blue curve we want most.
The handout calls this situation bad generalization: low , high . In the lecture, Lin describes it as being unable to extend what has been learned to new cases: the 5 points that were seen are handled very well, and anything beyond them is not. This agrees with the VC bound, which says and can be far apart when the VC dimension is too large.
Bad generalization is a state, overfitting is a process
Page 3 brings back the figure from Foundations Lecture 7. The horizontal axis is the VC dimension , and the three curves are the in-sample error, which keeps falling; the model complexity, which keeps rising; and the out-of-sample error, which falls and then rises. The point where is lowest is written . On this figure the handout defines three things:
| Name | The handout's definition | What it describes |
|---|---|---|
| Bad generalization | Take for learning: is large | The state at one point |
| Overfitting | Switch from to : ↓, ↑ | The process of moving right |
| Underfitting | Switch from to : ↑, ↑ | The process of moving left |
1126 is just the number this course habitually uses for "some very large number". The footer of the page sums up the difference: bad generalization is low , high ; overfitting is lower , higher . The extra "er" says that two models are being compared.
In the lecture, Lin explains the names this way: fitting means doing well on . Overfitting is fitting done well, but overdone, so that gets worse instead; the slide colors the "over" and the "fitting" of the word differently for exactly this reason. Underfitting is not fitting well enough. Lin adds an assessment: underfitting is the easier one to handle, since enlarging the VC dimension usually works and the nonlinear transform of the previous lecture is the tool for it; overfitting is very common and not easy to solve, which is why this lecture is devoted to it.
The driving analogy: three causes
Page 4 puts two figures side by side: a good fit on the left (the red curve almost coincides with the blue one) and overfit on the right (the wild red curve from page 2). In the lecture, Lin says overfitting is the process of going from the left one to the right one, and the result is the state of bad generalization on the right. The handout then uses a car accident as an analogy for the causes of overfitting:
| Learning | Driving |
|---|---|
| overfit | commit a car accident |
| use excessive | "drive too fast" |
| noise | bumpy road |
| limited data size | limited observations about road condition |
In the lecture, Lin first states that this is only an analogy to aid understanding and not every detail matches, then explains it row by row:
- Driving too fast. Pressing the accelerator too hard corresponds to using too much of the power of model complexity. In the example the target is 2nd order, yet a 4th-order polynomial was used.
- A bumpy road. A little noise was added to the data. A bumpy road taken at speed easily leads to an accident.
- Not knowing the road. If the data points were densely packed, the data would tell the red curve it cannot arch up wherever it tries to, and the wild curve of page 2 would not appear. The example Lin gives: someone who knows the road well knows where the potholes are and steers around them, so the car can still go fast.
It takes all three together to be dangerous: limited knowledge of the road, a bumpy road, and an insistence on driving fast. The footer previews that the next section looks closely at two of them, noise and data size.
Numerical example: three points, three models
The following is an example made up for this article, not from the slides. It shrinks the setup of page 2 to a size that can be worked by hand: the target is a 1st-order function, there are 3 examples, and the candidate models are (constants), (lines), and (parabolas).
Setup. The target is . is uniform on , but the 3 examples drawn all happen to fall in the right half:
| Noise | ||||
|---|---|---|---|---|
| 1 | ||||
| 2 | ||||
| 3 |
is the mean squared error on the 3 examples. To keep the arithmetic doable by hand, is defined as the squared difference between and the target averaged over , ; computing it against the noisy instead would add the same constant to all three models and leave the comparison unchanged. A few moments of the uniform distribution on are used again and again below: , , .
: a constant. The least-squares constant is the mean of , .
: a line. and . The slope is . The denominator is . In the numerator the middle example has , which leaves . The slope is 1 and the intercept is :
The three residuals are , , and , so
: a parabola. With 3 coefficients and 3 points there is, as in the handout's example, a unique solution, and it passes through every point. Let . Substituting gives ; substituting gives ; substituting gives . The last two equations give and :
Its difference from the target is . After squaring and expanding, the odd-order terms have expectation 0 and only the even-order terms remain:
Here comes from and comes from .
Results.
| Model | |||
|---|---|---|---|
What this means. Each of the three terms has a place in this table. The lowest belongs to , whose position corresponds to in the figure on page 3. Switching from to , drops from 0.0089 to 0 and rises from 0.0011 to 0.405, more than three hundred times larger; this is overfitting. Switching from to , both errors rise; this is underfitting. Looking at the single hypothesis alone, and ; this is bad generalization.
All three causes are present too. The noise is only , but the parabola takes it seriously in order to pass through every point and learns a curvature that does not actually exist. There are only 3 examples and all are in the right half, so not one of them can tell the parabola that it must not bend upward in the left half: at , while the target is , a gap of 1.7. The line has not seen the left half either, but it has only two coefficients, and noise of merely shifts the whole line by .
Fun Time: which situation is least prone to overfitting
Question (page 5): Based on our discussion, for data of fixed size, which of the following situation is relatively of the lowest risk of overfitting?
- small noise, fitting from small to median
- small noise, fitting from small to large
- large noise, fitting from small to median
- large noise, fitting from small to large
Answer: 1. The handout's reference answer is: two causes of overfitting are noise and excessive , so if both are relatively "under control", the risk of overfitting is smaller. The question fixes the data size first, which leaves two of the three causes to compare. Choices 1 and 2 have the same noise, and 2 raises by more; choices 1 and 3 have the same , and 3 has larger noise; choice 4 is worse than 1 on both counts. In driving terms, 1 is a smoother road with only a small increase in speed.
The question asks about "relative" risk. Choice 1 can overfit as well: in the three-point example above the noise was small and the order went only from 1 to 2.
Noise and data size: why the learner who knows 10th-order polynomials loses to the one who only knows 2nd-order
(Video 00:00–02:22 sets up the two experiments, 02:22–05:29 looks at the results, 05:29–07:50 discusses the irony of two learners, 07:50–11:02 explains it with learning curves, 11:02–12:47 is the no-noise case, and Fun Time follows.)
Two data sets, two learners
Page 6 builds two artificial data sets, both one-dimensional regression problems:
- Left: the target is a 10th-order polynomial and noise is added to the data. The black points in the figure sit a little away from the blue target curve.
- Right: the target is a 50th-order polynomial with no noise at all. The blue curve bends much more than the one on the left, and the black points all lie exactly on it.
Both figures contain only a dozen or so examples.
Then come two learners. In the lecture, Lin presents them as two students: one knows only polynomials up to order 2 and, after seeing the data, picks the best from (the green curve in the figure); the other knows all polynomials up to order 10 and picks the best from (the red curve). The question in the footer is: is there overfitting from to ?
The result: both overfit
The numbers on page 7:
| Target | |||
|---|---|---|---|
| 10th order + noise | |||
| 50th order, noiseless | |||
In both experiments is lower for . This is bound to happen, because : contains , and the best choice from a larger set cannot be worse than . Lin puts it this way in the lecture: the red student knows more polynomials and has more choices, so naturally reaches a lower .
goes the opposite way entirely. On the left has 0.127 and has 9.00, about 71 times as much; on the right has 0.120 and has 7680, a factor of 64,000. The red curves in the figures swing widely between the data points. For the right-hand one, Lin describes the red curve as low where the target is high and high where the target is low, nothing like the 50th-order target. falls and rises, so by definition both are overfitting; the footer reads both yes!
The irony of the first experiment: concession for advantage
Page 8 names the two learners: O (Overfit) picks and R (Restrict) picks . It then supposes both of them know that the target is a 10th-order polynomial.
Intuitively O should have the edge: the target is 10th order and O knows 10th-order polynomials. R does not even know 10th order; the handout says R "gives up" ability to fit. Lin is more direct in the lecture: asking a student who only knows 2nd order means giving up on perfection from the start, because no 2nd-order polynomial can match a 10th-order target perfectly. Yet R wins in by a lot.
The footer of the handout reads philosophy: concession for advantage?, and in the lecture Lin glosses it with a Chinese idiom about stepping back in order to move forward. Lin also gives an example about a boss: if your boss tells you this problem can probably be solved with a 10th-order polynomial, you will most likely go straight to a 10th-order model, and it will not occur to you that a 2nd-order one might do better. Knowing the target is 10th order and actually learning with 10th order does not necessarily work better.
Explaining it with learning curves
Page 9 brings back the learning curves from Foundations Lecture 9. The horizontal axis is the data size and the vertical axis is the expected error, with one figure for and one for . Here the handout writes and for averages over many data sets.
Lin goes over again what the two figures have in common:
- As , and converge to the same value.
- For finite , is a bit below that value. The data is visible, so optimization pulls the curve toward the data points.
- is a bit above that value. A curve pulled toward the points it has seen drifts away at the points it has not; Lin says that if there is noise over there, the distance is in effect doubled.
Foundations Lecture 9 worked out how large this "bit" is for linear regression: with noise of level , the average and the average , a difference of . is the number of parameters, 3 for and 11 for .
The two figures differ in two ways. First, they converge to different values: contains the 10th-order target, so only the noise remains in the limit; cannot represent the target, so its limit is higher. This is the handout's first bullet: has lower when . Second, the distance between and differs: has large model complexity, so the two are pulled far apart. In the slide's figure for , shoots straight off the top of the plot where is small.
Both figures have a gray area on the left, the range of small . Comparing the two figures within that range, has lower and higher . The handout writes gray area: O overfits!, and the conclusion is R always wins in if small.
Lin's comment in the lecture is that this is a case of being too clever for one's own good: knowing too many hypotheses makes very good, and the exam () goes badly. The advice is not to split hairs when there is not enough data, and to explain the data with simple hypotheses; that is imperfect, yet may well work better.
Numerical example: computing the gray area
The following is an example made up for this article, not from the slides. It is a scaled-down version of the first experiment: the target is inside O's hypothesis set, the data is noisy, and R cannot even represent the target.
Setup. The target is and , where the are mutually independent noise with mean 0 and variance . R uses (constants) and O uses (lines), both with least squares. So that the expectations can be worked out by hand, the are fixed at equally spaced points on (in the handout's experiment is drawn at random), which gives ; write . At test time is uniform on and . In this example is computed against the noisy , consistent with the learning curves of Foundations Lecture 9. The expectation is taken over the noise in the training data.
R's . . Because , , the mean of the training noise, whose variance is . The error at a test point is , three mutually independent terms each with mean 0, so the expected square is the sum of the three variances:
is , the price of R being unable to represent the slope, and no amount of data makes it go away.
O's . When , the least-squares line has intercept and slope
Write ; its mean is 0 and its variance is . The error at a test point is . The covariance of and is proportional to , so the cross term vanishes:
The equally spaced points have (for the two points are and ; for they are and ; both agree). Substituting, :
This looks almost the same as from Foundations Lecture 9 (here ).
. O's average is , which is the formula from Lecture 9. R's residuals are , and its average is .
Plugging in numbers. Take , noise much larger than the signal:
| R's | R's | O's | O's | Lower | |
|---|---|---|---|---|---|
| 2 | 3.000 | 6.333 | 0.000 | 6.667 | R |
| 3 | 3.333 | 5.667 | 1.333 | 6.000 | R |
| 5 | 3.700 | 5.133 | 2.400 | 5.333 | R |
| 9 | 3.972 | 4.778 | 3.111 | 4.800 | R |
| 10 | 4.007 | 4.733 | 3.200 | 4.727 | O |
| 20 | 4.168 | 4.533 | 3.600 | 4.381 | O |
| 100 | 4.300 | 4.373 | 3.920 | 4.079 | O |
| 4.333 | 4.333 | 4 | 4 | O |
What this means. In every row O's is lower than R's. For O's is higher, and these rows are the gray area in the handout's figure: switching from R to O, falls and rises. O wins only from on, by a growing margin, and the limit is 4 against 4.333, matching the handout's statement that has lower when .
The difference of the two curves is . The first term is the extra noise O absorbs by learning one more thing, the slope; the second is the fixed price of R being unable to represent the target. The larger the noise or the smaller the data, the larger the first term and the wider the range where R wins; Self-check question 3 works out the low-noise case.
The second experiment: no noise, and R still wins
Page 10 returns to the experiment with the 50th-order target and no noise. This time suppose both learners know there is no noise; R still wins.
In the lecture, Lin first voices the doubt: with noise, one can say went wrong by chasing the noise; now there is no noise, so why does still do badly? Lin then asks back, in the words on the handout: is there really no noise? Lin's answer is that there is, only of another kind. What is to be learned is very complex: that winding 50th-order curve is beyond a 10th-order polynomial and beyond a 2nd-order one too, and the gap that cannot be reached behaves like noise. The handout's wording is "target complexity" acts like noise. The section on deterministic noise turns this into an experiment.
Fun Time: when R wins
Question (page 11): When having limited data, in which of the following case would learner R perform better than learner O?
- limited data from a 10-th order target function with some noise
- limited data from a 1126-th order target function with no noise
- limited data from a 1126-th order target function with some noise
- all of the above
Answer: 4. The handout's reference answer says that 1 and 2 were discussed, and that you should be able to "generalize" that R also wins in the more difficult case of 3. Choice 1 is the first experiment. Choice 2 replaces 50th order with 1126th order: the target is more complex, the part a 10th-order polynomial cannot reach is larger, and that noise-like thing only grows. Choice 3 is both at once: a complex target with stochastic noise added; O lost in 1 and 2 with one kind each, and stacking the two will not turn the result around.
The words "limited data" at the start of the question must not be dropped. In the numerical example above, O wins once .
Deterministic noise: when the target is too complex, overfitting happens even without noise
(Video 00:00–03:41 covers the experimental design and the overfit measure, 03:41–06:18 looks at the two result figures, 06:18–09:43 covers the two kinds of noise and the four causes, 09:43–12:56 defines deterministic noise, and Fun Time follows.)
A more detailed experiment
Page 12 writes how the data is generated as a formula with three adjustable quantities:
- Noise level : is Gaussian iid noise.
- Target complexity : the target is a polynomial of order . The two earlier experiments were and .
- Data size .
The handout says is drawn from the polynomials of order by some "uniform" distribution, with uniform in quotes. In the lecture, Lin explains why this is not easy: if the coefficients are simply generated at random, the coefficient of the highest-order term is often tiny, so the resulting polynomial does not really bend that much and is a lower-order polynomial disguised as a 50th-order one. The generation process therefore needs some normalization first, to make sure most of what is drawn are "true" polynomials of order . The lecture does not give the details, and this article does not expand on them either.
Page 13 defines how overfitting is measured. There are again two learners, and . holds for sure, so only needs to be looked at:
Positive and large means serious overfitting; negative means the 10th-order learner really did better.
The two result figures
Page 14 has two figures that show the overfit measure by color, on a scale from (dark blue) to (dark red) with 0 in the middle as green. The horizontal axis of both is the data size , with ticks at 80, 100, and 120.
| Left figure | Right figure | |
|---|---|---|
| Vertical axis | Noise level (ticks at 0, 1, 2) | Target complexity (ticks from 0 to 100) |
| Fixed quantity | ||
| Red (serious overfitting) | Upper left: large noise, little data | Upper left: complex target, little data |
| Blue ( is better) | Lower right: small noise, much data | Lower right: not-so-complex target, much data |
In the left figure the red-blue boundary is a slanted band from lower left to upper right: the more data, the larger the noise it takes to overfit. Lin says in the lecture that this is no surprise, since large noise with little data was already shown to cause overfitting.
The right figure is more interesting. Its overall trend resembles the left one, and Lin's reading in the lecture is that a more complex target with too little data is no different from noise. Looked at closely, the boundaries of the two figures have different shapes: in the right figure, above a of roughly 25, the red-blue boundary is nearly vertical, the whole left half is dark red, the upper right corner is light blue, and the darkest blue is at the lower right where is between the low teens and the twenties. The right figure also has a feature the left one lacks: around a of 10 there is a horizontal divide, and below it the left end, where data is scarce, is red and quickly turns dark blue toward the right; the thin strip closest to the horizontal axis is yellow-green all the way across (an overfit measure from around 0 to slightly above 0). In other words, even when the target is very simple the figure still has regions of overfitting. This strip is explained with the four causes below.
Under the two figures the handout writes ring a bell? and shows the course logo. These two figures are the two largest pieces (upper left and lower right, meeting in the middle) of the logo on the cover of every handout. In the lecture, Lin goes on to explain the two small cells as well: the lower left stands for the nonlinear transform and the upper right for linear learning.
Two kinds of noise, four causes
Page 15 gives each figure a name. The left figure is the impact of , called stochastic noise. The right figure is the impact of , called deterministic noise. Lin explains the naming in the lecture: both have the effect of noise, one is generated at random and the other is fixed and can be computed.
The handout then lists four reasons of serious overfitting:
| Cause | Direction | Where it is in the figures |
|---|---|---|
| Data size | ↓ | The left side of both figures |
| Stochastic noise | ↑ | The top of the left figure |
| Deterministic noise | ↑ | The top of the right figure |
| Excessive power | ↑ | The strip at the very bottom of the right figure |
The fourth cause explains the bottom of the right figure. This experiment compares 2nd order with 10th order. When the target is below 10th order, the learner who knows 10th order is too strong; Lin says in the lecture that when that learner is given an easy problem and the data contains noise (the right figure fixes ), the learner will fit that noise. This is the "drive too fast" row of the driving analogy, using excessive , a cause that was already known.
What Lin stresses in the lecture are the other three: as long as there is noise, or the target is more complex than you think, switching to a more complex model can overfit, especially when there is not enough data. The handout's conclusion is overfitting "easily" happens. Lin adds an analogy: using machine learning without knowing it well is like a child driving a big truck, and an accident comes easily.
The definition of deterministic noise
Page 16 gives the definition. If , something of cannot be captured by any hypothesis in . Let be the best hypothesis in ; deterministic noise is the difference between and . In the slide's figure the blue curve is , the red curve is , and the gray area between them is the deterministic noise.
The handout says it acts like "stochastic noise", and that this is not new to CS: pseudo-random generator. Lin's explanation in the lecture is that the random numbers in a computer are not truly random but are computed by a very complicated function, so a deterministic function has been used to produce a random effect all along.
It differs from stochastic noise in two ways:
- It depends on . Lin says in the lecture that with a more complex hypothesis set the deterministic noise in theory gets smaller; the power grows as well, though, so things still get more dangerous.
- It is fixed for a given . As Lin puts it in the lecture: draw many times for the same and the deterministic noise is the same every time, whereas the stochastic noise differs each time.
The footer is a line of educational philosophy: when teaching a kid, perhaps better not to use examples from a complicated target function. In the lecture, Lin illustrates it with teaching a daughter to count: a small child's hypothesis set is very simple, so when teaching her to count one, two, three, four, you would not bring up number theory or the completeness of the real numbers, nor mention that there are irrational numbers beyond the rationals; she has not learned the integers yet and has no need for anything that complicated. Not using overly complex examples when teaching a simple hypothesis set keeps the deterministic noise smaller.
Numerical example: computing overfitting from noiseless data
The following is an example made up for this article, not from the slides. It corresponds to the second experiment: the data has no noise at all, and the target is outside both learners' hypothesis sets.
Setup. The target is , is uniform on , and with no noise. There are only examples, with and drawn independently. R uses (constants) and O uses (lines). . Besides the earlier moments, is also used.
Step 1: deterministic noise. Find the best in , that is, minimize . Differentiating with respect to gives , or ; the odd moments are all 0, so . Differentiating with respect to gives . The best line is horizontal:
Its mean square is . The best constant in is also , so in this example the two hypothesis sets have deterministic noise of the same size. It has a fixed value at every : at and at .
Step 2: how R does. . is the average of two independent copies of , so and . Split into , two independent parts each with mean 0:
is , with expectation .
Step 3: how O does. The line through and has slope , so
Write and . , and after expanding, the odd-order terms vanish:
Now take the expectation over the data: (the cross term ), , and :
Results.
| Learner | Average | Average | Of which deterministic noise | The rest |
|---|---|---|---|---|
| R () | ||||
| O () |
The overfit measure is , which is positive. In a simulation with 2 million random data sets, O's average is 0.5332 and R's is 0.1333, in agreement with the hand calculation; in about 97% of the data sets O is the worse one.
What this means. The data contains no stochastic noise whatsoever, and switching from R to O still makes fall (0.044 → 0) and rise (0.133 → 0.533). O's line passes perfectly through the two points every time. The values of those two points contain a component that a line cannot represent, and O learns it as slope and intercept, so a different data set gives a different line. The column "The rest" is the error caused by this swaying with the data, and O's is ten times R's. Deterministic noise plays the same role here as the in the "three points, three models" example: both are things the model should not swallow whole.
This setup is close to Fall 2024 HW4 Q8 (the target there is , likewise fit with a line through two examples). This article uses a different target function and computes a different quantity; it is not a solution to that problem.
Fun Time: the deterministic noise of sin(1126x)
Question (page 17): Consider the target function being for . When is uniformly sampled from the range, and we use all possible linear hypotheses to approximate the target function with respect to the squared error, what is the level of deterministic noise for each ?
Answer: 1. The handout's reference answer says you can try a few different and convince yourself that the best hypothesis is , and that the deterministic noise is the difference between and . Lin's reasoning in the lecture: the best one is the flat line, since tilting up or tilting down cannot follow the sine function; the flat line is 0, so the deterministic noise is the target function itself, and taking its level means adding the absolute value.
This article computes . Minimizing and differentiating with respect to gives . The denominator is . The numerator uses integration by parts; for an integer :
Dividing by gives . So
The difference between this number and 0 shows up only in computation: over all of , is at most , the mean squared error of is , and that of is . This is what the handout means by and a deterministic noise of ; among the four choices only choice 1 corresponds to this nearly flat line, so there is no doubt that the answer is 1. Intuitively, goes through 1126 periods on , the positive halves and negative halves cancel almost completely, and no slope can line up with it.
Each of the other choices corresponds to one specific : choice 2 is , choice 3 is , and choice 4 is . Numerical integration gives these mean squared errors: 0.5 for , about 13.66 for , and about for . They are all far from the best hypothesis, so their difference from is not deterministic noise.
As in the example above, the best linear hypothesis in this question does (almost) nothing, and all of the target's variation becomes deterministic noise.
Dealing with overfitting: start with the data
(Video 00:00–03:18 returns to the driving analogy and lists five remedies, 03:18–06:28 is data cleaning and pruning, 06:28–08:37 is data hinting, 08:37–09:40 is Fun Time, and the summary of the whole lecture follows.)
Five remedies
Page 18 extends the driving analogy table of page 4 by five rows:
| Learning | Driving | Explanation in the lecture |
|---|---|---|
| start from simple model | drive slowly | Driving fast leads to a crash, so drive slower |
| data cleaning/pruning | use more accurate road information | The road information may be noisy; make it more accurate |
| data hinting | exploit more road information | When no more data can be collected, generate new data from the existing data or from what is known about the problem |
| regularization | put the brakes | You may drive fast, but brake at the right moments |
| validation | monitor the dashboard | Keep checking how well you are driving |
The first row was covered in the previous lecture, whose advice was to try first. Regularization is left to Foundations Lecture 14: Regularization, and validation to Foundations Lecture 15: Validation. This lecture only briefly covers the middle two rows.
The handout's comment is all very practical techniques to combat overfitting. Lin puts it more strongly in the lecture: these are the practical tools for doing machine learning well, sometimes they must be combined, and when one does not work you switch to another; these ways in which humans help the machine learn better are sometimes more important than the algorithm itself.
Setting this table against the four causes (this article's own summary): data cleaning and pruning deal with stochastic noise, data hinting deals with data size, and starting from a simple model and regularization deal with excessive power. Deterministic noise depends on the gap between the target and the hypothesis set, and no row corresponds to it directly.
Data cleaning and pruning
Page 19 uses the handwritten digit example that appeared in Foundations Lecture 3: Types of Learning: telling 1 from 5, with each image turned into two concrete features and plotted on a plane. The blue circles are 1s, clustered at the top; the red crosses are 5s, spread across the bottom. One point labeled 5 lies at the upper left, right up against the cluster of circles. The slide pulls out its original image, which looks like nothing more than a horizontal stroke. Lin says in the lecture that no matter how you look at it you cannot see why it is a 5, and that calling it something closer to a 1 would be more plausible.
For how to "detect" such a point the handout lists a few clues, ending with an ellipsis to indicate there are others:
- It is too close to other ○, or too far from other ×.
- Learn a classifier first; that classifier gets this point wrong, and wrong by a wide margin.
Once detected there are two possible actions:
- Data cleaning: correct the label. Lin says in the lecture that you can also ask someone to label it again.
- Data pruning: remove the example and train on fewer but cleaner data.
The handout's comment is possibly helps, but effect varies. Lin explains two reasons in the lecture. First, the hard part is detection: there is no method guaranteed to tell which example is the bad one, and each approach has its trade-offs. Second, even when one is found the effect may be small: in this example there are very many blue points and red points, and whether that one mislabeled cross is corrected or not, dropped or not, may make little difference to the overall result of learning. On some problems a clear benefit does appear.
Data hinting: supplementing the data with virtual examples
Page 20 stays with handwritten digits. The slide lays out images of dozens of digits, all slightly slanted or displaced. The handout's observation is that slightly shifted or rotated digits carry the same meaning. Lin's example in the lecture is writing a 3: rotate it a little and it is still a 3.
So when there is no more data at hand and you want to tell the computer this piece of knowledge, you can take the existing digits, shift and rotate them, and add the resulting new data for retraining. These new data are called virtual examples and the practice is called data hinting: giving the algorithm a few more hints.
The handout's comment is possibly helps, but watch out, with a specific reason: a virtual example is not drawn iid from . Lin's explanation in the lecture is that all the earlier theory assumes comes iid from some distribution, and these newly manufactured examples definitely do not come from there. Lin says the practice can be useful in particular applications, when it puts knowledge of the problem domain in, but the added data has to make sense and must not stray too far from the original; drift too far from the original distribution and you may learn to classify all the rotated ones correctly while getting the original ones wrong. Lin tosses in an example of rotating too far: a 6 rotated by 180 degrees becomes a 9.
Fun Time: which virtual examples to add for a symmetric target
Question (page 21): Assume we know that is symmetric for some 1D regression application. That is, . One possibility of using the knowledge is to consider symmetric hypotheses only. On the other hand, you can also generate virtual examples from the original data as hints. What virtual examples suit your needs best?
Answer: 3. The handout's reference answer is: we want the virtual examples to encode the invariance when . , and , so at the position the reasonable label is .
Each of the other choices expresses a different property, none of them the one the question gives. Choice 1 puts two opposite labels at the same , which amounts to telling the algorithm that is about 0. Choice 2 expresses , an odd function. Choice 4 expresses , the kind of property a line through the origin has.
As an addition in this article, here is what these hints actually do. Fit a least-squares line to and together. In the combined data the mean of is 0, and
The numerator of the slope is 0, so . With the hints added, the line automatically becomes a symmetric horizontal line, the same result as considering symmetric hypotheses only.
Apply this back to the deterministic noise example: the target happens to be symmetric. After getting the two examples, O adds and , and the line fit to the four points is , exactly R's answer, so the average drops from to . In this example the mirrored points do not stray from the original distribution (although each is not independent of the example it came from), because the distribution of is itself symmetric and the target really is symmetric; if the question had an asymmetric distribution instead, the mirrored points would land where data originally rarely appears, and that is the situation the handout tells you to watch out for.
Summary of this lecture
Page 22 condenses each of the four sections into one line: overfitting is lower but higher ; it happens easily; what cannot capture acts like noise; the remedies are data cleaning, pruning, hinting, and more. Lin wraps up the lecture this way: the causes are noise, not enough data, and too much power, and a target that is too complex can also be seen as a kind of noise; what was covered today are simple approaches that start from the data, which may help and may not. The preview of the next lecture is putting the brakes with regularization, learning how to brake.
Self-check
1. Three models give these results on the same data: A (, ), B (, ), C (, ), with complexity A < B < C. Which statements can be described with "bad generalization", "overfitting", and "underfitting"?
Answer: C by itself is bad generalization ( low, high, 0.89 apart). Switching from B to C is overfitting ( 0.10 → 0.01, 0.15 → 0.90). Switching from B to A is underfitting (both rise). Criterion: overfitting and underfitting must state which model is switched to which; saying only "C overfits" mixes up a state with a process.
2. The target is , is uniform on , the hypothesis set is , and the error is squared error. What is the best ? What is the mean square of the deterministic noise?
Answer: . The deterministic noise is , and its mean square is . Here is not 0, unlike the of Fun Time: part of can be captured by a line, and only what cannot be captured is deterministic noise.
3. In the "computing the gray area" example, change the noise to . For which does R win? In general, how large must be for R to have a chance of winning?
Answer: the difference of the two curves is . is at both and , is at , and keeps shrinking after that, so its maximum is . With the difference is at most , so O wins at every and there is no gray area. For R to win at some , it takes , that is, . When the noise is small, no shortage of data produces overfitting; this is the "stochastic noise ↑" row of the four causes.
4. The handout says deterministic noise depends on : the larger is, the smaller the deterministic noise. Then why does switching from to overfit instead?
Criterion: the answer has to separate two things. Deterministic noise is the difference between and ; as grows the best gets closer to , and this difference does shrink. But with limited data what is learned is not , and a larger has more degrees of freedom to fit the noise in the few examples at hand (both kinds of noise count), which is the "excessive power" cause. In the experiment with the 50th-order target, the 10th-order polynomial has smaller deterministic noise than the 2nd-order one, yet is 7680 against 0.120. Citing the learning curves or the "The rest" column of the noiseless example above is even better.
5. For handwritten digit recognition, someone rotates every image by 180 degrees, keeps the labels, and adds the results to the training data as virtual examples. What is wrong?
Answer: keeping the label presupposes that the transformation does not change the meaning. That holds for small rotations and fails for 180 degrees: a 6 becomes a 9. These virtual examples amount to injecting a batch of mislabeled data, that is, manufacturing stochastic noise yourself. Even if you pick digits that are unaffected (such as 0 and 8), upside-down digits almost never appear in normal data, so these points are far from , which is the situation the handout's watch out line refers to.
Exercises and corresponding reading
Corresponding weeks in two semesters. The Fall 2024 course page puts this lecture and the next in the same week (W7, 10/14), and the slides for this lecture are 13u_handout.pdf. The Fall 2026 course page schedules it in W7 (10/21); when checked on 2026-09-30 the slide link for that week was still a 404, so this article uses only the MOOC handout.
Textbook. Both course pages map this lecture to sections 4.0 and 4.1 of Learning from Data (LFD).
Homework. The related problems are in Fall 2024 HW4 (released 2024-10-21, due 11-04) and HW5 (released 11-04, due 11-18), neither with official solutions:
- HW4 Q8: the target is , approximated by a line , with linear regression on just two examples; find . This is a case where is not in , and you can start the way this article's noiseless example does, writing in terms of and and then taking the expectation.
- HW4 Q9: the problem says "In Lecture 13" explicitly. It generates virtual examples by adding Gaussian noise to the inputs and asks for the form of ; a note in the problem points out its relation to the matrix that regularized linear regression inverts.
- HW5 Q5: prove that linear regression with certain virtual examples added has the same solution as a weighted L2 regularization. This problem connects this lecture's data hinting to the next lecture's regularization, so do it after reading the next lecture.
The guide to the homework as a whole is the Foundations homework guide.
Hands-on. Before watching the second video, guess for yourself who wins each of the two experiments, then compare with the table on page 7. While watching the third video, copy down the four causes and pair each with an example you have seen at work. To reproduce page 7 yourself, use numpy to generate a data set from a 10th-order polynomial plus noise, take a dozen or so examples, fit 2nd order and 10th order with numpy.polyfit, and compute on a few thousand separately drawn examples; the numbers will not match the handout (which does not publish that data set), but you should see the of far above that of .
Further reading. Another way of telling the same story is the bias-variance decomposition; see Stanford CS229 Lecture 6: Bias and Variance, Regularization, and Model Selection.
Next lecture. Foundations Lecture 14: Regularization handles "put the brakes" from the analogy table: how to learn in without letting it use all of its power.
Course video sources
Original videos: What is Overfitting?, The Role of Noise and Data Size, Deterministic Noise, Dealing with Overfitting
Checked: 2026-10-13. The video IDs, titles, and lengths were taken from the official playlist that day; the videos have no caption tracks on YouTube, and what this article reports from the lecture comes from transcripts made for it.
Update Log
- 2026-10-13: Previously combined with Lecture 14 in one article; changed to one article per lecture and rewritten from the handout and the video transcripts.
- 2026-10-10: Marked the video status and checked the recording sources and how they were obtained.
- 2026-10-10: Rechecked the video status. The embedded videos match the lecture numbering of the official playlist.
References
- Foundations Lecture 13 handout 13_handout.pdf: the main basis of this article; the definitions in the four sections, the experimental numbers on page 7, the two result figures, the four causes, and the four Fun Time questions all come from this handout.
- Foundations Lecture 9 handout 09_handout.pdf: the formulas for the linear regression learning curves (pages 16 and 17), used to explain the two learning curves on page 9.
- Machine Learning Foundations YouTube playlist: this lecture is videos 50 to 53 of the playlist; what the text reports as said "in the lecture" is paraphrased from machine transcripts of these four videos.
- Hsuan-Tien Lin > MOOCs: the official portal for handouts and recordings.
- Machine Learning, Fall 2024 course page: the corresponding week, the 13u slides, and the LFD sections.
- Machine Learning, Fall 2026 course page: the corresponding week and the LFD sections.
- Fall 2024 Homework 4 (hw4_red.pdf): the content of Q8 and Q9.
- Fall 2024 Homework 5 (hw5.pdf): the content of Q5.
- Learning from Data textbook site: the source for sections 4.0 and 4.1.
- Reading NTU Hsuan-Tien Lin Machine Learning Foundations & Techniques: course overview: where this lecture sits in the whole course and the reading routes.