Skip to main content
Machine Learning

Support Vector Machines — Soft Margin, Non-Linear SVM, and Model Fairness

📅 Published: 2026-06-30
🎓 Level: postgraduate
👥 Audience: Postgraduate students in Machine Learning

Prerequisite Knowledge

This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.

Previously Covered in This Subject

  • Support Vector Machines — Core Concepts — covered in Lecture 16 (SVM decision boundary, margin, support vectors, hard/soft margin, primal and dual formulations)
  • Regularization (L1 and L2) — covered in Lectures 5 and 6 (Ridge vs. Lasso, shrinkage, sparsity, the regularization parameter λ)
  • Classification Evaluation — covered in Lecture 7 (confusion matrix, precision, recall, F1 score)

Support Vector Machines — Soft Margin, Non-Linear SVM, and Model Fairness

This lecture completes the SVM trilogy: from hard margins to soft margins (handling noisy data), from linear to non-linear decision boundaries (the kernel trick), and from pure accuracy to responsible AI (FACT ML framework).

By the end, you will be able to: solve a complete non-linear SVM numerical, prove a function is a valid kernel, compute hinge loss values, and explain why removing sensitive features from a dataset does not guarantee fairness.

17.1 Linear SVM — Problem Recap

Hook: You train an SVM on 10,000 points. At test time, only 3 or 4 of them actually matter. The other 9,996 could be thrown away and the decision boundary would not shift by a pixel. How is that possible — and why is it the key to SVM's power?

Intuition: Two crowds (Team Red & Team Blue) stand in a field. You must draw a straight line between them — but you want the fairest line, placed exactly in the middle of the gap so neither team feels the boundary is biased. The people at the very front of each crowd — the ones closest to the other team — are the only ones that decide where the line goes. Everyone deep in the crowd has no say. Those front-line people are the support vectors.

Where the analogy breaks: In the field, the line must be straight. SVM can "bend" the line by lifting points into a higher dimension (the kernel trick, §17.4–17.5).

17.1.1 Definition and Core Concepts

A Support Vector Machine (SVM) is a binary classifier that finds the decision boundary with the maximum margin — the widest strip separating two classes where no training points fall inside the strip.

The margin is the perpendicular distance from the decision boundary to the nearest data point on either side. Maximizing it gives the best chance of generalizing to unseen data.

Support vectors are the training points that lie exactly on the margin boundary (or inside it, in the soft-margin case). They alone determine the solution. All other points can be deleted with zero effect on the boundary.

The normal vector (also called the weight vector) is perpendicular to the decision boundary. Its direction sets the boundary's orientation; its magnitude controls the margin width — larger means a narrower margin.

17.1.2 Symbol Registry — Linear SVM Dual Formulation

Symbol Meaning Type Domain
Weight vector (normal to decision boundary) vector
Bias term (shifts hyperplane from origin) scalar
-th data point vector
Class label for scalar
Lagrange multiplier for scalar for support vectors; otherwise
Mapping to higher-dimensional feature space function

17.1.3 Mathematical Formulation — The Dual Problem

The margin formula. The perpendicular distance between the two margin hyperplanes ( and ) is:

Maximizing the margin means minimizing . For a smooth derivative, we minimize instead.

The primal problem (hard margin):

The constraint means every point lies on or outside its class margin. Points exactly on the margin satisfy — these become support vectors.

Why the dual? Solving the primal in high dimensions is expensive. Using Lagrange multipliers , we convert to the dual, where everything is expressed through dot products:

subject to and .

The three operational formulas. Solve the dual for , then compute:

Notation note. Bishop (§7.1, Eq. 7.18) gives — a numerically stable average over all support vectors. The professor's is equivalent for a single support vector and matches the augmented-vector shortcut. Both produce the same line.

These three formulas are all you need. The first expresses as a weighted sum of support vectors. The second gives the bias. The third classifies any new point: gives the predicted class.

Notation: and are identical — both mean the dot product. Some texts write , others . Same geometry, different sign convention for .

17.1.4 Worked Example — Finding α Values and Decision Boundary

Problem: Three augmented support vectors are given. Find the decision boundary.

Given (with bias augmented as the third component — the lecture PDF provides exact values):

- - -

(Plausible values from the lecture context; the method is what matters.)

Step 1 — Set up the linear system for . For each point :

For : , and cross-terms with . After computing dot products and simplifying, the equation reduces to a linear equation in . Repeat for .

Step 2 — Solve. Three equations, three unknowns — solve by elimination.

Step 3 — Compute . . The first two components are the weight vector; the third component is the bias (augmented vector trick).

Step 4 — Decision boundary. . For the lecture's data: , a horizontal line.

Sense-check: A horizontal line separating (below) from (above) — geometrically consistent.

17.1.5 Assumptions & Scope

Scope / Assumptions: - Binary classification only. SVM natively handles two classes. For , use one-vs-rest or one-vs-one. - Hard margin assumes linear separability. Overlapping classes produce no feasible solution. Use soft margin (§17.2). - Dot-product formulation. The dual uses only — this is what enables the kernel trick later. - Convex optimization. The dual is a convex QP. Any local optimum is global. No initialization lottery.

17.1.6 Visual Intuition

Picture a 2D scatter plot. Two parallel lines straddle a central decision boundary. A few circled points sit on those margin lines — these are the support vectors. All other points float well outside the strip. The axes are your two features. The key landmark: the perpendicular gap between the margin lines equals .

One-sentence takeaway: Move any non-support vector anywhere (without crossing the margin) — the decision boundary does not budge.

17.1.7 Pitfalls

Common traps: 1. Confusing and . is the direction; is the length. Maximizing the margin means minimizing , not . 2. Forgetting the bias. — without , the hyperplane is forced through the origin. Rarely works. 3. Dual vs. primal. The three formulas are the only operational outputs. You don't need to re-derive the dual each time. 4. Sign of . vs. is a convention. Keep the same convention within one problem.

17.1.8 Recap + Bridge

SVM = maximum margin classifier. Margin = . Only support vectors () matter. Three formulas: , , .

Next: Hard margins break on noisy data. Soft margins (§17.2) fix that by allowing some violations — with a penalty.

17.1.9 Real-World & Domain Connection

SVMs were the dominant classifier before deep learning, especially in text categorization (spam filters, sentiment analysis) and bioinformatics (gene expression, protein structure). They excel with high-dimensional data because the dual formulation's cost depends on the number of points, not dimensions. Linear SVMs remain production defaults for text classification — fast training, few hyperparameters, strong theoretical guarantees via VC bounds. The sparsity property (only support vectors matter) also makes SVMs memory-efficient at prediction time.


17.2 Soft Margin SVM — Handling Noisy Data

Hook: You draw the "perfect" line through your training data — zero errors. Then you test it: 40% wrong. The line was too perfect. It memorized the noise instead of learning the signal. How do you force a classifier to accept a few mistakes today so it wins tomorrow?

