← Back to Classic ML Mind Map
📊 Classic MLID: svm-margin

SVM Margin & Duality

SVM 最大间隔与对偶
🎯Core Definition
SVM finds the hyperplane with maximum geometric margin. In the separable case the constraint yi(wTxi+b)≥1y_i(w^Tx_i + b) \ge 1 (normalized functional margin) yields geometric margin 2∥w∥\frac{2}{\Vert w\Vert}, so maximizing it is equivalent to minimizing 12∥w∥2\frac{1}{2}\Vert w\Vert^2. With Lagrange multipliers αi≥0\alpha_i \ge 0, L(w,b,α)=12∥w∥2−∑i=1nαi[yi(wTxi+b)−1]L(w, b, \alpha) = \frac{1}{2}\Vert w\Vert^2 - \sum_{i=1}^{n} \alpha_i [y_i(w^Tx_i + b) - 1]; setting derivatives w.r.t. w,bw, b to zero gives w=∑iαiyixiw = \sum_i \alpha_i y_i x_i and ∑iαiyi=0\sum_i \alpha_i y_i = 0, and substituting back yields the dual max⁡α∑iαi−12∑i,jαiαjyiyjxiTxj\max_{\alpha} \sum_i \alpha_i - \frac{1}{2}\sum_{i,j} \alpha_i \alpha_j y_i y_j x_i^Tx_j s.t. αi≥0, ∑iαiyi=0\alpha_i \ge 0,\ \sum_i \alpha_i y_i = 0. The KKT complementary-slackness condition αi[yi(wTxi+b)−1]=0\alpha_i[y_i(w^Tx_i + b) - 1] = 0 means only samples on the margin boundary (yi(wTxi+b)=1y_i(w^Tx_i+b) = 1) have αi>0\alpha_i > 0; these are the support vectors, and f(x)=∑i∈SVαiyixiTx+bf(x) = \sum_{i \in SV} \alpha_i y_i x_i^Tx + b depends only on them.
💡Use Cases
the classic whiteboard 'derive the SVM dual' and 'why do only support vectors matter'; prerequisite for the kernel trick (dual inner products xiTxjx_i^Tx_j get replaced by a kernel).
⚡Key Problems Solved
the primal is convex QP with inequality constraints where KKT is both necessary and sufficient; Lagrangian duality rewrites it in terms of inner products only, which kernels can replace for implicit high-dimensional mapping — and complementary slackness compresses the model to nSVn_{SV} support vectors: O(nSV⋅d)O(n_{SV} \cdot d) storage, and each prediction is just inner products with support vectors, decoupled from the full training set.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of SVM Margin & Duality.
Use Cases
In production engineering, what are the primary use cases for SVM Margin & Duality and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Whiteboard the SVM dual: write L=12∥w∥2−∑iαi[yi(wTxi+b)−1]L = \frac{1}{2}\Vert w\Vert^2 - \sum_i \alpha_i[y_i(w^Tx_i + b) - 1], take w,bw, b derivatives, substitute back, and state the full dual objective with constraints.
2
Geometric meaning of KKT complementary slackness αi[yi(wTxi+b)−1]=0\alpha_i[y_i(w^Tx_i+b) - 1] = 0: why αi=0\alpha_i = 0 for non-support vectors and how support vectors are identified?
3
Geometric vs functional margin: derive why the margin is 2∥w∥\frac{2}{\Vert w\Vert} and why we normalize the functional margin.
4
Derive f(x)=∑i∈SVαiyixiTx+bf(x) = \sum_{i \in SV} \alpha_i y_i x_i^Tx + b: why is ww a linear combination of support vectors, and what are the train/infer complexities?
5
Why can the dual be kernelized? Which terms in the dual contain only inner products, and where does the primal lack inner products?
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "SVM Margin & Duality"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardMulticlass Strategies: OvR/OvO/SoftmaxNext Card →Soft Margin & Hinge

🔗 More Classic ML Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/ML/card/svm-margin
中文速览与面试要点

SVM 最大间隔与对偶 (SVM Margin & Duality)

定义: SVM 寻找几何间隔最大的分类超平面。线性可分时约束 y_i(w^Tx_i + b) 1 (函数间隔归一), 几何间隔为 2 w , 最大化它等价于最小化 12 w ^2。引入拉格朗日乘子 _i 0 得 L(w, b, ) = 12 w ^2 - _i=1^n _i [y_i(w^Tx_i + b) - 1], 对 w, b 求导得 w = _i _i y_i x_i 与 _i _i y_i = 0, 代回得对偶问题 _ _i _i - 12 _i,j _i _j y_i y_j x_i^Tx_j s.t. _i 0,\ _i _i y_i = 0。KKT 互补松弛条件 _i[y_i(w^Tx_i + b) - 1] = 0: 只有落在间隔边界上 (即满足 y_i(w^Tx_i+b) = 1) 的样本 _i > 0, 其余样本 _i = 0——这些非零乘子对应的样本就是支持向量, 决策面 f(x) = _i SV _i y_i x_i^Tx + b 只由它们决定。 使用场景: 经典白板题“推导 SVM 对偶”与“为什么只有支持向量起作用”; 是理解核技巧 (对偶中的内积 x_i^Tx_j 被核函数替换) 的前置。 解决的问题: 原问题是带不等式约束的凸二次规划 (KKT 条件充分必要); 拉格朗日对偶把它转化为只依赖样本内积 x_i^Tx_j 的问题——内积可被核替换从而实现隐式高维映射 (核技巧), 且互补松弛把模型压缩为 n_SV 个支持向量的加权和: 训练存储 O(n_SV d), 推理每个新样本只需与支持向量做内积, 复杂度与全部训练样本解耦。

核心要点

  • 白板推导 SVM 对偶: 写出 L = 12 w ^2 - _i _i[y_i(w^Tx_i + b) - 1], 求 w, b 偏导代回, 写出完整对偶目标与约束。
  • KKT 互补松弛 _i[y_i(w^Tx_i+b) - 1] = 0 的几何含义: 为什么非支持向量的 _i = 0, 支持向量如何被识别?
  • 几何间隔与函数间隔的区别: 推导间隔为什么是 2 w , 为什么要把函数间隔归一化?
  • 推导决策面为什么是 f(x) = _i SV _i y_i x_i^Tx + b: w 为什么是支持向量的线性组合, 训练/推理复杂度各是多少?
  • 为什么对偶问题能被核技巧利用? 对偶目标中哪些项只含内积, 原问题哪个地方没有内积?