How to understand the functional margin in SVM ?
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
Support Vector Machines (SVM) are powerful supervised learning models used for classification and regression tasks. One of the core concepts within SVM is the margin, which quantifies the distance between the decision boundary (hyperplane) and the nearest data points. Understanding the functional margin is crucial because it drives the optimization that determines the SVM model.
What Is the Functional Margin?
The functional margin measures the confidence of the classification made by the separating hyperplane. A larger functional margin means the data point is farther from the decision boundary and classified more confidently.
Mathematical Formulation
In a binary classification problem with labels , let:
- be the feature vector of data point
- be the normal vector to the hyperplane
- be the bias term
The hyperplane is defined by all points satisfying .
For a data point with label , the functional margin is:
Here, is the dot product between the normal vector and the feature vector. The term gives a signed distance from the point to the hyperplane (scaled by ). Multiplying by the true label ensures that correct classifications yield a positive margin.
Interpreting the Functional Margin
- Positive margin (): The point is classified correctly. The larger the value, the more confidently the point sits on the correct side of the boundary.
- Negative margin (): The point is misclassified. It lies on the wrong side of the hyperplane.
- Zero margin (): The point lies exactly on the decision boundary.
The Problem with Functional Margin: Scale Sensitivity
The functional margin has a critical flaw: it is not scale-invariant. If you multiply and by a constant , the functional margin scales by as well:
This means you can make the functional margin arbitrarily large without actually changing the hyperplane or improving classification. To fix this, SVM uses the geometric margin.
Geometric Margin
The geometric margin normalizes the functional margin by the norm of :
This gives the true Euclidean distance from the data point to the hyperplane, which is invariant to scaling of and . The SVM optimization objective is to maximize the minimum geometric margin across all training points:
The constraint is a normalization convention. By fixing the functional margin of the closest points to 1, maximizing is equivalent to maximizing the geometric margin.
Worked Example
Consider three data points:
- with label
- with label
- with label
With hyperplane parameters and :
Functional margins:
Interpretation:
- has a negative margin, so it is misclassified.
- also has a negative margin, so it is misclassified.
- has a positive margin of 2.5, so it is correctly classified with good confidence.
Geometric margins (with ):
Summary
| Concept | Formula | Key Property |
| Functional Margin | Scale-dependent | |
| Geometric Margin | Scale-invariant | |
| SVM Objective | s.t. | Maximizes geometric margin |
The functional margin captures classification confidence but is sensitive to the scale of the weight vector. The geometric margin corrects for this by normalizing. SVM's optimization maximizes the geometric margin by convention fixing the minimum functional margin to 1, which leads to the elegant formulation of finding the weight vector with minimum norm that correctly separates the data.
Related reading
- How to understand the output of Topic Model class in Mallet?
- How to understand the term tensor in TensorFlow?
- How to understand the term tensor in TensorFlow?
- How to understand this LSTM example?
- How to update an SVM model with new data
- How to update Logistic Regression Model?
- How to update model parameters with accumulated gradients?
- How to update Spark MatrixFactorizationModel for ALS
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.