Intuition: Think of drawing a boundary between two scatterplots of overlapping dots. A hard margin demands zero dots in the strip — impossible when the dots intermingle. A soft margin says: "I'll let a few dots cross the line, but each crossing costs a penalty." It's like a toll road — you can cross, but you pay. The toll price is governed by .

Where the analogy breaks: In a real toll road, the price is fixed per crossing. In SVM, the penalty grows linearly with how far you cross — a point deep in enemy territory pays more than one barely over the line.

17.2.1 Motivation — When Hard Margins Fail

Hard margin SVM requires the training data to be perfectly linearly separable — every point must fall on or outside its class margin. Real data rarely satisfies this.

Two failure modes: - Overlapping classes. Points from different classes intermingle. No straight line can separate them. The hard margin problem has no feasible solution — the constraints cannot all be met. - Overfitting on separable data. Even when data is linearly separable, the maximum margin hyperplane may hug a noisy outlier, producing a narrow margin that generalizes poorly.

The fix: soft margin classification. Allow some points to violate the margin — but charge a penalty for each violation. The penalty is measured by a slack variable .

17.2.2 The Slack Variable

The slack variable (pronounced "xi" or "epsilon" in the lecture) measures how far data point is from its correct side of the margin.

value Meaning Penalty
Correctly classified AND on or outside the margin None
Correctly classified but inside the margin Small
Misclassified (on the wrong side of the decision boundary) Large (grows with distance)
Impossible — slack is always N/A

From Bishop (§7.1.1, Fig. 7.3): for points on or inside the correct margin boundary, and for other points. A point exactly on the decision boundary has .

Confidence interpretation:

  • → high confidence (point is safely on its side)
  • → moderate confidence (point is near the boundary)
  • → low confidence (point is misclassified)

17.2.3 The Soft Margin Objective Function

The optimization now trades off two competing goals:

- First term : Maximize the margin (minimize ). Same as hard margin. - Second term : Penalize margin violations. controls how heavily we punish violations.

Subject to the relaxed constraints:

Notice: when , the constraint reduces to the hard margin condition . When , the right-hand side drops below 1 — the point is allowed to drift inside or even across the margin.

The Lagrangian for the soft margin (Bishop Eq. 7.22) introduces two sets of Lagrange multipliers: for the margin constraints and for the non-negativity of . After eliminating , the dual is identical to the hard margin dual except that each is now box-constrained: (Bishop Eq. 7.33). This acts as an upper bound — support vectors with lie inside or on the wrong side of the margin.

17.2.4 The Hyperparameter C — The Football Coach Analogy

The professor's analogy: Think of as a football coach.

- High → strict coach → narrow margin. The coach forbids any player from crossing to the other team's side. To enforce this, the margin is made very narrow — players can hardly move without violating it. Result: perfect training classification, but overfitting. The model is too rigid for new players (test data).

- Low → liberal coach → wide margin. The coach tolerates some wandering. The margin is wide. A few players drift to the wrong side but the coach shrugs it off. Result: some training errors, but better generalization to new data.

In Bishop's terms (§7.1.1): is analogous to the inverse of a regularization coefficient — recovers hard margin; makes the margin dominate, ignoring errors. The regularization parameter appears when the objective is rewritten as (Bishop Eq. 7.44).

Summary: controls the margin-vs-errors trade-off. High = high penalty = narrow margin = low error tolerance. Low = low penalty = wide margin = high error tolerance.

17.2.5 Student Q&A

Q: For a point correctly classified but inside the margin, is the slack variable between 0 and 1? A: Yes. The point is on the correct side but very close to the boundary. The small penalty acts as a warning — if data shifts slightly, this point could flip. Several students asked this; it's the most common confusion about slack values.

Q: Can the slack variable be negative — like "bonus points" for being far on the correct side? A: No. The constraint is absolute. You cannot earn "extra credit" for being deep in safe territory. Slack only penalizes closeness to (or crossing of) the boundary. This is a hard mathematical constraint in the optimization, not a choice.

Q: Is slack zero for correctly classified points far from the margin on the negative side too? A: Yes. For any correctly classified point (positive or negative class) that lies on or outside its margin, . The sign of the class doesn't matter — only the distance from the correct margin matters.


17.3 Hinge Loss — Mathematical Realization of the Slack Variable

Hook: The slack variable is a beautiful idea — but it's not directly computable. You can't just "set " for a borderline point; the optimizer must figure it out. Hinge loss is the function that makes the optimizer feel the right amount of pain for each mistake.

Intuition: Think of a door hinge. When the door is closed or swinging freely in the correct direction — zero resistance, zero loss. But push the door the wrong way past the frame and resistance kicks in immediately, growing with how far you push. The "frame" is the margin boundary (). Correctly classified points beyond it feel nothing. Points inside feel linear resistance.

The analogy breaks: A real hinge resists in both directions. Hinge loss only penalizes one direction — being on the wrong side of the margin. Being "too correct" costs nothing.

17.3.1 Definition

The hinge loss is the mathematical function that replaces the slack variable in the SVM objective. It measures the penalty for a single point:

Here is the "agreement" between the true label and the model's signed-distance prediction. In Bishop (§7.1.2, Eq. 7.45), this is written as where denotes the positive part.

The notation and are interchangeable — different textbooks, same weight vector.

17.3.2 Symbol Registry — Hinge Loss

Symbol Meaning Type Domain
True class label scalar
Model's signed distance from decision boundary scalar
Agreement score — positive when prediction and label agree scalar

17.3.3 Hinge Loss Values by Classification Outcome

The hinge loss mirrors the three slack-variable regimes exactly:

Case 1 — Correctly classified AND outside the margin ():

For a positive point () with strong positive signal :

For a negative point () with strong negative signal :

Numerical check: . ✓

Case 2 — Correctly classified but INSIDE the margin ():

The agreement is positive but weak. Then :

Numerical check: . Between 0 and 1. ✓

Case 3 — Misclassified ():

The agreement is negative — model and truth disagree. Then :

Numerical check: . ✓

Classification Outcome Hinge Loss
Correct, outside margin
Correct, inside margin
On the decision boundary
Misclassified

17.3.4 The Complete Soft Margin Formulation with Hinge Loss

Replacing with hinge loss gives the full SVM objective in one expression:

Or equivalently (Bishop Eq. 7.44 with ):

Both forms express the same trade-off. The professor's form keeps in the numerator (large = strict); Bishop's uses in the regularizer position (small = strict).

17.3.5 Visual Intuition

Plot the hinge loss as a function of :

  • Horizontal axis: , the agreement score. Right side = correct classification; left side = misclassification.
  • Vertical axis: loss value.
  • For : flat at zero — the "hinge" is closed, no loss.
  • For : a straight line sloping down-left with slope — the "hinge" opens, loss grows linearly.
  • Key landmarks: At , loss = 0 (margin boundary). At , loss = 1 (decision boundary). At , loss = 3 (deep misclassification).

