Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

SVM: Linear

Support Vector Machine
A classification algorithm that finds the best boundary to separate two classes (−1,1-1,1) by maximizing the distance to the closest observations.
Loading...
  • Observations that are included within the dashed lines are called as support vectors.

DescriptionFormula
Equation for a line in two dimensions(β0+β1x1+β2x2)=0(\beta_0 + \beta_1 x_1 + \beta_2 x_2) = 0
Equation for a hyperplane(β0+β1x1+⋯+βpxp)=0(\beta_0 + \beta_1 x_1 + \cdots + \beta_p x_p) = 0
Observations above the hyperplane(β0+β1x1+⋯+βpxp)>0(\beta_0 + \beta_1 x_1 + \cdots + \beta_p x_p) > 0
Observations below the hyperplane(β0+β1x1+⋯+βpxp)<0(\beta_0 + \beta_1 x_1 + \cdots + \beta_p x_p) < 0
yi∈{−1,1},i=1,...ny_i \in \{-1,1\}, i=1,...n
  • Observations below the hyperplane are classified as y=(−1)y=(-1).

  • Observations above the hyperplane are classified as y=(+1)y=(+1).

  • Since yy is either {−1,1}\{-1, 1\}, y(β0+β1x1+...βpxp)y(\beta_0 + \beta_1x_1 + ... \beta_px_p) is positive for correctly classified observations, negative for misclassified observations, and zero on the boundary.

  • For every correctly classified observation, this statement holds: y(β0+β1x1+...βpxp)≥0y(\beta_0 + \beta_1x_1 + ... \beta_px_p) \geq 0.

    • This can be redefined with a margin, MM, such that: y(β0+β1x1+...βpxp)≥My(\beta_0 + \beta_1x_1 + ... \beta_px_p) \geq M.

    • MM is the distance of the line to the closest observation.

Linearly Separable

Maximum Margin Classifier

