Back to Classic ML Mind Map
中文·English
📊 Classic MLID: soft-margin

Soft Margin & Hinge

软间隔 C 与 Hinge
🎯Core Definition
when data are not linearly separable, the hard margin (requiring yi(wTxi+b)1y_i(w^Tx_i + b) \ge 1) is infeasible. The soft margin introduces slack variables ξi0\xi_i \ge 0 allowing violations at a linear penalty: minw,b,ξ12w2+Ci=1nξi\min_{w,b,\xi} \frac{1}{2}\Vert w\Vert^2 + C\sum_{i=1}^{n}\xi_i s.t. yi(wTxi+b)1ξiy_i(w^Tx_i + b) \ge 1 - \xi_i. Eliminating ξi\xi_i gives the equivalent unconstrained form minw12w2+Cimax(0,1yif(xi))\min_w \frac{1}{2}\Vert w\Vert^2 + C\sum_i \max(0, 1 - y_i f(x_i)), where the hinge loss max(0,1yf(x))\max(0, 1 - y f(x)) is a convex upper bound on the 0-10\text{-}1 loss and has zero gradient once yf(x)1y f(x) \ge 1. The hyperparameter CC trades margin width against misclassification penalty: CC \to \infty recovers the hard margin (zero tolerance, overfits), C0C \to 0 ignores mistakes (maximum margin, underfits).
💡Use Cases
interview comparisons of hinge vs log loss, the bias-variance reading of CC, and how the dual constraint changes from αi0\alpha_i \ge 0 to 0αiC0 \le \alpha_i \le C.
Key Problems Solved
a single outlier can completely redraw a hard-margin boundary; the hinge's linear penalty makes the boundary robust — it only penalizes samples inside the margin (yf(x)<1y f(x) < 1) and gives zero gradient to correct high-confidence ones (yf(x)1y f(x) \ge 1), a sparsity the log loss (which penalizes everything continuously) lacks. The dual stays convex QP with only the box constraint 0αiC0 \le \alpha_i \le C, so the kernel trick applies unchanged — support vectors split into on-margin (0<αi<C0 < \alpha_i < C) and inside-margin (αi=C\alpha_i = C) types.
🎯5 High-Frequency Exam Points
1
Whiteboard the soft-margin objective: min12w2+Ciξi\min \frac{1}{2}\Vert w\Vert^2 + C\sum_i \xi_i s.t. yi(wTxi+b)1ξi,ξi0y_i(w^Tx_i+b) \ge 1 - \xi_i, \xi_i \ge 0, then eliminate ξ\xi to reach the hinge form.
2
Properties of hinge max(0,1yf(x))\max(0, 1-yf(x)): why it is a convex upper bound on 0-10\text{-}1 loss, why gradient vanishes for yf(x)1yf(x) \ge 1, and how the non-differentiable point is handled.
3
Bias-variance tradeoff of CC: behavior as CC \to \infty vs C0C \to 0, and how to choose CC via cross-validation.
4
Derive the box constraint 0αiC0 \le \alpha_i \le C in the soft-margin dual (eliminating the slack multipliers) and the meaning of the two support-vector types.
5
Hinge vs log loss: why is the SVM solution sparse but not LR's? How do they differ on probability output, outliers and overlapping distributions?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Soft Margin & Hinge"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardSVM Margin & DualityNext CardKernel Trick & RBF

🔗 More Classic ML Knowledge Cards

AdaBoost DerivationBagging & Random ForestBaum-Welch (HMM EM)GBDT Negative Gradient