The name "hinge" comes from the shape — flat on one side, linear ramp on the other, like an L-shaped door hinge. Bishop's Figure 7.5 compares this shape to logistic loss (smooth curve, never exactly zero) and squared error (penalizes "too correct" points). Only hinge loss produces sparse solutions where most .

17.3.6 Pitfalls

Common traps: 1. Confusing with the prediction. The prediction is . The argument to hinge loss is the agreement . They are different numbers. 2. Thinking hinge loss can be negative. guarantees loss . If you compute a negative value, you misapplied the formula. 3. Forgetting that , not . SVM uses labels. If your labels are 0/1 (like in logistic regression), hinge loss must be re-derived — it won't work as written.

17.3.7 Comparison — Hinge Loss vs. Logistic Loss

Property Hinge Loss (SVM) Logistic Loss
Formula
Zero region Yes () Never exactly zero
Penalizes "too correct"? No Slightly (vanishes as )
Leads to sparsity? Yes (flat region ) No (all points influence)
Probabilistic output? No Yes

When to pick which: Use hinge loss (SVM) when sparsity and margin maximization matter. Use logistic loss when calibrated probability estimates are needed.

17.3.8 Student Q&A

Q: Why is the prediction "greater than 1" for a correctly classified positive point? Shouldn't it be exactly 1 on the margin? A: Points exactly on the margin give (positive side) or (negative side) — these are the support vectors. But most correctly classified points lie beyond the margin, giving values or . The margin boundary is the threshold, not a ceiling. Several students asked this — it's a key geometric point.

Q: For a negative-class point misclassified as positive, what is the hinge loss? A: but (predicted positive). Then . The further the point is on the wrong side, the larger the loss.

Q: How is the value of determined? A: is a hyperparameter, chosen by cross-validation or grid search. In Python's sklearn.svm.SVC, it's the C parameter. The key intuition: large → strict → narrow margin; small → liberal → wide margin. This was covered in §17.2.4.

17.3.9 Recap + Bridge

Hinge loss = is the computable stand-in for the slack variable. It's zero for safe points, linear for violators, and its flat region is what makes SVM solutions sparse. The full soft-margin SVM minimizes .

Next: Soft margins handle overlapping classes — but what if the classes are separable only by a curve, not any line? Non-linear SVM (§17.4) lifts the data into higher dimensions where a line can separate them.


17.4 Non-Linear SVM — The Need for Higher Dimensions

Hook: You have a 1D problem: blue dots at and red dots at and . No single cut point can separate them — the blues are sandwiched between the reds. Yet with one simple trick you can draw a straight line that perfectly separates them. The trick: add a dimension.

Intuition: Imagine you're looking down at a room from the ceiling. Two clusters of people are interwoven — you can't draw a line on the floor to separate them. Now imagine some people are lifted onto chairs. From the ceiling, the pattern still looks tangled. But if you could fly around the room in 3D, you'd see a flat plane slicing cleanly between the standing people and the people on chairs. That's what mapping to a higher dimension does: it gives you a new viewpoint where complexity dissolves into simplicity.

The professor's own analogy (dosage): Too little medicine doesn't cure. Too much medicine doesn't cure. Only the middle dose works. On a 1D line, the "cured" cases are sandwiched between "not cured" cases — inseparable. Square the dosage (add an dimension) and the two "not cured" extremes both shoot up while "cured" stays near zero. A straight diagonal line in the plane now separates them.

17.4.1 When Data is Not Linearly Separable

A dataset is linearly inseparable when no single hyperplane can separate the classes. Example: blue dots cluster near the origin, red dots surround them in a ring (the classic XOR or concentric circles pattern). A straight line cannot split a ring from its center.

Hard margin SVM has no feasible solution on such data. Soft margin helps with overlapping classes but cannot fix fundamentally non-linear decision boundaries — a straight line through a ring will always misclassify roughly half of it.

17.4.2 The Core Idea — Mapping to a Higher Dimension

The solution: Transform data into a higher-dimensional feature space where it becomes linearly separable, then apply linear SVM in that space.

