🌏 中文版
Video status: Videos included. This article is written from the official MOOC handout 12_handout.pdf and transcripts of this lecture's four official videos, with formulas 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 12 in Reading NTU Hsuan-Tien Lin Machine Learning Foundations & Techniques. The Roadmap on page 1 of the handout divides Foundations into four questions, and this is the last lecture under the third one, "How Can Machines Learn?". The previous lecture, Foundations Lecture 11: Linear Models for Classification, is summarized on the same page: binary classification via (logistic) regression; multiclass via OVA/OVO decomposition. Up to that point, the three models PLA, linear regression, and logistic regression can only compute a linear score . This lecture answers the question of whether those three models are still usable when no line separates the data at all.
The prerequisites are PLA from Foundations Lecture 2 (the update rule ), the VC dimension from Foundations Lecture 7 ( for the -dimensional perceptron, and how to read ), plus conic sections and counting from high school. After reading, you should be able to write a quadratic curve as a weight vector in Z-space, work through every step of "transform, then run PLA" by hand on a small data set, compute the dimension of the -th order polynomial transform, and explain why choosing the transform after looking at the data voids the VC guarantee.
What to do when no line separates the data: turning a circular boundary into a line in Z-space
(Video 00:17–02:30 reviews linear hypotheses and their limit, 02:30–04:59 covers circular separable data, 04:59–11:21 renames the coefficients and the inputs, 11:21–17:29 looks at the curve each of five weight vectors draws, 17:29–22:58 covers the general quadratic hypothesis set, and Fun Time follows.)
What linear hypotheses offer and where they stop
Page 2 of the handout arranges the linear hypotheses seen so far into two columns. The left column is what they look like: visually a 'line'-like boundary, mathematically linear scores . The right column is their limit: theoretically is under control, which is good; practically, on some , is large for every line. The figure in the right column shows a cluster of circles (○) in the middle with crosses (×) scattered around them, and no straight line separates the two.
In the lecture, Lin connects the two facts as cause and effect: because the model's complexity is under control, and do not drift far apart; but for exactly the same reason, there will be data that no line cuts well. Then is large, is close to it and therefore also large, and nothing has been learned. The goal of the lecture is written at the bottom of page 2: how to break the limit of linear hypotheses.
Circular separable
Page 3 draws the same data again, this time with a circle added. The handout says this data is not linear separable but is circular separable: a circle of radius centered at the origin separates it, and the corresponding hypothesis is
is the squared distance from the point to the origin. In the lecture, Lin reads the hypothesis this way: compare that squared distance with 0.6, say circle when it is smaller than 0.6, and say cross when it is larger.
Since circular separable data exists, one direct idea is to redo everything learned so far: a circular PLA, a circular regression, a circular logistic regression. That is the question at the bottom of the page (re-derive Circular-PLA, Circular-Regression, blahblah … all over again?). In the lecture, Lin answers on the students' behalf: that is too hard, since every algorithm would have to be gone through again to find where the line must become a circle. So what comes next is a systematic method that does not require redesigning the algorithms one by one.
Renaming the coefficients and the inputs
Page 4 does only one thing: it gives names. Split into its three terms and write each as "a coefficient times a quantity that depends on the input":
The lecture goes through this one step at a time. The three numbers 0.6, , and determine what the hypothesis does, for example whether it is a circle of radius or of radius ; they play the same role as the weights of a linear hypothesis, so they are called . Previously was paired with , and now it is paired with ; to make that visible, is called and is called , and the constant term gets a by analogy with the old . Once that is written out, the expression differs from the linear world's only in that has become . To keep the new weights from being confused with the original ones, a tilde is placed above them; Lin nicknames it the little earthworm, a reminder that this is the of the Z world. (Lin also says up front that the written form will be , but when speaking it is simpler to just say .)
With the names in place, the same thing can be seen from another angle. Square each of the two components of every point and plot the result on another figure whose coordinates are . The handout writes this operation as
and calls the (nonlinear) feature transform. In the lecture, the left side is called the X world and the right side the Z world. The figure on the right of page 4 is the transformed data: horizontal axis , vertical axis , the circles crowded into the lower left near the origin, the crosses toward the upper right, and a straight line from to separating the two groups. That line is , which is the original circle.
This gives the first conclusion of the lecture:
An addition in this article: the Z-space figure has one feature that is easy to miss. Neither nor can be negative, so whatever the data looks like in X-space, every transformed point lands in the first quadrant (axes included). This will be used shortly.
Does the converse hold: a line in Z-space is not always a circle
The bottom of page 4 leaves a question: vice versa? If the transformed data is linear separable, does that mean the original data can be separated by a circle? Page 5 answers: not necessarily. First write the hypothesis in Z-space in full:
To find out what a given draws in X-space, the method taught in the lecture is to look for "where it switches": the points where the quantity inside the sign equals 0 form the boundary, and the signs of the coefficients then decide which side is the circle side. The handout lists five choices of ; the table below writes out the boundary equation for each (the semi-axis lengths and the "which side is positive" entries in the last column are computed in this article with the same method):
| Boundary (inside of sign equals 0) | What the handout says | Where the output is (circle) | |
|---|---|---|---|
| circle (◦ inside) | Inside the circle. Plug in the origin: | ||
| circle (◦ outside) | Outside the circle. Plug in the origin: | ||
| ellipse | Inside the ellipse. Semi-axis along , semi-axis along | ||
| hyperbola | The region between the two branches, the one containing the origin | ||
| No solution | constant ◦ | Every point |
The first two are the same circle; the only difference is that the whole weight vector is multiplied by , which swaps inside and outside. The third doubles the coefficient of , so the two axes have different lengths, and Lin points out that this is no longer the perfect circle from before but an ellipse. The fourth has one positive and one negative coefficient, which is the hyperbola from high school. The fifth is the most unusual: in the lecture, Lin imagines a student coming back to report that there is no place where the expression equals 0, because plus two quantities that cannot be negative is positive no matter what, so the output is always circle.
An addition in this article: the fifth case is even more direct in the Z-space picture. The whole line lies outside the first quadrant, while all transformed data lies inside it, so the line touches no data and every point is on the same side of it.
So different lines in Z-space can come back to X-space as a circle, an ellipse, a hyperbola, or a constant. The handout's conclusion is
The handout prints the word special in red. In the lecture, Lin explains what is special about them: taking the circle as the example, its center is always at the origin. A circle centered anywhere else has first-order terms once expanded (they come from the shift), and has no or entry, so it cannot be represented. An addition in this article: likewise, without an term there is no way to make a tilted ellipse; every curve this transform can draw is symmetric about both the axis and the axis.
The general quadratic hypothesis set
To get every quadratic curve, the answer in the lecture is to put in every term needed to represent one: all the second-order terms, all the first-order terms, and the constant. Page 6 writes this 'bigger' Z-space as
Now has 6 components. Each perceptron in Z-space corresponds to one quadratic hypothesis in X-space, and the handout defines this hypothesis set as
In words: first send to Z-space with , then let some linear classifier in Z-space decide; collect every built this way and you have . The handout says it can implement all possible quadratic curve boundaries: circle, ellipse, rotated ellipse, hyperbola, parabola, and so on.
The handout's example is a tilted ellipse:
The handout gives only the result, and in the lecture Lin computes the constant term and the two first-order terms aloud. Here is the full expansion. The first square:
The second square:
Add the two and move the 1 from the right side to the left:
Arrange the coefficients in the order of (constant, , , , , ) and you get . The three numbers computed in the lecture are the same: constant term , coefficient of equal to , coefficient of equal to .
Two additions in this article. First, the center of this ellipse is where and , that is, ; plugging it into gives , so these weights output inside the ellipse and outside. To make the inside , multiply the whole vector by . Second, the coefficient 2 of is not 0, which is exactly why the ellipse is tilted and also why cannot produce it.
The handout adds one last line: also includes lines and constants as degenerate cases. The explanation in the lecture is that a line needs only the first three weights: set the weights of the three second-order terms to 0 and what remains, , is the original linear hypothesis; the constant classifiers that always say circle or always say cross are in there too. So the quadratic hypothesis set contains the original linear hypothesis set. This containment becomes the main subject of the last section.
Fun Time: the weights of a parabola
Question (page 7): Using the transform , which of the following weights in the Z-space implements the parabola ?
Answer: 3. Rearrange the equation into and match it against the six positions of : the constant coefficient is , does not appear so it is 0, the coefficient of is 1, the coefficient of is 2, and and are both 0, which gives . The handout's comment is that the question is too simple; the point is that the flexibility to implement arbitrary quadratic curves opens new possibilities for minimizing .
Each of the other options is a different curve (worked out in this article):
- Option 1 is , a straight line. It puts the 2 in the position instead of the position.
- Option 2 is , which rearranges to , a hyperbola.
- Option 4 is , also a parabola, but the square falls on and it opens toward negative , so it is not the one the question asks for.
Check: take the four points , , , and on the parabola; option 3 is the only one whose is 0 at all four.
How to learn a good quadratic curve: transform, run a linear algorithm, plug back in
(Video 00:00–03:56 covers the three steps of the transform, 03:56–05:50 the two choices and Pandora's box, 05:50–08:36 explains that the feature transform is nothing new, and Fun Time follows.)
Trading "find a good quadratic curve" for "find a good line"
The previous section established a correspondence between hypotheses. Page 8 pushes it one step further, with three rows side by side:
| Z-space | X-space | |
|---|---|---|
| perceptrons | quadratic hypotheses | |
| good perceptron | good quadratic hypothesis | |
| separating perceptron | separating quadratic hypothesis |
The first row is the definition. The other two hold because the predictions on the same example are identical on both sides: , so however many examples gets wrong on , gets the same number wrong on , and the two values are equal. In the lecture, Lin says that if "good" is taken to mean the smallest , then finding a separating line in Z-space is the same as finding a separating quadratic curve in X-space.
The handout then organizes the problem into three lines:
- want: get good perceptron in Z-space.
- known: get good perceptron in X-space with data .
- todo: get good perceptron in Z-space with data .
There is no new algorithm in the third line. An algorithm sees only the vectors and labels it is fed; feed it in place of and it looks for a line in Z-space.
The three steps
Page 9 writes the procedure in three steps:
- Transform original data to by .
- Get a good perceptron using and your favorite linear classification algorithm .
- Return .
The same page has four figures arranged in a square. The upper left is the original data in X-space; an arrow to the right labeled leads to the Z-space data in the upper right; an arrow downward labeled leads to the lower-right figure, Z-space with a line drawn and the regions colored; between the lower right and the lower left there are two arrows, one pointing left, labeled and drawn in gray, and one pointing right, labeled ; the lower left is the circular boundary in X-space.
The handout does not explain the gray , and the lecture spends a good while on it. "Moving" the line in Z-space back to X-space to get a curve is only something we imagine; that inverse operation need not exist, because nothing guarantees that the map from to is one-to-one. What is actually done is always the arrow pointing right: take a point anywhere in X-space, send it to Z-space with , see which side of the line it lands on to get red or blue, and paint that color back onto the point in X-space. Do this for every point and the lower-left figure appears. The formula in step 3, , states exactly this order: first , then the inner product, then the sign.
An addition in this article: is itself not one-to-one. and both square to , so one point in Z-space corresponds to several points in X-space, and there is no inverse function. The numerical example below happens to contain such a pair.
Numerical example: seven points, PLA in Z-space
What follows is an example made up for this article, not from the slides; the numbers were verified with Python (pure integer arithmetic). The data is seven points in X-space:
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| 7 |
First confirm that a line cannot do it. Suppose some line classifies all seven points correctly. Points 4 and 5 are negative, so and . Adding the two gives . But point 1 is the origin, and classifying it correctly requires , a contradiction. The reason is plain from the picture: the origin sits exactly midway between the two negative points 4 and 5. So this data is not linear separable, and the guarantee proved in Foundations Lecture 2 that PLA halts does not apply in X-space.
Step 1: transform. Use :
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 | |||
| 7 |
Points 4 and 5 coincide in Z-space, which is the non-one-to-one behavior of mentioned above.
Step 2: run PLA in Z-space. Start from and check the points in the order , starting over after each full pass; a score of exactly 0 counts as a mistake. On each misclassified point, correct with . The table lists only the checks that led to a correction:
| Correction number | Point checked | Score before the correction | after the correction | |
|---|---|---|---|---|
| 1 | point 1 | |||
| 2 | point 4 | |||
| 3 | point 6 | |||
| 4 | point 1 | |||
| 5 | point 2 | |||
| 6 | point 3 | |||
| 7 | point 2 | |||
| 8 | point 3 |
Take correction 2 as an example: at that moment , points 2 and 3 both score 1 and are correct; point 4 scores , so the prediction is while the label is , and therefore . After correction 8, the scores of the seven points are, in order, ; every sign agrees with its label, and PLA halts.
Step 3: return .
The boundary is , a circle centered at the origin with radius , with inside. In Z-space it is the line .
Predicting new points. Follow the direction stressed in the lecture: transform first, then compute the score. For : , score , prediction . For : , score , prediction .
What this result means. Not one line of the PLA code changed; it is just finding a plane over the three-dimensional (or, ignoring , which is always 1, a line in the plane). We did only two extra things: before training, replace each with , and before predicting, replace the new with as well. That is how data that cannot be cut in X-space reaches equal to 0. This example comes back in the next two sections: the way it picked its transform is actually flawed, and the same data under a different transform learns a different curve.
Two choices, and Pandora's box
The title of page 10 writes the method as a single formula: Nonlinear Model via Nonlinear + Linear Models. Two things in the pipeline are yours to decide:
- feature transform : what kind of Z-space to transform into.
- linear model : the handout notes specifically, not just binary classification.
In the lecture, Lin expands on the second point: this lecture uses binary classification for the explanation, but the same method applies to linear regression, logistic regression, and even multiclass classification, because at its core it only moves to another space to do linear learning. In training you go to that space to find a line, and in testing you go to that space as well to read off the prediction.
The handout calls the consequence Pandora's box: you can now freely do quadratic PLA, quadratic regression, cubic regression, all the way to polynomial regression. As Lin puts it in the lecture, PLA, pocket, linear regression, and logistic regression, each paired with a quadratic transform, all become quadratic; making them cubic works too, and the flexibility of the algorithms goes up a great deal at once.
The feature transform is nothing new
The figure on page 11 is about handwritten digits. The upper left shows rows of raw digit images; an arrow to the right labeled leads to a scatter plot with Average Intensity on the horizontal axis and Symmetry on the vertical axis, where the blue circles are the digit 1 and the red crosses are not 1; going down, draws a separating line on that plot; the lower left has a few new digit images, framed in red or blue. The handout's caption is not new, not just polynomial: from raw (pixels) to concrete (intensity, symmetry), with domain knowledge written on the arrow in between.
In the lecture, Lin asks everyone to recall Foundations Lecture 3: features were divided there into concrete features, which have a specific physical meaning, and raw features, as originally collected, and it was said that raw signals can be organized into concrete features. In the digit recognition example the raw data is a grayscale image, that is, a 256-dimensional vector; once it is reduced to two numbers, symmetry and "how many black cells are filled", it becomes a two-dimensional vector, and classification is done in two dimensions. Lin adds that the plot separates 1 from the other digits, which resembles the subproblem for class 1 in the one-versus-all decomposition from the previous lecture. Testing works the same way: for a newly written digit, compute these two features first and then decide whether it is a circle or a cross.
So this has been done before; the difference is where the transform comes from. The polynomial transform mechanically lists every term; symmetry and intensity were picked using a person's understanding of the problem. Both are a , and the latter amounts to doing something nonlinear in pixel space.
At the bottom of the page the handout writes: the force, too good to be true? In the lecture, Lin explains that the force is the one from Star Wars, and that the feature transform is that powerful a force in machine learning, usable for many things. The question that follows is whether it comes at a price.
Fun Time: how many dimensions the quadratic transform of a d-dimensional input has
Question (page 12): Consider the quadratic transform for instead of in . The transform should include all different quadratic, linear, and constant terms formed by . What is the number of dimensions of ?
Answer: 2. The handout's solution counts the three kinds of terms separately:
- Quadratic terms: of them. The count in the lecture goes: pick two different variables out of and multiply them (, ), which gives ways; pick the same variable twice (), which gives ways.
- Linear terms: of them.
- Constant term: 1.
Adding up:
Check with : , exactly the six terms of .
The other options (worked out in this article): option 1, , does not even cover the original linear terms plus the constant. Option 3, , treats and as two different terms, so it counts quadratic terms; at it gives 7, one too many. Option 4, , is 4 at and does not match either.
In the lecture, Lin mentions that might be 10 or might be 100. Plugging into the formula (computed in this article): 66 dimensions at and 5,151 dimensions at . With the quadratic transform alone, the dimension goes from 100 to more than five thousand, and this question is a warm-up for the next section.
What the transform costs: dimension, VC dimension, and no peeking at the data
(Video 00:00–03:51 covers the computation and storage price, 03:51–05:58 the model complexity price, 05:58–08:00 the trade-off between the two questions, 08:00–14:29 the danger of choosing a transform by eye, and Fun Time follows.)
How many dimensions the Q-th order polynomial transform has
Page 13 generalizes from second order to order . The -th order polynomial transform lists every term of degree 0 through :
The handout writes its length as : the 1 is the constant term (matching ), and counts the others. In the lecture, Lin says the 1 is set apart for the same reason is written for linear models; the tilde over again marks a quantity in Z-space. The handout then gives
The handout accounts for this in a single line: it is the # ways of -combination from kinds with repetitions. In the lecture, Lin says this is combinations with repetition from high school counting and asks everyone to look it up. The step is filled in below (an addition in this article).
Every term has the form , where each is a non-negative integer and the total degree satisfies . One tuple corresponds to one term, so what has to be counted is the number of non-negative integer solutions of this inequality. Introduce one more variable , standing for the "unused degree", and the inequality becomes an equation:
This is the same as putting identical balls into boxes. Line up the balls and dividers, positions in all, and choose of them for the dividers: there are ways; choosing the positions for the balls instead writes it as , and the two are equal.
Check with and : , matching the six terms of . The from the previous Fun Time is a special case too, since .
As for : in the lecture, Lin says to treat as a constant (it is fixed once the data is given) and look at the growth as gets large. Write out the binomial coefficient,
The numerator is a product of factors, each of first degree in , so the whole thing is a polynomial of degree in . A few numbers (computed in this article; is in parentheses):
| 3 (2) | 6 (5) | 10 (9) | 21 (20) | 66 (65) | |
| 11 (10) | 66 (65) | 286 (285) | 3,003 (3,002) | 184,756 (184,755) |
The first price: computation and storage
The handout's conclusion on page 13 is that is the efforts needed for computing/storing and ; large means difficult to compute/store.
In the lecture, the "efforts" are broken into several accounts:
- Computing : every example needs its computed from . If has 2 dimensions and has 6, each example costs an effort of 6.
- Computing : whether you use pocket, linear regression, or logistic regression, every update costs at least ; each PLA correction costs that much. Linear regression may be worse, since it has to handle a matrix and invert it.
- Storing : after learning, has to be kept in order to predict, and that takes space too.
Lin's conclusion in the lecture is that the transform is not free: when is large, storing and updating a vector of ten or twenty thousand dimensions, or optimizing in a space that size, can all be hard.
The second price: model complexity
The title of page 14 is Model Complexity Price. Look at the same from another angle:
- The number of free parameters is , which the handout writes as . This uses the rule of thumb from Foundations Lecture 7: is roughly the number of free parameters.
- The handout then gives an inequality that holds for certain, , and its reason takes only two lines. In the handout's words, any inputs not shattered in any inputs not shattered in .
Here are those two lines expanded into a full argument:
- The hypotheses in Z-space are -dimensional perceptrons (plus the constant term). Foundations Lecture 7 proved that the -dimensional perceptron has , so no points in Z-space can be shattered by perceptrons.
- Now pick arbitrary inputs in X-space; their transforms are points in Z-space. By step 1, there must be some assignment of circles and crosses that no can produce on these .
- Every hypothesis in has the form , and its output on is the output of the corresponding perceptron on . So cannot produce that assignment on these either.
- No points in X-space can be shattered, so by definition .
In the lecture, Lin presents step 3 as a proof by contradiction: if the X-space side could shatter, taking those coefficients over to Z-space would shatter there too, which conflicts with a known fact. Lin also notes that the other direction (the lower bound) is harder to prove and is not covered in this course; it is enough to remember the upper bound. An addition in this article on why the reverse direction cannot simply be copied: to prove you would have to find points in X-space that are shattered, but the transformed points can only land in the restricted range and cannot be placed freely. A small example in which the upper bound is not attained: the input is one-dimensional, , , and the upper bound is 3; but is only a one-dimensional perceptron, whose is 2.
One spot to watch for in the video: the sentence that closes this segment sounds as if it says the price is at most . is the "number of points that cannot be shattered" in the argument; the upper bound on is the written in the handout.
The handout's conclusion is large large . As Lin puts it in the lecture, the linear model was getting along fine with only degrees of freedom, and now it has , which climbs quickly with .
The two questions cannot both be satisfied
Page 15 shows two ways of separating the same data. The left figure uses (which is just the original ): a slanted line splits the two groups, with a few circles and crosses on the wrong side. The right figure uses : a winding fourth-order curve classifies every point correctly, . The handout asks which one do you prefer, and comments: is 'visually' preferred; has equal to 0 but is overkill. In the lecture, Lin says most people would pick the left one; the right one forces even the points that look like outliers onto the correct side, which is going too far.
An addition in this article: for a two-dimensional input has weights, while has only 3.
The handout ties this back to the two central questions left by the second question of Foundations:
- Can we make sure that is close enough to ?
- Can we make small enough?
| () | Question 1: | Question 2: small enough |
|---|---|---|
| higher | hard | easy |
| lower | easy | hard |
When is high, there are many hypotheses and the curve can bend, so is easy to make small, but is large and the two errors may be far apart. When is low, it is the other way around. In the lecture, Lin says this is the most important trade-off in machine learning.
The from Foundations Lecture 7 puts numbers on the Question 1 column (computed in this article, with , , and taken at its upper bound):
| Transform (two-dimensional input) | Upper bound on | |
|---|---|---|
| 3 | 0.163 | |
| 6 | 0.225 | |
| 15 | 0.349 | |
| 1,326 | 3.24 |
An error can be at most 1, so an above 1 means the guarantee says nothing. The VC bound itself is very loose and the absolute size of these numbers should not be taken literally; what matters is the direction in which they move as grows.
The danger of choosing a transform by eye
So how should be picked? The bottom of page 15 asks tentatively: visually, maybe? The judgment a moment ago that is better than relied on the eye. The title of page 16 answers directly: Danger of Visual Choices.
The first reason is written at the very top: can you really 'visualize' when ? The handout answers its own question: well, I can't. In the lecture, Lin adds that most data used in practice is high-dimensional, and deciding by sight is not easy.
The second reason is subtler: even in , where you can see, deciding by eye is a problem. The handout takes the circular separable data from the beginning and lists four increasingly "clever" choices:
| Choice | marked in the handout | |
|---|---|---|
| full | 6 | |
| after visualizing | 3 | |
| better? | 2 | |
| even better? | The handout gives no number |
The lecture acts these four steps out as a dialogue. At first you honestly use the six-dimensional transform and pay a price of . After looking at the plot you see there is no need for that much; three dimensions will do, at a price of 3. A cleverer student says: it is a perfect circle anyway, so the squared distance to the origin is all that is needed, and one special polynomial is enough, at a price of 2. Finally the teacher steps in to do the "cleverest" thing: the transform does not have to be a polynomial, so just use the answer itself as the feature; is down to one dimension, with no constant term even, and Lin says it then looks as though the price is only 1.
It sounds like a better and better deal, so where is the catch? The explanation in the lecture: during this process your brain did a round of computation and picked a transform that suits this particular data set. The VC argument originally says that the data is drawn from some distribution, and we work out the probability of drawing bad data that makes learning fail; that argument assumes the hypothesis set is fixed before the data is seen. If you look at the data first and then fix the transform, your brain has already done a round of learning, which Lin calls human learning and says is no longer machine learning. What you hand to the machine has already been shaped by your subjective choice, and the complexity price paid for that choice stays in your head without being counted.
The consequence is overestimation: you will believe you made very low with a very small . As Lin explains it, looks small only because the VC dimension inside your head was left out; and people are clever enough to do many different classification tasks, so the brain's VC dimension is presumably rather large. The outcome Lin gives as an example: the machine appears to do very well, yet when it is used to invest in the stock market, it does badly no matter what.
The handout closes the page with two lines:
careful about your brain's 'model complexity'
for VC-safety, shall be decided without 'peeking' data
An addition in this article: the seven-point example above made exactly this mistake. I first laid out data with "positives inside, negatives outside, and centered at the origin", and then picked , the transform that happens to fit it. On paper that is and , but the 3 does not account for the step of "look at the plot first, then pick the transform". If you do not look at the data beforehand and honestly use the full , the same PLA (same starting point and checking order) halts after 7 corrections at , whose boundary is , an ellipse centered at , also with equal to 0. The two curves agree completely on the seven training points but disagree on unseen ones: plugging into the circle's expression gives , prediction ; plugging it into the ellipse's expression gives , prediction . Seven examples cannot tell which is right, and this is what the price of more degrees of freedom looks like in a small example.
This theme appears once more under the name data snooping in Foundations Lecture 16: Three Learning Principles. After this lecture, whenever you meet a you can ask yourself two things: what is ? Was this decided only after looking at the data?
Fun Time: the dimension when Q = 50
Question (page 17): Consider the -th order polynomial transform for . Recall that . When , what is the value of ?
- 1126
- 1325
- 2651
- 6211
Answer: 2. Substitute directly:
The handout's comment: it's just a simple calculation, but it shows you how becomes hundreds of times of after the transform ().
The other options (worked out in this article): option 3, 2651, comes from forgetting to divide by 2, . Option 1, 1126, and option 4, 6211, cannot be obtained from this formula; as far as this article can tell, 1126 is a number this course is fond of: the in the next section and the experiments "repeated 1126 times" in the later homework both use it.
In the lecture, Lin goes on to ask a practical question: the input was only two-dimensional and is now in a space of over a thousand dimensions, so does your amount of data hold up? In two dimensions twenty points may be enough; in a thousand dimensions twenty points are certainly not, and do you really have ten thousand points? An addition in this article: by the rule of thumb from Foundations Lecture 7, the two-dimensional perceptron with needs about 30 examples; the upper bound on for is 1326, so it needs about 13,000, which matches the order of magnitude mentioned in the lecture.
Which transform to try first: structured hypothesis sets and the linear model first
(Video 00:00–02:20 covers the recursive definition of the polynomial transform and the nested structure, 02:20–04:38 derives the two chains of inequalities for the VC dimension and E_in, 04:38–07:30 covers the linear model first, 07:30–08:02 is Fun Time, followed by the summary and a preview of the next lecture.)
Polynomial transforms nest one inside another
Page 18 rewrites the polynomial transform recursively. The zeroth-order transform has only the constant, and each step up appends all terms of the new degree to the previous transform:
Every transform contains the one before it. In the lecture, Lin explains what this means for the hypothesis sets: when doing linear learning in the larger Z-space, you can always set the weights of the newly added dimensions to 0, and the resulting hypothesis is exactly what the previous transform could do. The statement in the earlier section that "lines are degenerate cases of quadratic hypotheses" rests on the same reason. Abbreviate the hypothesis set of each transform as and you get
The handout draws a set of ellipses, one inside another, with the innermost labeled and then , , going outward, and calls this one-inside-another relationship the structure of the hypothesis sets (structure: nested ).
Two chains of inequalities running in opposite directions
Page 19 lets , the hypothesis with the lowest in , and writes three rows:
The handout gives no reasons for the second and third rows; the lecture explains each in a short passage, summarized here.
The VC dimension does not decrease. means that has every hypothesis of . If some points can be shattered by , each of the assignments is produced by some hypothesis in , and those hypotheses are all in as well, so the same points are shattered by . The number of points that can be shattered can only go up or stay the same.
The lowest E_in does not increase. is itself a member of . is the one with the lowest in , and the list of candidates includes , so . As Lin puts it in the lecture: there are more choices now, and a better one may turn up among the new ones; if not, you do at least as well as before.
Applied to the seven points (computed in this article). Using the earlier data, three positives and four negatives:
| Hypothesis set | What it can do | Lowest | How it is obtained |
|---|---|---|---|
| Constants: guess all or all | Guessing all gets 3 wrong, guessing all gets 4 wrong | ||
| Lines | Shown above that at least 1 is wrong; gets only point 5 wrong | ||
| Quadratic curves | The circle PLA found above | ||
| and beyond | Curves of third order and higher | It is already 0 and cannot go lower |
, in agreement with the third row. Meanwhile the upper bounds on are 1, 3, 6, 10: by there are 10 weights, more than the 7 examples, and yet has not improved at all. Going right from , everything extra you pay is complexity.
The lower half of page 19 is the figure that appeared in Foundations Lecture 7, with on the horizontal axis: the in-sample error curve goes down all the way, the model complexity curve goes up all the way, and the out-of-sample error curve falls and then rises, with the horizontal coordinate of its lowest point marked . The nested hypothesis sets, laid out from left to right, correspond exactly to the horizontal axis of this figure. Next to it the handout writes: use won't be good. The explanation in the lecture is that if you start out with a transform of order as high as 1126, you are already standing very far to the right on the curve; may be very low, but you have paid a large model complexity and will be very high.
One number added in this article: for on a two-dimensional input, .
Linear model first
Page 20 writes the advice as two routes.
Tempting sin: use directly, and take the low to fool your boss. The handout's comment is really? a dangerous path of no return. In the lecture, Lin says people who have just met the feature transform are especially prone to this: the data is all in your hands, you apply a high-dimensional transform, push down to 0, and go tell your boss it went very well, and a boss who is not paying close attention is fooled. But was never what we care about; it is only an intermediate product. Lin describes the path of no return this way: once is good and is very high, there is almost nothing left to do to fix it.
Safe route: first.
- If is good enough, the matter is settled (the handout writes live happily thereafter). is small, is close to , so is good too.
- Otherwise, move right of the curve, with nothing lost except 'wasted' computation.
The handout's closing line is linear model first: simple, efficient, safe, and workable. In the lecture, Lin goes through the four adjectives one by one: simple; efficient, because the dimension is small; safe; and the last is that quite often you will be surprised to find it does rather well. Lin makes a point of warning against assuming that a linear model must do badly; in many cases linear is a fairly good approximation for describing the world.
Fun Time: VC dimensions of nested sets
Question (page 21): Consider two hypothesis sets, and , where . Which of the following relationship between and is not possible?
Answer: 4. The handout's solution: every input combination that shatters can be shattered by , so cannot decrease. This is the reason behind the chain of "" above.
The other three options can all happen (an addition in this article). The question gives only the containment and does not say the two sets come from polynomial transforms, so what it asks is: in general, when a small set sits inside a large one, what can happen?
- Option 3 (less than) and option 2 (not equal) are the common situation. For example, on a two-dimensional input lines have and quadratic curves have (the number on page 16 of the handout).
- Option 1 (equal) is possible too. The hypotheses the large set has beyond the small one do not necessarily help with shattering. One example: the one-dimensional positive ray has ; add the single hypothesis "always output " and the set is larger, but the assignment "left , right " on two points still cannot be produced, and is still 1.
One spot to watch for in the video: the answer number spoken aloud in the lecture sounds like 3, but the explanation that immediately follows is that the greater-than case cannot happen, which is option 4 on the handout. Go by the handout's reference answer, 4.
Summary of the lecture
Page 22 wraps each of the four sections into one line:
| Section | The handout's one line |
|---|---|
| Quadratic Hypotheses | linear hypotheses on quadratic-transformed data |
| Nonlinear Transform | happy linear modeling after |
| Price of Nonlinear Transform | computation/storage/[model complexity] |
| Structured Hypothesis Sets | linear/simpler model first |
In the third line model complexity is set in square brackets. Lin's summary in the lecture likewise says that the most important price is the one paid in model complexity.
The preview at the bottom of the page is next: dark side of the force. In the lecture, Lin says the feature transform is the force and that this lecture has already touched some of its dark side; the next lecture takes on directly what harm it does to machine learning, and after that comes how to control it. On the Roadmap, the next lecture begins the fourth question, How Can Machines Learn Better?.
Self-check
1. Using , write a whose boundary is the circle with center and radius 2, with output inside the circle. Why can not produce this circle?
Answer: the inside is positive, so take . Expand: , so (multiplying by a positive number is also correct). Check: the center scores ; the point on the circle gives . The expansion has the two first-order terms and , and has no positions for them.
2. The input is 10-dimensional. What is for the polynomial transforms with , , and ? Using the rule of thumb with taken at its upper bound , roughly how many examples does each need?
Answer: , which is , , and respectively, so , , and . The amounts of data are about 660, 2,860, and 30,030 examples. Raising the order from 2 to 5 multiplies the data needed by about 45.
3. Five one-dimensional examples: , with labels in that order. Find and , and find a hypothesis in with ().
Answer: can only guess one label for everything; guessing all gets 2 wrong, so . is the one-dimensional perceptron : lies exactly midway between the two negative points , and just as in the seven-point example, adding gives , which contradicts having to be positive, so at least 1 is wrong; gets only wrong, so . : take , that is, ; the five scores are , all correct. .
4. A colleague gets a two-dimensional data set, draws a scatter plot first, sees that the positive points form a ring-shaped cluster with the negative points outside it, and therefore trains with only , gets , and writes in the report that "the model's VC dimension is only 2, so generalization is guaranteed". What is wrong with this claim? What would make it defensible?
Criteria: the answer must point out that the transform was chosen after looking at the data, and that the selection process (picking this one out of all possible transforms) has a complexity of its own that is not counted in that 2, so the VC guarantee does not apply and the conclusion is too optimistic. A defensible approach is to decide the transform before looking at the data (for example, agree beforehand to use and accept the price of ), or to set aside a separate portion of data that took part in no decision and evaluate on it. Answering only "the VC dimension is computed wrong" without saying that the price is hidden in the human's choice is not complete.
5. Which known result does the proof of use? Why does the same argument not give directly?
Criteria: the answer must name "the -dimensional perceptron cannot shatter a set of points, whichever points they are" and "the output of on equals the output of the perceptron on ", so an assignment that cannot be produced in Z-space cannot be produced in X-space either. The reverse direction needs points in X-space that are shattered, but their transforms can only land on and cannot be placed freely; the set of points behind the perceptron's "there exist some points that can be shattered" in Z-space need not be the transforms of some .
Exercises and corresponding reading
Corresponding weeks in the two semesters. The Fall 2024 course page puts Foundations Lectures 11 and 12 in the same week (W6, 10/07), and the slides for this lecture are 12u_handout.pdf. The Fall 2026 course page schedules it in W6 (10/14); when checked on 2026-09-30, the slide link for that week still returned 404, so this article uses only the MOOC handout.
Textbook. Both course pages map this lecture to Section 3.4 of Learning from Data (LFD).
Homework. The related problems are in Fall 2024 HW4 (released 2024-10-21, due 11-04, 12 problems plus 1 bonus), which has no official solutions:
| Problem | Content | Where it connects to this lecture |
|---|---|---|
| Q4 | Run linear regression after the "Dr. Transformer" transform, which one-hot encodes every training example; the problem prompts you to think about | The price of the transform: a very low does not mean anything was learned |
| Q11–12 | Apply the homogeneous polynomial transform with to the cpusmall_scale data and look at the gain in and the change in | The trade-off between the two questions, structured hypothesis sets |
| Q13 (bonus) | A hypothesis set in multiplicative form; prove or disprove that its is larger than that of linear hypotheses | Transforms and |
The cpusmall_scale data used in the programming problems comes from the public LIBSVM datasets page, and each experiment has to be repeated 1126 times with different random seeds. Q11 can be self-checked this way: the difference in cannot be negative by definition, because the linear hypotheses are contained in the transformed hypothesis set (the same reasoning as this lecture's chain of inequalities for ); a negative value means the implementation has a bug. The guide to the whole assignment is in Foundations Homework.
Further reading.
- The trade-off between feature transforms and regularization, as another course tells it: CMU 07-280 Lecture 10: Trading Expressiveness for Stability with Features and Regularization.
- Techniques hands the problem that "a large dimension has a price" to SVM and kernels: Techniques Lecture 1: Linear SVM and Techniques Lecture 3: Kernel SVM.
Next lecture. Foundations Lecture 13: Hazard of Overfitting continues with the dark side of the force: what exactly happens when the transform is too powerful and is very low while is very high.
Course video sources
Original videos: Quadratic Hypotheses, Nonlinear Transform, Price of Nonlinear Transform, Structured Hypothesis Sets
Checked: 2026-10-13. The video IDs, titles, and lengths were taken from the official playlist that day; the videos have no caption track on YouTube, and what this article reports from the lecture comes from transcripts made for it.
Update Log
- 2026-10-13: Changed to one article per lecture, rewritten from the handout and the video transcripts.
References
- Foundations Lecture 12 handout, 12_handout.pdf: the main source for this article. The content of the four sections, the four Fun Time questions, and the figures on each page all come from this handout.
- Foundations Lecture 7 handout, 07_handout.pdf: the VC dimension of the -dimensional perceptron, the formula for , and the rule of thumb , used in the calculations of the model complexity section.
- Foundations Lecture 3 handout, 03_handout.pdf: the distinction between concrete features and raw features, and the grayscale image example.
- Machine Learning Foundations YouTube playlist: the IDs and titles of the four videos; what the text reports as said "in the lecture" is paraphrased from machine transcripts of these four videos.
- Hsuan-Tien Lin > MOOCs: the official entry for handouts and recordings.
- Machine Learning, Fall 2024 course page: the W6 schedule, the 12u slides, and the LFD section.
- Machine Learning, Fall 2026 course page: the W6 (10/14) schedule.
- Fall 2024 Homework 4 (hw4_red.pdf): the content of Q4, Q11–12, and Q13, and the release and due dates.
- LIBSVM datasets: cpusmall_scale: the data for the HW4 programming problems.
- Learning from Data textbook website: the source for Section 3.4.
- Reading NTU Hsuan-Tien Lin Machine Learning Foundations & Techniques: Course Overview: where this lecture sits in the whole course and the reading routes.
Loading...