🌏 中文版
Video status: Videos included. This article is written from the official MOOC handout 201_handout.pdf and transcripts of the five official videos for this lecture, 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/28 to 28/28), and wherever the text says "in the lecture" it is paraphrasing what is said in the video.
This is Techniques Lecture 1 in Reading NTU Hsuan-Tien Lin Machine Learning Foundations & Techniques, following Foundations Lecture 16: Three Learning Principles. The Roadmap on page 4 of the handout divides Techniques into three ways of handling features, and this lecture is the starting point of the first, Embedding Numerous Features: Kernel Models. The question it answers is concrete: when the data are linearly separable, many lines classify all of them correctly, so which one should you choose, and how do you compute it?
The prerequisites are a few things from Foundations: the linear classifier and PLA (Foundations Lecture 2), dichotomies and shattering (Foundations Lecture 5), the VC dimension (Foundations Lecture 7), feature transforms (Foundations Lecture 12), and regularization (Foundations Lecture 14), plus vector inner products and projection. After reading, you should be able to get from "find the fattest line" to the standard hard-margin SVM problem on your own, compute the fattest line by hand for a small data set, fill the problem into the four inputs of a quadratic programming solver, and say why a fat line helps generalization.
The derivation in this lecture runs in this order:
- The question: all the data are classified correctly, so which line is better? The one farthest from its nearest data point.
- Write it as an optimization problem: maximize the margin, subject to classifying every point correctly.
- Compute the distance: take the intercept out of and derive the distance from a point to a hyperplane.
- Fix the scaling: look only at the ways of writing the line in which the nearest point gives exactly ; the margin becomes .
- Relax the constraint: replace "the smallest equals 1" with "every one is at least 1" and prove the answer does not change.
- Hand it to quadratic programming: the objective is a quadratic function and the constraints are linear.
- Go back and ask why: two explanations, regularization and the VC dimension.
How this course is organized: three techniques surrounding feature transforms
(Video 00:18–03:00 introduces the course, and Fun Time follows.)
Page 1 of the handout gives the history of the course. Lin's machine learning course at NTU is a 15 to 17 week on-campus course, taught in English on a blackboard. When it moved to Coursera it was cut into two courses: the first 8 weeks are Machine Learning Foundations, and the last 8 weeks are this course, Machine Learning Techniques. The online version switched to Mandarin and to slides, and works with Coursera's quiz and homework mechanisms; the goal written on the handout is to make the online version even better than the on-campus one.
Foundations ties its 16 lectures together with four questions: when can machines learn (When), why can they learn (Why), how do they learn (How), and how can they learn better (How Better). The lectures each part covers are listed in the Course Overview. Techniques is organized differently. Page 2 of the handout says this course is again a mixture of philosophical illustrations, key theory, core algorithms, and usage in practice, but the backbone is now three major techniques surrounding feature transforms:
| Technique | The question on the handout | The model it inspires | Lectures |
|---|---|---|---|
| Embedding Numerous Features | how to exploit and regularize numerous features? | Support Vector Machine (SVM) | Techniques Lectures 1–6 |
| Combining Predictive Features | how to construct and blend predictive features? | Adaptive Boosting (AdaBoost) | Techniques Lectures 7–11 |
| Distilling Implicit Features | how to identify and learn implicit features? | Deep Learning | Techniques Lectures 12–15 |
The lecture ranges in the table follow the split in the overview and are not on this slide. In the lecture, Lin adds one sentence about each technique. The first: when you use a lot of feature transforms, complexity becomes a problem and has to be kept under control; the handout writes regularize and the lecture says controlling complexity, and the two refer to the same thing. The second: blend the features you have found so that the whole model performs better; the lecture also gives AdaBoost a Chinese name that means roughly "step-by-step boosting method". The third: the lecture switches to a plain way of putting it, which is letting the machine learn the features by itself; this idea led to neural networks early on and has grown into deep learning in recent years.
The first technique picks up a problem Foundations left behind. The feature transform in Foundations Lecture 12 can draw curved boundaries, but that lecture also lists the price: once the transformed dimension is high, computation and storage both get expensive, and grows with it. The weight decay in Foundations Lecture 14 keeps complexity down by constraining the length of . What the first few Techniques lectures do is let you afford high-dimensional transforms without paying those two prices in full. This lecture does no transform yet and handles only linear classification in the original space, which is why it is called linear SVM.
Fun Time: which description of this course is true
Question (handout page 3): Which of the following description of this course is true?
- the course will be taught in Taiwanese
- the course will tell me the techniques that create the android Lieutenant Commander Data in Star Trek
- the course will be 16 weeks long
- the course will focus on three major techniques
Answer: 4. Reading the question aloud in the lecture, Lin describes Data as a robot in that TV series. The handout's reference answer replies to each option in one line. Option 1: no, Lin's Taiwanese is unfortunately not good enough for teaching (yet). Option 2: no, although what the course teaches may serve as building blocks. Option 3: no, unless you count the previous course, Foundations, as well; 8 weeks plus 8 weeks is what makes 16. Option 4 is the table above.
All correct, so which line is better: the fattest separating hyperplane
(Video 00:00–01:11 reviews linear classification, 01:11–03:21 asks which line is best, 03:21–08:04 explains with measurement error, 08:04–09:41 turns "robust" into "fat", 09:41–13:11 writes the optimization problem, and Fun Time follows.)
Neither PLA nor the VC bound can tell them apart
Page 5 of the handout first reviews linear classification: compute a weighted score and look at its sign, . When the data are linear separable, PLA can find a line that completely separates the circles (positive examples) from the crosses (negative examples).
Page 6 shows three pictures. All three contain the same data, each with a different line, and all three lines classify the data perfectly. The handout asks: which line is best?
- Ask PLA: the handout's answer is depending on randomness. In the lecture, Lin explains that PLA holds a line and rotates it a little whenever it sees a mistake, so which perfect line it stops on depends on the mistakes it saw along the way; if it picks a random mistake to fix each time, where it stops is not fixed.
- Ask the VC bound: the handout's answer is whichever you like. The VC bound says
All three lines have equal to 0, and they all come from the same hypothesis set (linear classifiers in dimensions, ), so the complexity term is identical. By the theory learned in Foundations, the three lines are no different.
Yet most people would pick the rightmost line by intuition. The handout writes "You? rightmost one, possibly :-)". In the rightmost picture the line is farther from the points on both sides.
Why the line farthest from the points: tolerating measurement error
Page 7 gives an argument the handout itself labels as an informal argument. In the lecture, Lin first says this is only a simple explanation and that a more careful theoretical guarantee comes later.
Imagine the training data are and a future test input is very close to some , . The reason given in the lecture is measurement error, or error in the data collection process: even data that should be exactly identical come in slightly different. The handout writes "(Gaussian-like) noise"; the lecture does not mention Gaussian and only says measurement error. If we trust the training data, the most reasonable prediction gives this the same label as .
The picture on page 7 draws a gray circle around every training point, standing for how much error the line can still tolerate. Within one picture every point's circle is the same size, and the radius is the distance from the nearest point to the line: make the circles any bigger and the nearest point's circle crosses the line. In the left picture one point sits right next to the line, so every circle is too small to see; in the right picture even the nearest point is far from the line, so every point's circle is large. The handout writes this observation as two chains of equivalences:
| From the point's side | From the line's side |
|---|---|
| further from hyperplane | distance to closest |
| ⟺ tolerate more noise | ⟺ amount of noise tolerance |
| ⟺ more robust to overfitting | ⟺ robustness of hyperplane |
The lecture connects this back to something from Foundations (Foundations Lecture 13: Hazard of Overfitting): noise is the main cause of overfitting, and measurement error is a kind of noise, so the more error a line can tolerate, the better it is. How robust a line is comes down to how far it is from its nearest training point.
From robust to fat
Page 8 draws the same thing from another angle. Instead of drawing circles around the points, let the line itself grow outward on both sides: how fat it can get depends on where it first touches the nearest point. In the picture each of the three lines grows into a gray band, thin on the left and wide on the right. The handout's definitions are:
- a robust separating hyperplane is a fat one, far from both sides of examples;
- robustness is equivalent to fatness, the distance to the closest .
The goal then fits on one line: find fattest separating hyperplane. In the lecture, Lin says this lecture prefers fatter lines, like someone with a steadier stance, and even jokes about Yang Guifei: fatter is better.
Writing it as an optimization problem
Page 9 writes the goal as a formula. Each line is determined by , and the we want satisfies two things: it classifies all the data correctly, and it is the fattest.
Fatness is computed like this: find the distance from the line to every point and take the smallest. In the lecture, Lin stresses that this problem is only simple to state in words, which does not make it easy to solve; the work ahead is to rewrite it step by step into a form we know how to solve.
The handout then changes two pieces of wording. First, the formal name of fatness is margin. Lin's explanation in the lecture is that a margin is like the blank space at the edge of a page: a blank strip is left on both sides of the line, no training data appear in that strip, and the wider the blank space, the fatter the line. Second, "correct" can be written as an inequality. means the score has the same sign as , and the product of two numbers with the same sign is always positive:
This is the largest-margin separating hyperplane: separating means it splits the data completely, and largest-margin means its margin is the largest. For now we assume the data are linearly separable; otherwise no can satisfy the first constraint. The distance in the formula is still only a name, and how to compute it is left to the section "Turning 'fattest' into a solvable problem".
Fun Time: the fattest separating line for two points
Question (handout page 10): Consider two examples and where (without padding the ). Which of the following hyperplane is the largest-margin separating one for the two examples? The handout suggests visualizing with .
Answer: 3. The handout's reason: the largest-margin separating line must be a perpendicular bisector of the line segment between and , hence is a normal vector of that line; the result extends to .
The handout does not say why it must be the perpendicular bisector, so this article fills that in. Any line that separates the two points has to pass between them. The two points' distances to the line add up to the length of the projection of the segment between them onto the normal direction, which cannot exceed the distance between the two points, . The smaller of the two distances is the margin, so the margin is at most . To equal exactly, the line must be perpendicular to the segment (so the projection does not shrink) and pass through the midpoint (so both sides are equally far). The midpoint of these two points is the origin, and the line through the origin perpendicular to is .
Check the four options with (the distance formula is derived in the section "Turning 'fattest' into a solvable problem"; it is used here ahead of time):
| Option | Line | Distance from to the line |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 |
All four lines pass through the origin, and is as far from each line as is, so the numbers in the table are the margins. For this all four lines separate the two points, and the fattest is option 3, whose margin is exactly . Options 1 and 2 look at only one coordinate; change to and option 1's line lies right on top of both points and cannot separate them at all. Option 4 swaps the two components of , and the resulting normal vector is in general not in the direction of .
Turning "fattest" into a solvable problem: distance, scaling, and the standard problem
(Video 00:00–02:51 takes the intercept out, 02:51–07:00 derives the distance formula, 07:00–08:55 covers the distance to a separating hyperplane, 08:55–11:51 fixes the scaling, 11:51–16:44 relaxes the constraint, 16:44–18:38 does the final cleanup, and Fun Time follows.)
First take the intercept out of w
Foundations always pads with an so that the intercept becomes and everything can be written as a single inner product. In the lecture, Lin compares that to a shoe lift tucked underneath. Page 11 of the handout says that when computing distance, and play different roles (the reason only shows once the formula is derived), so from here on the two are separated:
is the bias, that is, the intercept. and each have one component fewer than before; the handout says to shorten them, and the lecture says they got a little shorter in height. The hypotheses in this lecture and the next few are all written as
Distance from a point to a hyperplane
Page 12 computes : the distance from a point to the hyperplane . The derivation has three steps.
Step 1: what points on the hyperplane satisfy. Take any two points and on the hyperplane. Both satisfy the hyperplane's equation, and rearranging gives
Step 2: w is perpendicular to the hyperplane. Subtract the two equations:
is the vector from one point on the hyperplane to another, so it lies entirely on the hyperplane. and were chosen arbitrarily, so the inner product of with every vector on the hyperplane is 0; that is, is perpendicular to the hyperplane and is its normal vector. In the lecture, Lin remarks that once you have the normal vector, things get easy.
Step 3: projection. The distance from the point to the hyperplane is the length you get after taking the vector from any point on the hyperplane to and projecting it onto the direction perpendicular to the hyperplane. The perpendicular direction is ; projecting onto a direction means taking the inner product with the unit vector in that direction, , and then the absolute value:
The last equality uses from step 1. There is no in the result, so it does not matter which point on the hyperplane you pick.
The formula reads: compute the original score , take its absolute value, and divide by the length of . The denominator has only and no . In the lecture, Lin points out that this is the reason for separating from : the distance needs only the length of , not the size of ; if were still packed inside , the length would come out wrong.
A separating hyperplane lets you drop the absolute value
We only care about hyperplanes that classify the data correctly. Page 13 uses this property to remove the absolute value. A separating hyperplane has, for every ,
is or and has the same sign as the score, so times the score is exactly the absolute value of the score:
Substitute it back into the optimization problem and distance is no longer just a name:
At this point in the lecture Lin asks: can we solve it now? Apparently not yet; it needs more simplifying.
Fixing the scaling: make the nearest point equal exactly 1
The observation on page 14 is that the same hyperplane can be written in many ways. and are the same hyperplane; the handout writes scaling does not matter. In the lecture, Lin puts it this way: there are not really that many lines in the world, the pairs are all over the place, and many of them are just the same line scaled up or down. Since scaling does not change the line, pick the scaling that makes the formulas easiest to write: consider only the that satisfy
An addition in this article: why this choice does not leave out any line. For any that separates the data, is a positive number. Divide both and by : the hyperplane is unchanged, and the new minimum is . So every separating hyperplane has exactly one way of being written that fits this scaling.
Under this scaling the margin formula becomes very simple. does not depend on , so it can be pulled outside the min:
There is a side benefit too. If the smallest one equals 1, every is certainly greater than 0, so the original "correct" constraint no longer needs to be written; in the lecture, Lin says writing it would be pointless. The problem becomes
Relaxing the constraint: from "the smallest equals 1" to "every one is at least 1"
The constraint still contains a min. In the lecture, Lin says maximizing on the outside is annoying enough, and now a minimization pops up inside, which is hard to handle. Page 15 relaxes the constraint to a necessary condition of it:
If the smallest equals 1, every one is certainly at least 1, so any that was feasible before is still feasible under the new constraint. The converse does not always hold: every one being at least 1 does not guarantee that some one equals exactly 1. In the lecture, Lin says this is a necessary condition but not a sufficient one, and illustrates it with a sketch: the original constraint encloses a small region, and after relaxing we get a large region that contains it. Relax a constraint carelessly and the optimal solution may move outside the small region, which changes the answer. What has to be proved is that the optimal solution found in the large region still lies in the small region.
The handout argues by contradiction. Suppose the optimal solution of the relaxed problem lies outside the small region, that is, every point is strictly greater than 1. The number the handout uses is
Then divide both and by 1.126 and look at the new pair :
- It is still feasible: .
- Its objective value is larger: got shorter, and .
We have found a feasible solution that is better, which contradicts " is optimal". There is nothing special about 1.126; the argument is the same for any number greater than 1. So the optimal solution of the relaxed problem must have some point that equals exactly 1, and it lies in the small region. Every solution in the small region is also in the large region, and since the champion of the large region lies in the small region, it is the champion of the small region as well. Relaxing did not change the answer.
Final cleanup: max becomes min
At the end of page 15 come three adjustments that do not change the optimal solution, which the handout writes on one line as "max ⟹ min, remove √, add ½":
- Maximizing becomes minimizing . The larger a positive number is, the smaller its reciprocal. The reason given in the lecture is that the gradient descent in Foundations was always about minimizing, so switching to minimization is closer to the familiar form.
- Remove the square root. , and minimizing the length is the same as minimizing the squared length, so minimize instead.
- Multiply by in front. Minimizing a quantity and minimizing half of it have the same optimal solution. The lecture only says the reason will show up later. An addition in this article: when Techniques Lecture 2 takes the partial derivative with respect to , this cancels the 2 that comes from differentiating the square; it also matches the in the standard form of QP.
The result is what the handout calls the standard problem:
The that solves this problem is the fattest separating hyperplane, and its margin is . The summary on page 28 of the handout wraps this section up in one phrase: minimize 'length of w' at special separating scale.
Fun Time: three points and a given line
Question (handout page 16): Consider three examples , , , where , , . In addition, consider a hyperplane . Which of the following is not true?
- the hyperplane is a separating one for the three examples
- the distance from the hyperplane to is
- the distance from the hyperplane to is
- the example that is closest to the hyperplane is
Answer: 2. Write the hyperplane as , , with . Point by point:
| Point | Score | score | Distance | |
|---|---|---|---|---|
The fourth column is all positive, so all three are classified correctly and option 1 is true. The distance of is , and it is the smallest of the three, so options 3 and 4 are true. The distance of is ; option 2 writes 2, which forgets to divide by and takes the score itself as the distance. The handout's reference answer lists only the computation , and the lecture likewise only says the distance should be rather than 2; "forgot to divide by the length" is this article's reading of the wrong option.
An addition in this article: this line classifies the data correctly, but it is not the fattest. Its margin is . Solve the standard problem for these three points: the constraints are , , and . Adding the first and the third gives , and adding the second and the third gives , so . Taking , makes all three equal exactly 1, so it is the optimal solution, and the margin is . The fattest line is , and all three points are at distance 1.2 from it.
Four points by hand, then over to quadratic programming
(Video 00:00–03:53 solves four points by hand, 03:53–06:10 covers support vectors, 06:10–07:53 covers quadratic programming, 07:53–13:59 maps to the solver's inputs, 13:59–14:58 wraps it into an algorithm, and Fun Time follows.)
Numerical example: the handout's four points
Page 17 of the handout solves the standard problem from start to finish on a small data set. The data are four points in two dimensions:
| 1 | ||
| 2 | ||
| 3 | ||
| 4 |
Step 1: one constraint per point. Substitute each point into :
Step 2: add constraints in pairs to eliminate b. The left sides of (i) and (iii) add up to and the right sides add up to 2, so . Adding (ii) and (iii) cancels both and , leaving , so . In the lecture, Lin calls these two necessary conditions: if all four original constraints hold, these two must hold.
Step 3: get a lower bound on the objective. means ; means . So
No feasible solution has an objective value below 1.
Step 4: find a feasible solution that reaches the lower bound exactly. For the objective value to equal 1, the only choice is , . Substitute them back into the four constraints to see the range of : (i) requires ; (ii) is , again ; (iii) is , requiring ; (iv) is , requiring . The only value for which all four hold is . The handout writes only the conclusion " at lower bound and satisfies (i)–(iv)"; the ranges of in between are filled in by this article.
The objective value reaches the lower bound and all four constraints are satisfied, so this is the optimal solution. The classifier is
What this result means. Page 18 computes the margin:
Checking point by point, the first three points have equal to exactly 1 and are at distance 0.707 from the line; point 4 gives , at distance 1.414. The line grows 0.707 on each side and just touches the first three points.
This article compares it with two more lines that also classify the four points correctly; the numbers are computed for this article and are not on the handout:
| Line | , | for the four points | margin | |
|---|---|---|---|---|
| , | ||||
| , | ||||
| , |
All three are written so that the minimum is 1, matching the scaling chosen earlier, so can be compared directly: the smaller, the fatter. The last two lines are feasible, but their objective value is 2.5 and their margin is only 0.447.
The benefit of fatness also shows up on this data set. Suppose a test point arrives. It is only 0.6 away from the training point , so by "very close means the same class" it should be a positive example. The fattest line gives it the score and calls it positive. The second line gives and calls it negative. An error of 0.6 is smaller than 0.707 and larger than 0.447, so the former holds up and the latter does not.
Support vectors: only the points on the boundary decide the line
In the picture on page 18, the three points , , and are boxed; they sit exactly on the edge of the gray fat boundary. is not boxed. The handout's observations are:
- examples on the boundary "locate" the fattest hyperplane;
- the other examples are not needed.
In the lecture, Lin explains that if you erase the points that are farther away, pretend you never saw them, and look for the fattest line again with the remaining points, you find the same line. This article checks that: after removing , constraint (iv) is gone, none of the four steps above needs changing, and the answer is still . Conversely, remove the boundary point : constraint (ii) disappears, the requirement disappears with it, and the optimal solution becomes , , the line , with margin 1. Move a point on the boundary and the line moves with it.
The handout calls a boundary example a support vector, followed in small print by "(candidate)". The explanation in the lecture is that these points hold up that fat hyperplane; for now they are only candidates for support vectors, and a precise definition comes later. That definition is in Techniques Lecture 2. This is where the name SVM comes from:
support vector machine (SVM): learn fattest hyperplanes (with help of support vectors)
The general case: this is a quadratic programming problem
Four points can be forced through by hand, but that stops working once there is more data. Page 19 lists two roads that do not work: doing it manually is not easy, of course; gradient descent is not easy either, because of the constraints. In the lecture, Lin puts it this way: now you cannot roll freely down into the valley, because some places are off limits.
The good news is that this problem has two properties:
- the objective function is a convex quadratic function of ;
- the constraints are linear in .
An optimization problem with these two properties is called quadratic programming (QP). In the lecture, Lin says you can think of it as the advanced version of linear programming; people who study numerical optimization understand it thoroughly, and ready-made tools exist. The handout says QP is an "easy" optimization problem. The remaining work is to write SVM in the standard form of QP and hand the coefficients to a tool.
Mapping to the four inputs of a QP solver
Page 20 puts the two problems side by side. The QP solver solves
is the variable to solve for; holds the coefficients of the quadratic terms and the coefficients of the linear terms; each constraint has a set of coefficients and a constant , and stacking all the gives the matrix while stacking all the gives the vector . Match them item by item:
Variables. We solve for and , all packed into , with components in total:
Quadratic term. The objective function is , which contains only and no . In the lecture, Lin explains that we do not care about the part involving , and not caring means a coefficient of 0; is multiplied by itself, so the corresponding block is the identity matrix:
Check: .
Linear term. The objective function has no linear term in or , so .
Constraints. SVM has of them, so . The constants on the right are all 1, so . The left side has to be written as the inner product of some vector with . Expand into : what multiplies is , and what multiplies is . So
The first entry is , and the next entries are .
With the mapping done, Lin says in the lecture that only one step is left: call the solver. The box on the handout reads: SVM with general QP solver: easy if you've read the manual. The lecture mentions that Matlab and plenty of other software come with a built-in QP tool, but you have to read the manual yourself for the details, the way you read the instructions for a new household appliance: the constraints here are written with "≥", some tools want you to feed them the "≤" form, and then the coefficients have to change sign; when there are equality constraints or other kinds of constraints, they may also have to be fed in some other way.
The Linear Hard-Margin SVM Algorithm
Page 21 wraps the procedure into three steps:
- Compute , , , .
- Call .
- Return and as .
Each of the two adjectives in the name means something. Hard-margin: the handout writes nothing violate 'fat boundary', meaning no point may violate the fat boundary; in the lecture, Lin says this means insisting that circles and crosses be completely separated, with no mistake allowed. When the data are not linearly separable this QP has no feasible solution, and relaxing this requirement is the job of Techniques Lecture 4: Soft-Margin SVM. Linear: it uses the original and looks for a hyperplane in the space.
What if you want a non-linear boundary? The handout's hint is "—remember? :-)". Following Foundations Lecture 12, first transform into , then run the same algorithm on .
Fun Time: the a to feed the solver for the four points
Question (handout page 22): Use the four points from page 17 again: two negative examples with and ; two positive examples with and . Define , , , as those listed on page 20. What are the that need to be fed into the QP solver?
- , , ,
- , , ,
- , , ,
- , , ,
Answer: 4. The handout's reference answer is one line: . Following it:
Each row times is one of the constraints (i) to (iv) above; the second row, for example, is . Substitute the hand-computed optimal solution and the four rows give , all at least 1; , which agrees with the objective value computed by hand. This article also handed this , , , to a numerical optimization program, which likewise returned .
Each of the other options is wrong in one place. Option 3 is , which forgets to multiply by . Option 1 is : the first entry is everywhere and the rest is not multiplied by . Option 2 is : the part is right, but the sign of the coefficient of is flipped.
Why fatness helps: two explanations, regularization and the VC dimension
(Video 00:00–02:08 looks at it through regularization, 02:08–05:29 shows that a large margin restricts dichotomies, 05:29–09:26 covers the VC dimension of an algorithm, 09:26–11:10 pairs it with feature transforms, 11:10–11:55 is Fun Time, and the summary follows.)
The formulas in this section are written with (handout page 23), a reminder that the method works just the same in the transformed space. Measurement error was used earlier to explain why to be fat, and that was an intuitive account. This section adds two explanations that connect to the theory in Foundations.
Explanation one: SVM is weight decay within E_in equal to 0
Put the regularization of Foundations Lecture 14 next to the standard SVM problem (page 23):
| minimize | constraint | |
|---|---|---|
| regularization | ||
| SVM | [and more] |
Regularization wants to push down but fears overfitting, so it constrains the length of and allows only the in a small region. SVM swaps the two roles: what it minimizes is the length of , and the constraint is classifying all the data correctly. In the lecture, Lin says the two are doing two sides of the same thing: the object being minimized and the constraint trade places, but both try to take care of these two concerns at once.
The "and more" in the table means SVM's constraint is stricter than . Classifying correctly only needs , and SVM requires . The handout's conclusion: SVM (large-margin hyperplane) is weight-decay regularization within .
Explanation two: insisting on fatness leaves fewer dichotomies
The second explanation goes back to VC theory. Foundations Lecture 5 uses dichotomies to count the complexity of a hypothesis set: given points, how many different circle-and-cross patterns can be produced. Being able to produce all is called shattering.
Page 24 defines a "large-margin algorithm" : if a separating hyperplane with margin at least exists, return it; otherwise return 0, that is, give no answer. The lecture's analogy is looking for a partner: this algorithm likes them as fat as possible; if the data offer one that is fat enough, it picks that one, and if none is fat enough, it would rather stay single for life.
- : does not care about fatness, just like PLA. For 3 points in general position in the plane, all 8 labelings can be produced, so they can be shattered. The handout's picture draws 4 of them, and the lecture explains that the other 4 are their symmetric counterparts.
- : requires the line to be at least 1.126 fat. The handout says this is more strict than SVM; SVM only looks for the fattest and does not prescribe a minimum fatness. For the same 3 points in the picture, a fat enough line can be found when all are labeled circles; but in some labelings a circle and a cross are too close for a line that fat to fit between them, and cannot produce them. So these 3 points cannot be shattered.
Fewer producible dichotomies means lower complexity. The handout writes this chain of reasoning as:
fewer dichotomies ⟹ smaller 'VC dim.' ⟹ better generalization
"VC dim." is in quotation marks. In the lecture, Lin explains that this is not a VC dimension derived from the Foundations definition; you can think of it as an effective VC dimension, and the lower it is, the closer and are.
The VC dimension of an algorithm: the example on the unit circle
Page 25 explains the quotation marks. The of Foundations is a property of the hypothesis set and is data-independent. The discussed here is a property of the algorithm: whether can produce a given dichotomy depends on whether a fat enough line can be found on this particular data, so it is data-dependent. The handout notes that this needs more than VC. In the lecture, Lin says the rigorous derivation of this part takes more effort and that only the concept is covered here: see how many points this algorithm can shatter at most.
The setting in the handout is being the unit circle in . The lecture talks about any three points inside the circle, and the picture on the slide is a filled circle, so what is meant here is the disk of radius 1.
- : just perceptrons, .
- : cannot shatter any 3 inputs, . The reason the handout gives: some two of the inputs must be at distance at most .
The handout gives this reason in a single line, and this article completes it.
Why some two points must be at distance at most √3. If one of the three points is at the center, its distance to each of the other two is at most 1. Otherwise, the three points are seen from the center in three directions, the three directions go around a full 360 degrees, and some two of them must form an angle of at most 120 degrees. Those two points are at distances and from the center, both at most 1. By the law of cosines, , so their squared distance is
Why that rules out shattering. Label one of these two points a circle and the other a cross. The separating line has to pass between the two points, and their distances to the line add up to no more than the distance between them, (the same argument as in the Fun Time on "the fattest separating line for two points"). The nearer of the two is then at distance at most from the line, so the margin is at most as well. When is greater than this number, cannot find a line that qualifies, and this labeling cannot be produced. With at least one of the 8 labelings missing, it is not shattering.
Applied to a concrete set of points (an example made up for this article, not from the slides). Take the equilateral triangle inscribed in the unit circle: , , , with every side of length . Label the top point a circle and the bottom two crosses, and the fattest separating line is the horizontal line : the top point is at height 1, the bottom two at height , they are 1.5 apart, the line sits right in the middle, and the margin is 0.75. By symmetry the other five one-against-two labelings also give 0.75; when the three points all get the same label, the line can be placed far away and the margin can be as large as you like. So for these three points, with can shatter them and with it cannot. The handout's threshold is larger than 0.75; it is a sufficient condition guaranteed to hold for any three points in the disk.
The handout then gives the general result: when lies inside a hyperball of radius ,
The handout does not prove this formula, and neither does this article. It says two things. First, the upper bound depends on two quantities: the range over which the data spread, and the required fatness . In the lecture, Lin explains that a bigger circle has room for a fatter line, and data squeezed into a small range do not. Second, whatever happens, it is never worse than the of ordinary perceptrons; when is large enough, the term is smaller than and the upper bound really does come down. The lecture sums it up as: one more way to control complexity.
An addition in this article, about something to watch for when reading this formula that the handout does not mention. When is not an integer, plugging in literally gives a number with a fractional part. Check it against the equilateral triangle above: with , , , , which read literally says at most 2 points can be shattered. Yet those three points all lie in the disk of radius 1 and really can be shattered by : the six one-against-two labelings all have margin 0.75, and the two all-same labelings have unlimited margin. So when is not an integer, this formula cannot be read literally as an exact upper bound; what it conveys is the trend that the larger is relative to , the fewer points can be shattered. The two numbers this lecture actually uses are not affected: that 3 points cannot be shattered when was proved above directly from the distance between two points, without this formula; and in the Fun Time, happens to be an integer.
Paired with feature transforms: not many boundaries, yet sophisticated shapes
Page 26 closes with a table:
| large-margin hyperplanes | hyperplanes | hyperplanes + feature transform Φ | |
|---|---|---|---|
| number of boundaries that can be produced (#) | even fewer | not many | many |
| shape of the boundary | simple | simple | sophisticated |
The handout's two comments: not many is good, for and generalization; sophisticated is also good, for a possibly better . The lecture looks back at what Foundations did: hyperplanes were used in the first place because their is not large and the complexity stays under control; but a boundary that is too simple may not do well, which is why feature transforms were added to buy sophisticated boundaries. We want to take care of both terms of the VC bound, but the original tools could take care of only one at a time.
A large margin offers a new combination. Put large-margin hyperplanes together with numerous feature transforms:
| large-margin hyperplanes + numerous feature transform Φ | |
|---|---|
| number of boundaries that can be produced (#) | not many |
| shape of the boundary | sophisticated |
The feature transform pushes the number up to "many", and the large margin pulls it back to "not many" while keeping the sophisticated shape. The handout calls this a new possibility: non-linear SVM. In the lecture, Lin says that with this new way of controlling complexity, you can use all kinds of feature transforms with more peace of mind. This is exactly what the first technique in Course Design sets out to do: exploit numerous features while keeping complexity in check.
Fun Time: the upper bound in a 1126-dimensional space
Question (handout page 27): Consider running the large-margin algorithm with on a -space such that is of 1126 dimensions (excluding ) and . What is the upper bound of when calculated by ?
Answer: 2. The handout's reference answer: and , so the upper bound is 17. The computation is
Option 1's 5 forgets the square and computes . Option 3 takes only . Option 4's 1127 is the of ordinary perceptrons and does not use the margin at all. The comment in the lecture is that even in a 1126-dimensional space, as long as you insist on fatness, the upper bound on the VC dimension is as small as 17.
The summary on page 28 wraps each of the five parts into one line: the course goes from foundations to techniques; the large-margin separating hyperplane is intuitively more robust against noise; the standard problem minimizes the length of at a special scale; SVM can be solved "easily" via quadratic programming; a large margin gives fewer dichotomies and better generalization. The preview for the next lecture is solving non-linear Support Vector Machine.
Self-check
1. Three examples: labeled , labeled , and labeled ; the hyperplane is . Compute the three points' distances to it and the margin, then rewrite in the scaling where "the smallest equals 1" and confirm that equals the margin.
Answer: , , . The three points' score values are , , and ; the distances are , , and ; the margin is 2. The minimum is 10, so divide everything by 10: , . Now and , which agrees with the margin.
2. Three examples: labeled , labeled , and labeled . Following the handout's method for solving four points by hand, find the hard-margin SVM's and margin, and say which points are on the fat boundary.
Answer: the constraints are , , and . Adding the first two gives , , so , with equality requiring , . Substituting back: the first needs and the second needs , so ; the third is , which holds. The optimal solution is , , the line , with margin . The first two points have equal to 1 and are on the fat boundary; gives 2 and is not on the boundary, and removing it does not change the answer.
3. Why can the constraint "the smallest equals 1" be replaced by "every one is at least 1"?
Criterion: the answer needs three points. First, the latter is a necessary condition of the former, so the feasible set can only grow. Second, the optimal solution of the relaxed problem cannot have every point strictly greater than 1: if the minimum were some , dividing by would still be feasible while making shorter, contradicting optimality. Third, the optimal solution of the relaxed problem therefore already satisfies the original constraint, and it is also the optimal solution of the original problem. Saying only "because scaling does not matter" does not count as correct; that is the reason for the previous step (fixing the scaling).
4. The data have features and examples. Write down the sizes of the four QP inputs and the contents of . If the solver you have only accepts the form , how should and change?
Answer: has 4 components ( plus 3 values of ). is with diagonal and 0 everywhere else. is 4 zeros. is , and row is . is 5 ones. To switch to the "≤" form, multiply both sides of the inequality by : , so feed and .
5. The data lie in a ball of radius and the features have dimensions. Use the handout's formula to compute the upper bound of for and for , and say in which case the large margin helps.
Answer: for , and the upper bound is , smaller than the perceptron's 51, so the large margin helps. For , and the upper bound is , the same as the perceptron, so the formula gives no better guarantee. The margin has to be large enough relative to the range of the data for the upper bound to come down.
Exercises and corresponding reading
The corresponding week in two semesters. The Fall 2024 course page puts linear SVM and dual SVM in the same week (W9, 10/28), and the slide code for this lecture is 201u. The Fall 2026 course page also puts them in W9 (11/04), with the two lectures taught together. The Fall 2026 link to 201u_handout.pdf for that week returned a 404 when opened on 2026-09-30 (the course had only reached W4 at the time), so this article uses only the MOOC handout. The MOOC handouts and videos are all free to access.
Textbook. Both course pages map this lecture to e-8.1 of Learning from Data (LFD). e-Chapter 8 is one of LFD's online chapters and is not in the printed book.
Homework. This lecture had no homework of its own in Fall 2024. The related Fall 2024 HW6 (released 2024-11-18, due 12-02) is about kernels, soft margin, and aggregation, and has no official solutions; the problems in it closest to the first two SVM lectures, Q1 and Q13, use duality and " represented by data" and are discussed in Techniques Lecture 2. The guide to the whole assignment is in Techniques Homework and Final Project. The most direct exercise for this lecture is to redo self-check question 2 with a few sets of points you make up yourself, then follow the three steps of the Linear Hard-Margin SVM Algorithm, hand the same data to whatever QP tool you have, and compare the answers.
Further reading. Chapter 6 of the CS229 main notes derives SVM in a different way and can be read alongside this lecture's QP formulation. Caltech Learning from Data is the course in English that Abu-Mostafa teaches from the same textbook.
Next lecture. Techniques Lecture 2: Dual SVM deals with the problem this lecture leaves behind: after a high-dimensional feature transform, has components and the QP becomes too large to solve, so it has to be traded for an equivalent problem whose number of variables depends only on the amount of data.
Course video sources
Original videos: Course Introduction, Large-Margin Separating Hyperplane, Standard Large-Margin Problem, Support Vector Machine, Reasons behind Large-Margin Hyperplane
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-10: Marked the video status and checked the recording sources and how to access them.
- 2026-10-10: Rechecked the video status. The embedded videos match the lecture numbering of the official playlist.
- 2026-10-13: Previously combined with Lecture 2 in one article; changed to one article per lecture and rewritten from the handout and the video transcripts.
References
- Techniques Lecture 1 handout, 201_handout.pdf: the main source for this article. The derivations in the five parts, the four-point example, and the five Fun Time questions all come from this handout.
- Machine Learning Techniques YouTube playlist: the IDs and titles of the five videos; what the text reports as said "in the lecture" is paraphrased from machine transcripts of these five videos.
- Hsuan-Tien Lin > MOOCs: the official entry for handouts and recordings.
- Foundations Lecture 12 handout, 12_handout.pdf: the two prices of feature transforms, which this lecture's motivation follows from.
- Foundations Lecture 14 handout, 14_handout.pdf: the formulation of weight decay, used for comparison with the standard SVM problem.
- Machine Learning, Fall 2024 course page: the corresponding week and LFD chapter.
- Machine Learning, Fall 2026 course page: the corresponding week and LFD chapter.
- Fall 2024 Homework 6 (hw6_red.pdf): the assignment's topics and the related problem numbers.
- Learning from Data textbook website: the source of e-8.1.
- CS229 main notes, main_notes.pdf: further reading, the SVM derivation in Chapter 6.
- Caltech Learning from Data telecourse: further reading, a course in English that uses the same textbook.
- Reading NTU Hsuan-Tien Lin Machine Learning Foundations & Techniques: Course Overview: where this lecture sits in the whole course, and which lectures the four Foundations questions and the three Techniques categories cover.