The key insight (from Cover's theorem): a complex classification problem cast into a high-dimensional space is more likely to be linearly separable than in a low-dimensional space. You may need thousands or even infinite dimensions — and that's fine, because the kernel trick (§17.5) lets us compute in that space without ever constructing it explicitly.

17.4.3 The Mapping Function

Let (phi) be the feature mapping:

A concrete example — mapping 2D to 5D:

The factors are not arbitrary. They ensure for the polynomial kernel. Here's why: expanding gives . The cross-term coefficient 2 must be distributed as between the two vectors for the dot product to work. Verified against Bishop §7.1 and the kernel trick derivation in §17.5.

How do we know ? In practice, we work backward: start from a desired kernel function , then derive by algebraic expansion (§17.6). Libraries like sklearn.svm.SVC handle this automatically — you just pick the kernel.

17.4.4 Non-Linear SVM — The Two-Step Process

The non-linear SVM process: 1. Map: Transform every data point into the higher-dimensional feature space. 2. Classify: Run standard linear SVM (hard or soft margin) on the transformed points .

The linear hyperplane found in the -space corresponds to a non-linear decision boundary in the original space. Both represent the same classifier — just viewed through different lenses.

17.4.5 The Non-Linear SVM Equations

Every formula from linear SVM carries over — just replace with :

Decision boundary:

Primal objective (soft margin):

Weight vector:

Prediction for a new point :

Notice: every appearance of is inside a dot product . This is the opening the kernel trick exploits.

17.4.6 Assumptions & Scope

Scope / Assumptions: - Cover's theorem guarantee: For sufficiently high-dimensional , linear separability is likely — but not guaranteed for every dataset. Pathological cases exist. - Dimensionality can be infinite. The Gaussian (RBF) kernel implicitly maps to an infinite-dimensional space. This is fine because we never build explicitly. - The mapping is fixed beforehand. is chosen by the kernel, not learned from data. The SVM only learns and . - Computational problem: Explicitly computing for millions of points in a billion-dimensional space is impossible. This is exactly why we need the kernel trick (§17.5).

17.4.7 Visual Intuition

Picture the 1D dosage example: a number line with blue at and red at . Now add a vertical axis. The blue point stays at . The red points shoot up to and . In this 2D plane, draw a diagonal line from top-left to bottom-right — it cleanly separates blue (below) from red (above). This diagonal line in is a parabola in the original 1D space. Same boundary, different view.

Takeaway: A complex curve in low dimensions is a simple plane in high dimensions. The data didn't change — only the coordinate system did.

17.4.8 Pitfalls

Common traps: 1. Thinking changes the data. is just a change of coordinates — like switching from Cartesian to polar. The underlying points are the same. 2. Confusing with the kernel . maps one point to a high-D vector. computes a dot product in that space directly from the original points. They are related but distinct. 3. Assuming higher dimensions always help. Adding dimensions adds flexibility but can overfit. The margin maximization (and ) still controls this.

17.4.9 Recap + Bridge

Non-linear SVM = map data to higher dimensions via , then run linear SVM. The only change from linear SVM: replace every with . The resulting linear hyperplane in -space is a non-linear boundary in the original space.

Next: Explicitly computing is computationally impossible for large datasets. The kernel trick (§17.5) gives us the result without ever computing .

17.4.10 Real-World & Domain Connection

The insight that non-linear problems become linear in higher dimensions is foundational to kernel methods and was a major breakthrough in the 1990s (Vapnik, Boser, Guyon). It enabled SVMs to handle image recognition, handwriting digit classification (MNIST), and text categorization where decision boundaries are inherently non-linear. The same principle — lifting to higher dimensions — underpins modern techniques like random Fourier features and certain neural network architectures (though NNs learn the mapping rather than fixing it upfront).


17.5 The Kernel Trick

Hook: You need to compute dot products in a billion-dimensional space. Your computer has 16 GB of RAM. Representing just ONE vector in that space would take ~8 GB — two vectors, and you're out of memory. Yet SVM does this routinely on commodity hardware. The secret: it never builds those billion-dimensional vectors.

Intuition: You want to know the total area of two rooms combined. You could measure each room's length and width, multiply, and add — the direct way. Or you could notice that both rooms together form a rectangle that's just , and compute that directly — much faster. Both give the same answer. The kernel trick is this "shortcut formula" for high-dimensional dot products.

Another analogy: You want to know if two recipes are similar. You could list every ingredient each recipe COULD use (an infinite list), mark which ones appear, and compare the lists. Or you could just count the ingredients they share — much faster. The kernel computes "shared ingredient count" without ever building the infinite list.

Where the analogy breaks: The kernel trick gives the exact high-dimensional dot product, not an approximation. It's algebraically identical.

17.5.1 The Computational Problem

The bottleneck: Explicitly mapping every data point into a high-dimensional feature space is computationally infeasible. For polynomial kernels, the dimension explodes: mapping 100 features with degree gives ~5,000 dimensions; gives ~170,000. The Gaussian (RBF) kernel maps to infinite dimensions. You cannot allocate arrays of infinite size.

Yet every SVM formula only needs — a single scalar. We don't need the vectors; we just need their dot product.

17.5.2 What the Kernel Trick Does

The kernel trick computes — the dot product in the high-dimensional feature space — directly from the original points , without ever constructing or .

This gives the exact same mathematical result as the expensive explicit mapping. It is not an approximation. It is an algebraic identity: certain functions can be rewritten as dot products of some , and evaluating on the original inputs is infinitely cheaper than computing and then the dot product.

17.5.3 The Kernel Function

A kernel function is defined as:

Wherever linear SVM uses (the dot product in the original space), non-linear SVM uses . The decision function becomes:

All the duality, sparsity, and margin properties carry over — only the "similarity measure" between points changes from a simple dot product to a kernel evaluation.

17.5.4 Common Kernel Functions

Kernel Formula When to use
Linear Data is (approximately) linearly separable; baseline
Polynomial Moderate non-linearity; controls curvature
Gaussian (RBF) Complex, unknown decision boundaries; infinite-dim mapping
Sigmoid Historical interest; related to neural nets

The linear kernel is what we used in §17.1–17.3 — it's just the plain dot product. The Gaussian (RBF) kernel is the most common choice when you don't know the data's shape. Its (or in sklearn) controls how "local" each support vector's influence is.

17.5.5 Worked Kernel Trick — 2D to 3D

Given , . The mapping to a 3D feature space:

The explicit (expensive) way — compute , then dot product:

The kernel (cheap) way — dot product in 2D, then square:

Identical. The factors in distribute as to give the correct cross-term coefficient.

Numerical spot-check: . Kernel: . Explicit: , . Dot product: . ✓

Key takeaway: replaces a 3D dot product (with 3 multiplies + 2 adds in the explicit space) with a 2D dot product + one square.

17.5.6 Worked Kernel Trick — 3D to 9D

For , the degree-2 polynomial kernel maps to a 9D space:

(Note: this version omits factors. With factors, the mapping would be — a 6D space. Both are valid for different kernel variants.)

The dot product of the 9D vectors simplifies to:

The 9D computation (81 multiplies, 80 adds) collapses to a 3D dot product (3 multiplies, 2 adds) + one square. The savings grow with dimensionality: mapping 100D data with degree 3 would require computing dot products in a ~170,000-dimensional space — versus 100 multiplies + a cube.

17.5.7 Student Q&A

Q: How do you know what is? How do you construct it? A: By reverse engineering. We know works as a kernel. We expand the algebra and group terms to factor into . In practice, you never need — you just pick a known kernel (polynomial, RBF, sigmoid) from the library. Several students asked this — the confusion comes from thinking you need to use the kernel. You don't.

Q: Is it always the case that the dot product squared equals the high-dimensional dot product? A: Only for the polynomial kernel of degree 2. Each kernel function corresponds to a different implicit . The Gaussian kernel corresponds to an infinite-dimensional (via Taylor expansion of the exponential). The key point: for ANY valid kernel, for some — we just never compute explicitly.

17.5.8 Recap + Bridge

The kernel trick = compute via without building . Common kernels: linear (no transform), polynomial (finite-dim), Gaussian/RBF (infinite-dim). The SVM formulas stay identical — just swap .

Next: Not every function is a valid kernel. How do you verify one? Two methods: find explicitly (§17.6) or check Mercer's conditions (§17.7).

17.5.9 Real-World & Domain Connection

The kernel trick is arguably the most important idea in kernel methods and one of the most elegant computational shortcuts in machine learning. It allows SVMs to learn non-linear decision boundaries with the same computational complexity as linear models (plus the cost of kernel evaluations). The Gaussian kernel is the default in sklearn.svm.SVC and is the first non-linear model tried in many industrial classification pipelines — from fraud detection to medical diagnosis. The same kernel trick appears in Gaussian Processes, kernel PCA, and kernel ridge regression.


17.6 Proving a Function is a Kernel

Hook: Someone hands you a function and says "this is a valid kernel." How do you know they're telling the truth? You can't test every possible pair of vectors. But you can prove it with one algebraic expansion.

17.6.1 How to Verify a Kernel Function

A function is a valid kernel iff there exists some mapping such that:

To prove validity, find . The method is algebraic expansion: write as a sum of terms, each of which is a product of something depending only on and something depending only on . Those "something" vectors are and .

17.6.2 Worked Verification — in 2D

Given: for 2-dimensional vectors , .

Goal: Find such that .

Step 1 — Expand the dot product:

Step 2 — Substitute into :

Step 3 — Expand the square. Let , , . Then :

Step 4 — Factor each term into "-part -part":

Term -part -part

The coefficient 2 in the cross-terms is split as — this is why factors appear in . Not arbitrary; algebraically required.

Step 5 — Read off :

This is a 6-dimensional vector. Then . ✓

Numerical spot-check: . Kernel: . Via : , . Dot product: . ✓

Exam tip: The professor's ordering is the same 6 components in a different order. Dot product is commutative — order doesn't matter.

17.6.3 Recap + Bridge

To verify a kernel: expand algebraically, split every term into , read off . If you can find ANY , the function is a valid kernel. The factors come from splitting cross-term coefficients.

Next: Finding by hand works for simple kernels. For complex ones, Mercer's theorem (§17.7) gives mathematical conditions that guarantee a exists — without constructing it.


17.7 Mercer's Theorem — Conditions for Valid Kernels

Hook: Verifying a kernel by finding works for simple polynomials. But what about ? Expanding that into a is hopeless — it maps to infinite dimensions. We need a way to guarantee a kernel is valid without constructing .

Intuition: A kernel computes dot products . Dot products have familiar properties: they're symmetric (). If you build a matrix of all pairwise dot products among a set of points, that matrix is positive semi-definite — it behaves like a covariance matrix. Mercer's theorem says: if a function has these dot-product-like properties, then a MUST exist, even if you can't write it down. It's an existence guarantee, not a construction recipe.

17.7.1 Why Not Every Function is a Kernel

A function must behave like a dot product in some feature space. Arbitrary functions don't. For the SVM dual to be a valid convex optimization problem (bounded below, with a unique solution), the kernel must satisfy specific mathematical conditions.

17.7.2 Mercer's Conditions

Mercer's theorem states that a function is a valid kernel (a Mercer kernel) if it satisfies:

1. Continuity: is a continuous function — no jumps or breaks. 2. Symmetry: . Dot products are symmetric, so kernels must be too.

These are the two conditions the professor emphasizes for this course.

Additional condition from the full Mercer theorem: The kernel matrix (Gram matrix) formed by evaluating on any finite set of points must be positive semi-definite. This means for any set of points and any vector :

This condition ensures the SVM dual objective is bounded below (Bishop §7.1, Eq. 7.10 context). For this course, focus on symmetry and continuity. The PSD condition is the deeper mathematical guarantee.

17.7.3 Constructing Kernels

Approach 1 — From distance metrics:

A distance metric must satisfy:

  • Non-negativity:
  • Identity:
  • Symmetry:
  • Triangle inequality:

If is a valid distance metric, then:

is a valid kernel. The Gaussian (RBF) kernel is exactly this construction with squared Euclidean distance.

Approach 2 — Combining existing kernels:

If and are valid kernels:

  • is a kernel for any (positive scaling)
  • is a kernel for any (adding a constant)
  • is a kernel (sum of kernels)
  • is a kernel (product of kernels)

These closure properties let you build complex kernels from simple ones.

17.7.4 Student Q&A

Q: Do we need to construct kernel functions from scratch for the exam? A: No. Inventing new kernels needs significant experience. Exam questions will ask you to verify a given kernel (by finding , as in §17.6) or to identify which of several functions are valid kernels using Mercer's conditions. Focus on the verification method.

17.7.5 Recap + Bridge

Mercer kernels are symmetric, continuous functions. If is a valid kernel, a mapping is guaranteed to exist. Kernels can be built from distance metrics () or combined from existing kernels (). Focus on verification, not invention.

Next: Let's put everything together — a complete non-linear SVM numerical from start to finish (§17.8).


17.8 Non-Linear SVM — Worked Numerical Example

Hook: You have blue points at the corners of a square around the origin and red points further out on the axes. There's no straight line that separates the inner square from the outer diamond. Yet after one non-linear mapping, a simple diagonal line does the job — and the entire solution uses exactly the same three formulas you already know.

17.8.1 Problem Setup

Data: 2D points, two classes:

- Blue class (4 points): — clustered at the corners of a unit square centered at the origin. - Red class (4 points): — lying on the axes at distance 2 from the origin, forming a diamond around the blue cluster.

The blue points form an inner square; the red points form an outer diamond. No single straight line can separate them — the red points surround the blue points. This is the classic "ring and center" linear inseparability pattern.

17.8.2 Apply the Mapping

The mapping function is given (from the lecture PDF):

The condition checks whether the point is at Euclidean distance from the origin — i.e., whether it's a red point.

Blue points (distance ): unchanged.

Red points (distance , so the first formula applies):

After mapping: blue points remain at ; red points move to and . The data is now linearly separable — blue cluster near the origin, red cluster far in the upper-right. A straight line can separate them.

17.8.3 Finding Support Vectors and Solving

With the mapped data, the procedure is identical to linear SVM (§17.1.4):

Step 1 — Augment support vectors. Add 1 as an extra component for the bias. After mapping, the support vectors (identified from the geometry) are augmented.

Step 2 — Set up the linear system. For each support vector :

Step 3 — Solve for . Three equations, three unknowns — use elimination.

Step 4 — Compute :

The professor's result: (first two components), bias = (third component of the augmented vector).

17.8.4 Drawing the Decision Boundary

With and :

To plot: pick values, compute :

0 10.057
5 5.057
10 0.057

This is a diagonal line slicing through the mapped space, separating blue points (near origin) from red points (far upper-right). In the original 2D space, this line corresponds to a non-linear curve separating the inner square from the outer diamond.

17.8.5 Key Pedagogical Points

- The mapping did NOT increase dimensionality — it moved points within the same 2D space. Non-linear SVM does not always mean "more dimensions." It means a non-linear change of coordinates. - After mapping, the process is identical to linear SVM. Find , compute , extract bias, write . The only extra step is applying first. - The decision boundary in the original space is non-linear even though it's a straight line in the mapped space. These are two views of the same classifier. - Exam strategy: For any non-linear SVM numerical, (1) apply the given to all points, (2) identify support vectors in the mapped space, (3) solve using the three standard formulas. Don't overthink it.

17.8.6 Student Q&A

Q: How do you draw the decision boundary when and are given? A: Write , solve for one variable (e.g., ), and substitute 2–3 values to get coordinates. Connect them for the line. This works for any linear decision boundary in any dimension.

17.8.7 Recap + Bridge

The non-linear SVM workflow: raw data apply linear SVM (solve dual get decision boundary). The only new step is the mapping. Everything else is exactly what you practiced in §17.1.

Next: SVMs are powerful classifiers, but deploying them in the real world raises questions beyond accuracy — fairness, accountability, and transparency (FACT ML, §17.9).


17.9 FACT ML — Fairness, Accountability, and Transparency

Hook: Your model achieves 99% accuracy. Your boss is thrilled. Then a newspaper reports that your model is twice as likely to reject loan applications from a certain demographic. The 99% accuracy no longer matters. Fairness is not a bonus feature — it's a requirement.

Intuition: Think of FACT as the "safety inspection" for ML systems. Before a building opens, inspectors check the structure, fire exits, and accessibility. FACT does the same for AI: Is it fair to everyone? Who is accountable when something goes wrong? Can its decisions be explained and verified? You wouldn't occupy a building that skipped inspection. Don't deploy a model that skipped FACT.

17.9.1 Definitions

FACT ML (also written FACCT — Fairness, Accountability, and Transparency) is a framework for responsible AI deployment:

- Fairness: The absence of bias toward any individual or group — whether that bias is intentional or unintentional. A fair model does not systematically disadvantage people based on race, gender, ethnicity, age, or other protected attributes.

- Accountability: Determining who takes responsibility when an ML system causes harm. If an autonomous vehicle crashes or an AI hiring tool discriminates — who is liable? The developer? The deployer? The organization? This must be defined before the project starts, not after a failure.

- Transparency: Ensuring models are understandable and auditable. Stakeholders (users, regulators, affected parties) should be able to inspect how decisions are made, especially in high-stakes domains.

These three pillars must be addressed at the start of any ML/AI project — not retrofitted after deployment.

17.9.2 Real-World Examples of Algorithmic Bias

These are not hypothetical. Each case involved real people harmed by biased algorithms:

Amazon AI Hiring Tool (2018): An internal system screened resumes and penalized any mention of "women" (e.g., "women's chess club captain"). It learned from 10 years of hiring data where men dominated technical roles — and amplified that historical pattern. Amazon scrapped the tool.

Facial Recognition & Webcams (2022–23): Multiple systems struggled to detect or correctly identify people with darker skin tones. The training data had insufficient representation of non-white faces. Result: some demographics couldn't use passport photo tools or were misidentified by surveillance systems.

COMPAS Recidivism Algorithm (2016): Used in US courts to predict a defendant's likelihood of re-offending. A ProPublica investigation found that Black defendants were nearly twice as likely to be incorrectly labeled "high risk" compared to white defendants, while white defendants were more often incorrectly labeled "low risk." This case ignited the modern algorithmic fairness movement — the term "FACT" emerged directly from these discussions.

Common thread: All four cases share the same root cause — training data that reflected and amplified existing societal biases, combined with insufficient testing across demographic groups.

17.9.3 How ML Models Learn and Amplify Bias

ML models approximate patterns in training data. If the data contains bias (e.g., historically fewer women in engineering roles), the model learns that pattern as a "rule." Worse, because ML models optimize for overall accuracy, they can amplify the bias — the model treats the biased correlation as a stronger signal than it actually is.

Example: Word embedding models exhibit gender stereotypes. The vector for "nurse" is closer to "woman" and "engineer" is closer to "man" — not because of biology, but because training text corpora reflect historical occupational gender distributions. The model then reinforces those associations in downstream applications (job recommendation, search ranking).

17.9.4 Addressing Bias — Removing Sensitive Features

The naive approach: Remove sensitive features (race, gender, ethnicity) from the dataset.

Why it's insufficient: Other features act as proxies. Even without a "race" column, features like ZIP code, shopping patterns, names, or language preferences can allow the model to reconstruct ethnicity with high accuracy. The model finds the signal whether you label it or not.

What actually helps: - Data collection: Ensure diverse, representative sampling from the start. - Preprocessing: Identify proxy features (correlation analysis between non-sensitive features and sensitive attributes) and handle them — but this is hard to do perfectly. - Fairness constraints: Add mathematical fairness criteria to the training objective (e.g., equalized odds, demographic parity). - Auditing: Test model performance separately on each demographic subgroup. A 95% overall accuracy can hide 70% accuracy on a minority group.

The professor emphasizes: data preprocessing (discretization, normalization, noise handling, missing data) must ALSO include sensitive feature and proxy removal. This is not a separate step — it's part of preprocessing.

17.9.5 Tools for Bias Detection

Tool What it does Key property
SHAP (SHapley Additive exPlanations) Assigns each feature a "fair share" of the prediction, based on game theory Identifies which features drive biased decisions
LIME (Local Interpretable Model-agnostic Explanations) Explains individual predictions by perturbing inputs and observing output changes Model-agnostic — works on ANY model

Both tools are covered in detail in §17.10.5.

17.9.6 Recap + Bridge

FACT = Fairness (no bias), Accountability (clear responsibility), Transparency (explainable decisions). Bias in training data is learned and often amplified by models. Removing sensitive features is not enough — proxy features must be addressed too. Real-world failures (COMPAS, Amazon Hiring, facial recognition) drive home that FACT is not optional.

Next: Transparency requires interpretable models. §17.10 explores the trade-off between accuracy and interpretability, and the tools (LIME, SHAP) that help explain even black-box models.

17.9.7 Real-World & Domain Connection

Algorithmic fairness is now a legal and regulatory requirement in multiple jurisdictions. The EU AI Act classifies AI systems by risk level and mandates transparency for high-risk applications. In the US, the Equal Employment Opportunity Commission (EEOC) has issued guidance on AI in hiring. Financial services (fair lending laws) and criminal justice (due process) have long-standing legal frameworks that increasingly apply to algorithmic decision-making. FACT ML is the technical discipline that bridges these legal requirements with ML engineering practice.


17.10 Model Interpretability

Hook: A deep neural network with 50 million parameters approves your loan application. You ask: "Why?" The bank says: "The model says so." Is that acceptable? For a Netflix recommendation, maybe. For a loan, a prison sentence recommendation, or a medical diagnosis — absolutely not. You have the right to an explanation.

Intuition: Think of a model as a medical test. A "black box" test tells you "positive" or "negative" with no further detail. An "interpretable" test tells you which biomarkers triggered the result and by how much — so a doctor can verify it makes medical sense. In high-stakes ML, we need the second kind.

17.10.1 Why Interpretability Matters

Interpretability is the ability to explain why a model made a specific decision, in terms a human can understand.

Domains where interpretability is non-negotiable:

  • Autonomous vehicles: If a self-driving car brakes suddenly and causes a collision, investigators must know why — was it a sensor error, a misclassified obstacle, or a correct decision?
  • Criminal justice: If an algorithm recommends denying bail, the defendant has a constitutional right to challenge the reasoning.
  • Finance: Fair lending laws require explainable credit decisions. "The algorithm said no" is not a legal defense.
  • Healthcare: A misdiagnosis from an opaque model can kill. Doctors need to verify the model's reasoning against clinical knowledge.

In all these domains, interpretability is a legal and ethical requirement, not a nice-to-have.

17.10.2 The Accuracy-Interpretability Trade-off

The trade-off: More accurate models are generally less interpretable.

Model Family Accuracy Interpretability
Deep neural networks, large ensembles Highest Lowest (black boxes)
SVMs (non-linear), random forests High Medium
Decision trees, logistic/linear regression, KNN Moderate Highest (glass boxes)

Why this happens: High accuracy requires capturing complex, non-linear patterns. Complexity hides the reasoning. A decision tree with 3 splits is easy to trace. A neural net with 50 million weights is not.

The dilemma: The application dictates where on this curve you must operate. A medical diagnosis system might legally require an interpretable model even if a deep net would be more accurate. An ad-click predictor can use the most accurate black box available — no one's rights are violated by a wrong ad.

17.10.3 Highly Interpretable Models

Decision Trees: Naturally interpretable — each prediction is a path of if-then-else rules from root to leaf. You can point to the exact sequence of feature splits that produced the output. The KD-tree visualization shows how the feature space is recursively partitioned, making the geometry explicit. The root split uses the most important feature (highest information gain).

Linear Regression: Each feature gets a weight . The prediction is . You can say "Feature contributed to the prediction." The weights directly quantify influence.

K-Nearest Neighbors (KNN): Explaining a KNN prediction: "This point is classified as Class A because 4 of its 5 nearest neighbors belong to Class A. Here are those neighbors." This mirrors how people make decisions by analogy — looking at similar past cases.

17.10.4 L1 vs L2 Regularization for Interpretability

Regularization affects how many features the model uses, which directly impacts interpretability:

- L1 (Lasso): Penalty = . The diamond-shaped constraint region forces many weights to exactly zero. Result: a sparse model using only a handful of features. You can list all contributing features on one hand.

- L2 (Ridge): Penalty = . The circular constraint shrinks all weights toward zero but never to exactly zero. Result: all features remain, just with smaller weights. Explaining a prediction requires naming 200 features.

Why L1 wins for interpretability: Explaining "I classified this as Class 1 because Features 3, 7, and 12 indicated it" is feasible. Explaining it in terms of 200 features is not. Sparse = interpretable.

17.10.5 LIME and SHAP — Explaining Black-Box Models

When you need high accuracy but also need explanations, use post-hoc explanation tools:

LIME (Local Interpretable Model-agnostic Explanations): - Explains individual predictions, not the whole model. - Model-agnostic: treats the model as a black box — queries it with modified inputs, observes outputs. - How it works (image example): Model predicts "dog." LIME creates variations of the image (hide the ear, blur the nose, mask the tail) and asks the model to re-predict each. If hiding the ear drops the "dog" confidence sharply, the ear was important. LIME builds a simple local model (e.g., linear) around that one prediction to show which input regions mattered. - Works on ANY model: neural nets, SVMs, ensembles, anything.

SHAP (SHapley Additive exPlanations): - Based on Shapley values from cooperative game theory — each feature is a "player" and the prediction is the "payout." SHAP fairly distributes the prediction among features. - Provides both local (per-prediction) and global (overall feature importance) explanations. - More theoretically grounded than LIME but computationally heavier.

Together: These tools bridge the accuracy-interpretability gap. Train a high-accuracy black box, then use LIME/SHAP to explain its decisions when needed.

17.10.6 Recap + Bridge

Interpretability = explaining why a model decided. Higher accuracy generally means lower interpretability (the trade-off). Decision trees, linear models, and KNN are naturally interpretable. L1 regularization promotes sparsity (fewer features = easier to explain). LIME and SHAP explain black-box predictions post-hoc. Choose the right point on the accuracy-interpretability curve for your application's legal and ethical requirements.

17.10.7 Real-World & Domain Connection

The EU's General Data Protection Regulation (GDPR) includes a "right to explanation" for automated decisions. The US Equal Credit Opportunity Act requires lenders to provide specific reasons for adverse credit decisions — "the algorithm said so" does not comply. These regulations are driving adoption of interpretable models and explanation tools across finance, healthcare, and criminal justice. LIME and SHAP are now standard in enterprise ML platforms (AWS SageMaker Clarify, Google Cloud Explainable AI, IBM AI Fairness 360).


17.11 Exam Guidance Summary

Exam note: The professor provided the following exam-specific guidance for this lecture's topics.

17.11.1 Mark Distribution & Strategy

  • Post-mid-semester weight: ~75% of marks from post-mid-semester topics, ~25% from pre-mid-semester (unwritten but consistent proportion).
  • Question types: Emphasis on numerical and computational problems. Fewer direct theory questions — this is an open-book exam, so conceptual explanation questions are less useful for assessment.
  • Duration: 2.5 hours exam + 0.5 hours upload = 3 hours total.
  • Grading: Relative. The passing threshold depends on the class topper's score. Scoring 50–60 out of 100 is generally safe. Continuous assessment already contributes ~20 marks; an additional 25–30 in the final exam puts you in the safe zone.

17.11.2 Key Topics & Formulas

Numerical priority (high weight):

  1. SVM — linear and non-linear: find values, compute , extract bias, write decision boundary
  2. Kernel trick verification — expand a candidate kernel to find
  3. Soft margin with hinge loss — compute loss values for given points
  4. L1 vs L2 regularization — which produces sparse models and why

Key formulas to memorize:

Theory priority:

  • FACT ML definitions and examples (COMPAS, Amazon hiring, facial recognition)
  • Model interpretability: accuracy-interpretability trade-off, L1 vs L2 sparsity
  • Mercer's conditions (symmetry, continuity)

Study advice: The SVM numerical workflow is always the same: (1) apply if non-linear, (2) set up equations for , (3) solve, (4) compute , (5) extract bias, (6) write decision boundary. Practice this loop until it's automatic.


17.12 Key Industry Applications

The following real-world systems and tools connect this lecture's concepts to industry practice:

Application / Tool Relevance to Lecture
COMPAS (Correctional Offender Management Profiling for Alternative Sanctions) Risk assessment algorithm used in US courts (2016). Labeled Black defendants as high-risk at disproportionate rates. Sparked the modern algorithmic fairness movement and the FACT framework.
Amazon AI Hiring Tool (2014–2018) Internal resume screening system that learned gender bias from historical hiring data. Penalized resumes containing "women." Scrapped after bias was discovered. Classic example of model amplification of training data bias.
Facial Recognition Systems Webcam and surveillance systems that underperform on darker skin tones due to non-diverse training data. Demonstrates the critical need for representative sampling in data collection.
LIME (Local Interpretable Model-agnostic Explanations) Industry-standard tool for explaining individual black-box predictions. Used in finance, healthcare, and legal compliance to meet "right to explanation" requirements (GDPR, fair lending laws).
SHAP (SHapley Additive exPlanations) Game-theory-based feature attribution. Used alongside LIME for bias detection and model debugging. Integrated into AWS SageMaker, Google Cloud AI, and IBM AI Fairness 360.
Autonomous Vehicles Require interpretable real-time decisions for safety certification and accident investigation. Every braking, acceleration, and steering decision must be auditable.
Financial Credit Scoring Loan approval/denial models must provide specific reasons for adverse decisions (US Equal Credit Opportunity Act). Drives adoption of interpretable models and LIME/SHAP in banking.

ML Lecture 17 notes · Support Vector Machines — Soft Margin, Non-Linear SVM, and Model Fairness

Machine Learning· postgraduate· 2026-06-30

Sections Breakdown

117.1 Linear SVM — Problem Recap

Hard margin formulation, dual problem, support vectors, and the three operational formulas

217.2 Soft Margin SVM — Handling Noisy Data

Slack variables, the hyperparameter C, and the football coach analogy for the margin-vs-errors trade-off

317.3 Hinge Loss — Mathematical Realization of the Slack Variable

Definition of hinge loss, its three regimes of values, and comparison with logistic loss

417.4 Non-Linear SVM — The Need for Higher Dimensions

Feature mapping phi, Cover's theorem, and how non-linear problems become linear in higher dimensions

517.5 The Kernel Trick

Computing high-dimensional dot products directly from original points; polynomial and RBF kernels

617.6 Proving a Function is a Kernel

Algebraic expansion method to find the implicit phi mapping for a candidate kernel function

717.7 Mercer's Theorem — Conditions for Valid Kernels

Symmetry, continuity, positive semi-definiteness, and constructing kernels from distance metrics

817.8 Non-Linear SVM — Worked Numerical Example

Full worked example: ring-and-center problem solved via a non-linear mapping to linear separability

917.9 FACT ML — Fairness, Accountability, and Transparency

Algorithmic bias, real-world examples (COMPAS, Amazon), and why removing sensitive features is insufficient

1017.10 Model Interpretability

Accuracy-interpretability trade-off, L1 vs L2 sparsity, and LIME/SHAP for explaining black-box models

Postgraduate students in Machine Learning

Exam Revision Notes

Below is the distilled, exam-ready core of this lecture. Every entry is built from the full textbook notes above. Use this section for rapid review — but if something doesn't make sense, go back to the full explanation in the main content.

Linear SVM — Dual Formulation

Must-know: Only support vectors (αi > 0) matter. Margin = 2/||W||. Three operational formulas: W = Σ αi yi Xi, b = ys − W·Xs, f(X) = Σ αi yi (Xi·X) + b. The dual formulation converts the problem into one expressible entirely through dot products, enabling the kernel trick.

Top pitfall: Confusing W (direction vector) with ||W|| (its length). Maximizing the margin means minimizing ||W||, not W. Also forgetting the bias term b — without it the hyperplane is forced through the origin.

Self-check: You delete all non-support vectors from your training set. Does the SVM decision boundary change? Why or why not?

Connects to: Soft margin SVM (§17.2), Non-linear SVM (§17.4), Kernel trick (§17.5)

Soft Margin SVM and Hinge Loss

Must-know: Slack ξi ≥ 0 measures margin violation. Soft margin objective: (1/2)||W||² + C Σ ξi. Hinge loss = max(0, 1 − yi(W·Xi + b)). High C = strict coach = narrow margin = overfitting risk. Low C = liberal coach = wide margin = better generalization. ξi = 0 for safe points, 0 < ξi ≤ 1 inside margin, ξi > 1 for misclassified points.

Top pitfall: Thinking hinge loss can be negative. The max(0,·) guarantees loss ≥ 0 always. Also using 0/1 labels instead of ±1 — SVM requires yi ∈ {−1, +1}.

Self-check: For yi = +1 and W·Xi + b = 0.3, what is the hinge loss? Is the point correctly classified?

Connects to: Linear SVM dual (§17.1), Kernel trick (§17.5), Regularization comparison (§17.10.4)

The Kernel Trick

Must-know: K(Xi, Xj) = φ(Xi)T φ(Xj) computes high-dimensional dot products directly from original points, without ever building φ(X) explicitly. Common kernels: linear (XTY), polynomial (1 + XTY)d, Gaussian RBF exp(−||X−Y||²/(2σ²)). The kernel trick replaces every Xi·Xj with K(Xi, Xj) in all SVM formulas.

Top pitfall: Confusing φ(X) with K. φ maps one point to a high-dimensional vector; K is the shortcut that computes the dot product in that space without constructing φ.

Self-check: For 2D points, the degree-2 polynomial kernel (XTY)² maps to a 3D space with √2 factors. Why are the √2 factors necessary?

Connects to: Non-linear SVM (§17.4), Kernel verification (§17.6), Mercer's theorem (§17.7)

Mercer's Theorem and Kernel Verification

Must-know: A valid Mercer kernel must be symmetric, continuous, and produce a positive semi-definite Gram matrix. To verify: expand K algebraically, factor into f(Xi)·f(Xj), and read off φ. The √2 factors in φ come from splitting cross-term coefficients: 2 = √2 · √2. Kernels can be built from distance metrics (K = e−D) or combined (sum, product, positive scaling).

Top pitfall: Forgetting that √2 factors are algebraically required, not optional — they ensure φ(A)Tφ(B) = K(A,B) exactly. Omitting them gives a different (wrong) dot product.

Self-check: Explain why K(A,B) = −||A−B||² fails Mercer's conditions. Which condition(s) does it violate?

Connects to: Kernel trick (§17.5), Non-linear SVM (§17.4), Gaussian RBF kernel

FACT ML — Fairness, Accountability, and Transparency

Must-know: Removing sensitive features (race, gender) from a dataset is not enough to ensure fairness — models learn bias from correlated proxy features (ZIP code, shopping patterns, name). Real-world cases: COMPAS recidivism algorithm (racial bias), Amazon AI hiring tool (gender bias), facial recognition (skin tone disparity). FACT ML stands for Fairness, Accountability, and Transparency in Machine Learning.

N/A — this is a conceptual/procedural topic. Key procedural takeaway: bias detection requires testing model outcomes across subgroups, not just examining input features.

Top pitfall: Believing that simply deleting the "gender" or "race" column makes a model fair. Proxy variables in the data (location, purchase history, name patterns) carry the same discriminatory signal.

Self-check: Why did Amazon's AI hiring tool penalize resumes containing the word "women's" even though gender was not an input feature?

Connects to: Model interpretability (§17.10), LIME/SHAP (§17.10.5), Responsible AI practices

Model Interpretability — L1 vs L2 and Black-Box Explanations

Must-know: Accuracy and interpretability trade off: neural nets are accurate but opaque; linear/logistic regression and decision trees are interpretable. L1 (Lasso) produces exact zero coefficients (sparse, feature selection); L2 (Ridge) shrinks toward zero but never reaches it. LIME explains individual predictions by fitting a local interpretable model. SHAP uses Shapley values from game theory for feature attribution.

Top pitfall: Thinking L2 regularization produces sparse models. Only L1 can drive coefficients to exactly zero. L2 shrinks them toward zero asymptotically but never eliminates them.

Self-check: You have 10,000 features and need to identify the 50 most important ones. Use L1 or L2 regularization?

Connects to: FACT ML (§17.9), Regularization (Lectures 5–6), Feature selection

Was this lecture useful?

Loading comments…
🤖

BitsNotes AI Assistant

Subject Notes Assistant

Configure AI Chat

Choose how to access the chatbot
Have your own API key?

Switch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.

🔑 Enter API key above to fetch live models from provider, or enter model name manually.
OpenAI-Compatible API Support

Choose any provider preset (Gemini, DeepSeek, Kimi, GLM, MiniMax, Qwen, OpenAI, Groq, Ollama, etc.) or enter a custom endpoint URL.

Security & Privacy First

Your API key is sent directly from your browser to your specified provider. BitsNotes servers never store or see your key.