max⁡β0,β1,…,βp,  MMsubject to{∑j=1pβj2=1,yi(β0+β1xi1+⋯+βpxip)≥M,i=1,…,n.\begin{aligned} \max_{\beta_0,\beta_1,\ldots,\beta_p,\; M}\quad & M \\ \text{subject to}\quad & \left\{ \begin{aligned} \sum_{j=1}^{p} \beta_j^{2} &= 1, \\ y_i\left(\beta_0 + \beta_1 x_{i1} + \cdots + \beta_p x_{ip}\right) &\ge M, \quad i=1,\ldots,n. \end{aligned} \right. \end{aligned}
where M>0 is the margin, p is the number of x-variables, and\text{where } M > 0 \text{ is the margin, } p \text{ is the number of } x \text{-variables, and}
j is the index for each feature.j \text{ is the index for each feature}.
yi∈−1,1,i=1,...,ny_i \in {-1,1}, i=1,...,n
  • y(β0+β1x1+...βpxp)≥My(\beta_0 + \beta_1x_1 + ... \beta_px_p) \geq M implies no errors.

  • max⁡β0,β1,…,βp,  M\max_{\beta_0,\beta_1,\ldots,\beta_p,\; M} implies to find the hyperplane that gives the largest possible margin MM between the two classes.

    • These coefficients, β\beta, should give the largerst possible margin MM.

    • Noramlization of β\beta controls the margin width.

Normalization
Fixing the scale of the β\beta vector so that it has a specific length.
∥β∥=β12+β22+...+βp2\| \beta \| = \sqrt{\beta^2_1+\beta^2_2+...+\beta^2_p}
  • By notating ∑j=1pβj2=1\sum_{j=1}^{p} \beta_j^{2} = 1, the coefficient scale is fixed to 1. Can also be written as ∥β∥=1\|\beta\| = 1.

  • Ensure that the constraint on β\beta is met by dividing by the norm.

1∥β∥yi(β0+β1x1+...βpxp)≥M\frac{1}{\|\beta\|}y_i(\beta_0 + \beta_1x_1 + ... \beta_px_p) \geq M
∥1∥β∥(β1β2⋮β3)∥=1∥β∥∥(β1β2⋮β3)∥=1∥β∥ ∥β∥=1\left\| \frac{1}{\|\beta\|} \begin{pmatrix} \beta_1\\ \beta_2\\ \vdots\\ \beta_3 \end{pmatrix} \right\| = \frac{1}{\|\beta\|} \left\| \begin{pmatrix} \beta_1\\ \beta_2\\ \vdots\\ \beta_3 \end{pmatrix} \right\| = \frac{1}{\|\beta\|}\,\|\beta\| = 1

This proves that when you normalize β\beta, the result has length 1.

yi(β0+β1x1+...βpxp)≥M∥β∥y_i(\beta_0 + \beta_1x_1 + ... \beta_px_p) \geq M\|\beta\|
  • β\beta can be multiplied by any positive constant, cc, because both sides will scale equally. The actual values of β\beta don’t uniquely matter, only their ratios do.

Formula Rearrangements

1∥β∥yi(β0+β1x1+...βpxp)≥M\frac{1}{\|\beta\|}y_i(\beta_0 + \beta_1x_1 + ... \beta_px_p) \geq M
  • This is the original form that maximizes margin MM, while keeping β\beta a unit vector. It is hard to optimize because of the ∥β∥=1\|\beta\|=1 constraint.

min⁡βj,j=1,…,p1Msubject toyi(β0+xiTβ)≥M,∥β∥=1\min_{\beta_j, j=1,\ldots,p} \frac{1}{M} \quad \text{subject to} \quad y_i(\beta_0 + x_i^T\beta) \geq M, \quad \|\beta\| = 1
  • Subject to: “Under the condition that...” Hence, Find the β\beta that makes ∥β2∥\|\beta^2\| as small as possible, but only consider solutions where every training point is correctly classified with margin ≥1\geq 1.

  • Maimizing MM is the same thing as minimizing 1M\frac{1}{M}.

min⁡βj,j=1,…,p1Msubject toyi(β0+xiTβ)≥M∥β∥\min_{\beta_j, j=1,\ldots,p} \frac{1}{M} \quad \text{subject to} \quad y_i(\beta_0 + x_i^T\beta) \geq M\|\beta\|
  • Drop the ∥β∥\|\beta\| constraint. Absorb the unit norm constraitn into the inequality, and β\beta can be any scale.

  • If we assume M=1∥β∥M=\frac{1}{\|\beta\|},

    min⁡βj,j=1,…,p∥β∥2subject toyi(β0+xiTβ)≥1\min_{\beta_j, j=1,\ldots,p} \|\beta\|^2 \quad \text{subject to} \quad y_i(\beta_0 + x_i^T\beta) \geq 1
  • Minimizing ∥β∥\|\beta\| is the same thing as minimizing ∥β∥2\|\beta\|^2. If ∥β∥\|\beta\| is minimized at some ∥β∗∥\|\beta*\|, then ∥β∥2\|\beta\|^2 is also minimized at the exact point at β∗\beta*.

  • Final optimization for quadratic optimization problem with a linear constant:

    min⁡βj,j=1,…,p12∥β∥2subject toyi(β0+xiTβ)≥1\min_{\beta_j, j=1,\ldots,p} \frac{1}{2}\|\beta\|^2 \quad \text{subject to} \quad y_i(\beta_0 + x_i^T\beta) \geq 1

Geometric margin and coefficient scale

Multiplying both β0\beta_0 and β\beta by the same positive constant does not change the separating hyperplane. The geometric distance of xix_i from it is

∣β0+xiTβ∣∥β∥.\frac{|\beta_0+x_i^T\beta|}{\|\beta\|}.

In the unit-norm formulation, the signed score is already a signed distance. In the canonical formulation, the closest correctly classified points satisfy yi(β0+xiTβ)=1y_i(\beta_0+x_i^T\beta)=1, so the distance to either margin plane is 1/∥β∥1/\|\beta\|. The full width between the two margin planes is 2/∥β∥2/\|\beta\|.

This normalization is why minimizing ∥β∥2/2\|\beta\|^2/2 maximizes the margin. The intercept is optimized too, but it is not included in the norm: shifting the plane does not change the length of its normal vector.

  • To minimizie ∥β∥2\|\beta\|^2 as a constraint, the Lagragian trick merges the objective and constraint into a single expression.

    L=12∥β∥2−∑i=1Nαi[yi(β0+xiTβ)−1]L = \frac{1}{2}\|\beta\|^2 - \sum_{i=1}^{N} \alpha_i\left[y_i(\beta_0 + x_i^T\beta) - 1\right]
TermExpressionMeaning
First term½‖β‖²The original objective you want to minimize
Second term∑αᵢ[yᵢ(β₀ + xᵢᵀβ) - 1]Penalizes violations of the constraint
αᵢLagrange multipliersOne per training point, weights that control how much each constraint matters
L=12(β12+β22+⋯+βp2)−∑i=1Nαi[yi(β0+xiTβ)−1]L = \frac{1}{2}(\beta_1^2 + \beta_2^2 + \cdots + \beta_p^2) - \sum_{i=1}^{N} \alpha_i\left[y_i(\beta_0 + x_i^T\beta) - 1\right]
  • Set derivatives with respect to βj,βo\beta_j, \beta_o to zero (to find a minimum of a function):

βj=∑i=1Nαiyixij;j=1,…,p\beta_j = \sum_{i=1}^{N} \alpha_i y_i x_{ij}; \qquad j = 1, \ldots, p
0=∑i=1Nαiyi0 = \sum_{i=1}^{N} \alpha_i y_i
  • Writing β\beta in vector notation avoiding index jj:

βj=∑i=1Nαiyixij;j=1,…,p\beta_j = \sum_{i=1}^{N} \alpha_i y_i x_{ij}; \qquad j = 1, \ldots, p
⇔β=∑i=1Nαiyixi\Leftrightarrow \beta = \sum_{i=1}^{N} \alpha_i y_i x_i
  • Thus, we know β\beta is a linear combination of the observations.

Lagrange Multiplier
A variable that convers a constrained optimization problem into an unconstriained one.
L=f(x)−α⋅g(x)L = f(x) - \alpha \cdot g(x)
f(x)=Function to minimize,g(x)=constraint,α=Lagrange multiplierf(x) = \text{Function to minimize}, g(x) = \text{constraint}, \alpha = \text{Lagrange multiplier}
α\alpha measures how much the constraint is pushing back against the objective. The larger α\alpha is, more influeential the constraint is.
  • In the hard-margin formulation, only observations on a margin plane can have αi>0\alpha_i>0.

  • Observations strictly beyond the margin planes have αi=0\alpha_i=0.

Kuhn-Tucker Condition
Rules that the optimal solution must satisfy when you have an optimization problem with inequality constraints.
To optimize max⁡xf(x)\max_xf(x), subject to g(x)≤0\text{subject to } g(x) \leq 0,
If x∗x* is a local optimum, subject to regularity conditions, then there exist a constant multiplier αi\alpha_i such that,
g(x∗)≤0g(x*) \leq 0
αi≥0\alpha_i \geq 0
αi⋅g(x∗)=0∀i\alpha_i \cdot g(x*) = 0 \qquad \forall i
Complementary Slackness
αi[ yi(β0+xi⊤β)−1 ]=0,∀i\alpha_i \big[\, y_i(\beta_0 + x_i^{\top}\beta) - 1 \,\big] = 0, \qquad \forall i
  • Stemming from αi⋅g(x∗)=0\alpha_i \cdot g(x*) = 0, complementary so that the two terms complement each other to make zero. At least one factor must be zero; both can be zero.

  • A point xix_i is on the boundary if [ yi(β0+xi⊤β)−1 ]=0\big[\, y_i(\beta_0 + x_i^{\top}\beta) - 1 \,\big] = 0.

  • Also, if αi>0\alpha_i > 0, then xix_i is on the boundary. If xix_i is not on the boundary, then ai=0a_i = 0.

Beta Optimization

β=∑i=1Nαiyixi=∑i∈Sαiyixiwhere S=set of support vectors.\begin{align} \beta &= \sum_{i=1}^{N} \alpha_i y_i x_i \\ &= \sum_{i \in S} \alpha_i y_i x_i \\ & \text{where } S = \text{set of support vectors.} \end{align}

Hence, this proves that estimation of β\beta is only dependent on support vectors.

Not Linearly Separable

  • In cases like this, two classes are not completely separable.

maximize⁡βij,ϵi,i=1,…,n;j=1,…,pM\operatorname{maximize}_{\beta_{ij}, \epsilon_i, i=1,\ldots,n; j=1,\ldots,p} \quad M
subject to{∑j=1pβj2=1yi(β0+β1xi1+⋯+βpxip)≥M(1−ϵi)ϵi≥0;∑i=1nϵi≤C\text{subject to} \begin{cases} \displaystyle\sum_{j=1}^{p} \beta_j^2 = 1 \\[10pt] y_i(\beta_0 + \beta_1 x_{i1} + \cdots + \beta_p x_{ip}) \geq M(1 - \epsilon_i) \\[10pt] \epsilon_i \geq 0; \quad \displaystyle\sum_{i=1}^{n} \epsilon_i \leq C \end{cases}
  • Non-linearly separable classess can be managed with some errors. This is the slack variables, or ϵi\epsilon_i.

  • All observations between the margin, and the separating hyperplane, and all misclassified observations (on the other side of the separating hyperplane) have a positive ϵi>0\epsilon_i > 0.

  • Errors, ϵi\epsilon_i, of the correctly classified observations before the margin is 0.

Error Limit

  • The sum of ϵi\epsilon_i cannot exceed CC.

  • CC is the tuning parameter; the cost parameter.

    • Larger CC value allows for more error and have larger margins. Also correspond to more support vectors because more observations lie within the larger margins.

Two meanings of CC

Above, CC is a budget in ∑iϵi≤C\sum_i\epsilon_i\leq C. Increasing that budget permits more total margin violation. Another common formulation uses CC as a penalty coefficient:

min⁡β0,β,ξ12∥β∥2+C∑iξi,\min_{\beta_0,\beta,\xi}\frac12\|\beta\|^2+C\sum_i\xi_i,
yi(β0+xiTβ)≥1−ξi,ξi≥0.y_i(\beta_0+x_i^T\beta)\geq1-\xi_i,\qquad \xi_i\geq0.

Here, larger CC makes violations more expensive, so its direction is opposite to the budget convention. Always check the objective before interpreting the tuning parameter.

For the smallest feasible slack, ξi=max⁡(0,1−yif(xi))\xi_i=\max(0,1-y_if(x_i)):

  • ξi=0\xi_i=0: on or beyond the correct margin plane.

  • 0<ξi<10<\xi_i<1: correctly classified but inside the margin.

  • ξi=1\xi_i=1: on the decision boundary.

  • ξi>1\xi_i>1: misclassified.

In this penalty formulation, the dual coefficients satisfy 0≤αi≤C0\leq\alpha_i\leq C. A point with 0<αi<C0<\alpha_i<C lies on a margin plane; points inside the margin can have αi=C\alpha_i=C. Support vectors therefore need not all lie exactly on the margin in a soft-margin model.

Prediction

sign(β0+β1xi+...+βpxp)\text{sign}(\beta_0 + \beta_1 x_i + ... + \beta_p x_p)
Scoresign()Predicted class
Positive+1Class +1
Negative-1Class -1
Zero0On the boundary
  • How a new observation is being classified is decided by which side of the hyperplane the observation falls on.

  • Mathematically, the sign of the estimated value, sign(f(x)^)\text{sign}(\hat{f(x)}), determines whether the observation is classified as +1 or -1, where:

f^(x)=β0^+β1^x1+...+βp^xp\hat{f}(x) = \hat{\beta_0} + \hat{\beta_1}x_1 +... + \hat{\beta_p}x_p
f^(x)=β0^+∑i∈Sαi^yi⟨x,xi⟩\hat{f}(x) = \hat{\beta_0} + \sum_{i \in S} \hat{\alpha_i}y_i\langle x,x_i\rangle
  • where <..,..><.. , ..> is the inner dot product, αi^>0,i=1,...n\hat{\alpha_i} > 0, i=1,...n is the estimated coefficients arising during optimization.

    K(x,xi)=∑j=1pxjxijK(x, x_i) = \sum_{j=1}^p x_jx_{ij}
  • The dot product is a similarity measure affected by both direction and magnitude, where xix_i is an observation from training data and xx is an observation from test data.


SVM: Kernels

  • Add quadratic derived variables, so that the linear separation becomes possible in an expanded space, but it is still nonlinear in the original space.

  • In the original space (Assume we have x1,x2x_1, x_2), classes may not be separable.

  • Add new features like x12,x22,x1x2x_1^2, x_2^2, x_1x_2 and now we’re in the high dimensional, expanded space. In this space, a linear boundary may separate patterns that could not be separated in the original coordinates.

  • But when you project that boundary back to the original space, it looks nonlinear.

max⁡β0,{βj1,βj2}j=1p,{ϵi}i=1n, M  Msubject to{∑j=1p(βj12+βj22)=1,yi(β0+∑j=1pβj1xij+∑j=1pβj2xij2)≥M(1−ϵi),i=1,…,n,ϵi≥0,i=1,…,n,∑i=1nϵi≤C.\max_{\beta_0,\{\beta_{j1},\beta_{j2}\}_{j=1}^p,\{\epsilon_i\}_{i=1}^n,\, M}\; M \quad \text{subject to} \quad \left\{ \begin{aligned} \sum_{j=1}^{p}\left(\beta_{j1}^{2}+\beta_{j2}^{2}\right) &= 1, \\ y_i\left(\beta_0+\sum_{j=1}^{p}\beta_{j1}x_{ij}+\sum_{j=1}^{p}\beta_{j2}x_{ij}^{2}\right) &\ge M(1-\epsilon_i), \quad i=1,\ldots,n, \\ \epsilon_i &\ge 0,\quad i=1,\ldots,n, \\ \sum_{i=1}^{n}\epsilon_i &\le C. \end{aligned} \right.
  • Adding nonlinearities in xx.

  • The original feature space has pp variables, but expanded feature spaces have 2∗p2*p variables.

  • SVM is a linear method in the expanded features space.

  • SVM accommodates nonlinearity in the original feature space.

Kernels
A function that computes the similarity between two points in a higher dimensional space, without actually going there. Instead of expanding to high dimensions (which can be slow), directly computes what the dot product in that high dimensional space would have been.
K(xi,xj)=⟨ϕ(xi),ϕ(xj)⟩K(x_i, x_j) = \langle \phi(x_i), \phi(x_j) \rangle
where ϕ= transformation to high dimensions.\text{where } \phi = \text{ transformation to high dimensions.}
  • How kernels expand feature space is not obvious.

Predictions

  • From β^=∑i∈Sai^yixu\hat{\beta} = \sum_{i \in S} \hat{a_i}y_ix_u, the predicted value is:

f^(x)=β^0+β^tx=β^0+(∑i∈Sα^i yi xi)tx\begin{aligned} \hat{f}(x) &= \hat{\beta}_0 + \hat{\beta}^t x \\ &= \hat{\beta}_0 + \left(\sum_{i \in S} \hat{\alpha}_i\, y_i\, x_i\right)^tx \end{aligned}
SymbolTypeMeaning
xix_iVectorTraining data (feature vector for observation ii)
xxVectorA new vector that we want to predict
yiy_iScalarClass label (+1 or -1)
αi\alpha_iScalarLagrange multipliers arising during optimization
SSIndex setIndices of support vectors

Can be re-written as:

f^(x)=β^0+∑i∈Sα^i yi ⟨x,xi⟩\hat{f}(x) = \hat{\beta}_0 + \sum_{i \in S} \hat{\alpha}_i\, y_i \,\langle x, x_i \rangle
⟨xi,xi′⟩=∑j=1pxij xi′j\langle x_i, x_{i'} \rangle = \sum_{j=1}^{p} x_{ij}\,x_{i'j}

The solution depends only on the inner product of the observations, not on the observations themselves.

Non-Linear Expansion
  • Rather than adding quadratic terms to the xx-variables, it is possible to expand the feature space as a function of the original xx-variables.

f^(x)=β0^+∑i∈Sαi^yi ⟨h(x),h(xi)⟩\hat{f}(x) = \hat{\beta_0} + \sum_{i \in S} \hat{\alpha_i}y_i \space \langle h(x), h(x_i) \rangle
where h(x)= derived variable\text{where } h(x) = \text{ derived variable}
h(x)=(hi(x),h2(x),...,hpnew(x))h(x) = (h_i(x), h_2(x),...,h_{p_{new}}(x))

Can be re-written as:

f^(x)=β^0+∑i∈Sα^i yi ⟨h(x),h(xi)⟩=β^0+∑i∈Sα^i yi K(x,xi)\begin{aligned} \hat{f}(x) &= \hat{\beta}_0 + \sum_{i \in S} \hat{\alpha}_i\, y_i \,\langle h(x), h(x_i) \rangle \\ &= \hat{\beta}_0 + \sum_{i \in S} \hat{\alpha}_i\, y_i \, K(x, x_i) \end{aligned}

where K= Kernel function\text{where } K = \text{ Kernel function}
Linear Kernel
K(x,xi)=∑j=1pxjxijK(x, x_i) = \sum_{j=1}^p x_jx_{ij}
  • Referes to the standard SVM without any additional xx-variables.

  • Has no additonal tuning parameters.

  • Often preferred in text mining applications with nn-gram variables.

    • Sparse matrices and indicator variables.

Polynomial Kernel
K(xi,xi′)=(β0+γ∑j=1pxij xi′j)dK(x_i, x_{i'}) = \left(\beta_0 + \gamma \sum_{j=1}^{p} x_{ij}\,x_{i'j}\right)^{d}
where d= Degree of polynomial\text{where } d = \text{ Degree of polynomial}
  • Tuning parameters: β0,γ0,d (d>0)\beta_0, \gamma_0, d \space (d > 0).

    • In practice, often set β0=0,d=2 or 3 and tune γ and C\beta_0 = 0, d = 2 \text{ or } 3 \text{ and tune } \gamma \text{ and } C

RBF Kernel
  • Also called as Gaussian Kernel.

    K(xi,xi′)=exp⁡ ⁣(−γ∑j=1p(xij−xi′j)2)K(x_i, x_{i'}) = \exp\!\left( -\gamma \sum_{j=1}^{p} \left(x_{ij} - x_{i'j}\right)^2 \right)
  • Tuning parameter: γ>0\gamma > 0.

    • γ\gamma determines how fast the influence of neighboring observations on the classification of the test observation drops off as a function of distance. Larger γ\gamma leads to a local fit.

  • xi′xi' is a test observation.

  • When a test observation is very far from training observation, the kernel value approaches 0 as the exponent becomes increasingly negative.

    • Training observations far from test observation contribute very little to classification.

  • Most popular choice.

  • Corresponds to an infinite number of xx-variables.

Interpreting γ\gamma together with CC

For the RBF kernel, two observations a distance dd apart have similarity e−γd2e^{-\gamma d^2}. At d=0d=0, it is 1; as distance grows, the kernel value approaches 0. Larger γ\gamma makes each observation’s influence more local.

A large γ\gamma and a large penalty-form CC can give a highly irregular boundary. A small γ\gamma makes similarities vary more slowly, but its effect still depends on CC and the scaled distances. Tune them together using validation folds, fitting the scaling transformation within each fold.

A nonlinear feature map makes more boundaries available; it does not guarantee that every dataset becomes separable. Two observations with identical predictors and opposite labels remain indistinguishable under any deterministic feature map.

Sigmoid Kernel
K(xi,xi′)=tanh⁡ ⁣(β0+γ∑j=1pxijxi′j)K(x_i, x_{i'}) = \tanh\!\left(\beta_0 +\gamma \sum_{j=1}^{p} x_{ij}x_{i'j} \right)
  • Tuning parameters: γ>0,β\gamma > 0, \beta.

  • Not commonly used because of some undesirable theoretical properties.

KernelWhen to use
LinearData is already high dimensional (e.g. text, genomics), large datasets, when you suspect linear separability
PolynomialWhen you believe feature interactions matter, image recognition
RBF/GaussianDefault choice, when you have no prior knowledge, works well in most cases
SigmoidRarely used, sometimes in neural network contexts

Platt’s Method

Platt Scaling
A method to convert SVM’s raw decision scores into probabilities.
  • Since logistic regression computes a probability which is rounded up or down for classification, SVM yield a score.

    • Positive scores: the uncalibrated decision rule predicts y=+1y=+1.

    • Negative scores: the uncalibrated decision rule predicts y=−1y=-1.

      score=f^(x)=β0^+∑i∈Sαi^yiK(x,xi)\text{score} = \hat{f}(x) = \hat{\beta_0} + \sum_{i \in S} \hat{\alpha_i}y_iK(x, x_i)

Converting Scores into Probabilities

  • This is Platt’s way of estimating probabilities based on the score.

  • If a probability is needed, we can use logistic regression on the score:

    log⁡p1−p=β0+β1f^(x)\log \frac{p}{1-p} = \beta_0 + \beta_1 \hat{f}(x)
  • The probabilities can be estimated as usual by solving for pp.

Fitting the calibration step

The decision score gives a side of the boundary and a margin-related magnitude. A score of 2 does not mean a probability of 0.88 unless a particular fitted calibration map makes it so.

Fit the sigmoid mapping using held-out scores or out-of-fold predictions, then evaluate it on separate data. Fitting the map to the same in-sample scores used to train the SVM can make probability estimates too optimistic. Calibration can improve the meaning of probabilities without changing the underlying ordering when the fitted map is increasing.

Multi-Class SVM

  • Typically, SVM only allows for two classes.

  • Can extend two-class classifiers:

1. One vs. All
  • More common.

  • With KK classes, apply SVM once for each class.

    • Class kk vs. all remaining claases.

  • Each SVM classifier gives a score f(x)f(x) for class kk (vs. all others.)

  • Predict the class kk that has the highest score f(x)f(x).

2. One vs. One
  • kk classes give (kk choose 2) possible pairs.

  • SVM is conducted on each pair.

  • Keep track of which class wins each time.

  • Predict the class with the most wins.

Usage

  • Works well with large feature numbers.

  • Works well when number of features exceeds the number of observations.

  • Memory efficient for prediction, because only support vectors are needed.

Limitations

  • When the dataset is large, training time can be very long.

  • For nonlinear kernels, you may encounter convergence problems.

  • Does not work as well in the presence of a lot of noise variables.

  • Probability estimates are ad-hoc.

  • SVM is sensitive to scaling of xx-variables.