0% found this document useful (0 votes)
11 views4 pages

Support Vector Machines Tutorial

The tutorial focuses on Support Vector Machines (SVMs) and includes problems related to linear and nonlinear SVMs, as well as the kernel trick. It requires students to draw decision boundaries, identify support vectors, and analyze separability of data points in different feature spaces. Additionally, it explores feature transformations and the implicit mapping defined by a specific kernel function.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Support Vector Machines Tutorial

The tutorial focuses on Support Vector Machines (SVMs) and includes problems related to linear and nonlinear SVMs, as well as the kernel trick. It requires students to draw decision boundaries, identify support vectors, and analyze separability of data points in different feature spaces. Additionally, it explores feature transformations and the implicit mapping defined by a specific kernel function.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DATA7703 – Machine Learning for Data Scientists S2 -2025

Tutorial – Week 6
Support Vector Machines

The below tutorial problems are meant to be solved using pen and paper.
1) Linear SVMs

a) Suppose we are using a linear SVM (i.e., no kernel), with some large β value, and are given
the following data set.

Draw the decision boundary of a linear SVM and circle the support vectors. Give a brief explanation.

b) In the following image, circle the points such that removing that example from the training set
and retraining SVM, we would get a different decision boundary than training on the full
sample.

c) Circle the points such that removing that example from the training set and retraining SVM,
we would not get a different decision boundary than training on the full sample.

You do not need to provide a formal proof, but give a one or two sentence explanation for b) - c).
Solution:

a) b)
2) Nonlinear SVMs

Consider a supervised learning problem in which the training examples are points in 2-dimensional
space. The positive examples are (1, 1) and (-1,-1). The negative examples are (1,-1) and
(-1,1).

a) Are the positive examples linearly separable from the negative examples in the original
space?

b) Consider the feature transformation (x) = [1, x1, x2, x1x2], where x1 and x2 are, respectively,
the first and second coordinates of a generic example x. The prediction function is
y(x) = wT(x) in this feature space. Give the coefficients, w, of a maximum-margin decision
surface separating the positive examples from the negative examples. (You should be able to
do this by inspection, without any significant computation.)

c) Add one training example to the graph so the total 5 examples can no longer be linearly
separated in the feature space (x) defined in problem b).

d) [optional] What kernel K(x,y) does this feature transformation  correspond to?

Solution:

a) No
b) w=[0 0 0 1]^T (see also slide 29)
c) a + or a – in one of the corners of the above figure
d) K(x,y) = 1+x1y1+x2y2+ x1y1x2y2
3) The Kernel trick

Consider a support vector machine whose input space is R2, and in which the inner products are
computed by means of the kernel

k(x, y) = (x . y +1)2 -1

(bold letters represent vectors in R2 and x . y denotes the ordinary inner (scalar) product in R2 ).

Show that the mapping to feature space that is implicitly defined by this kernel is the mapping to R5
given by

Solution:

Expand (x . y +1)2 -1= (x1y1+x2y2+1)^2 = … = x12y12 + x22y22 + x1x2y1y2 + x1y1 + x2y2

Now expand (x)T(y) using the above definition and the results is equal to the previous line.

Common questions

Powered by AI

Support vectors play a critical role in determining the decision boundary of a linear SVM because they are the data points that lie closest to the decision surface. The position of these supports vectors influences the orientation and the margin of the decision boundary. If a support vector is removed from the training set, it could lead to a different decision boundary .

A feature transformation can affect linear separability by mapping input data to a higher-dimensional space where a linear classifier may separate the data. In the given problem, applying the transformation φ(x) = [1, x1, x2, x1x2] makes the previously inseparable points (1, 1), (-1, -1), (1, -1), and (-1, 1) separable, allowing for a maximum-margin decision boundary with coefficients w = [0, 0, 0, 1]^T .

Removing non-support vector data points from the training set typically does not affect the SVM decision boundary because the boundary is determined by the support vectors only. Non-support vector points lie outside the margin and do not influence where the decision boundary is positioned, remaining unchanged upon their removal .

The kernel trick allows SVMs to compute the inner product of the feature space implicitly without explicitly transforming data into higher dimensions. This is significant because it reduces computational complexity by using kernel functions like k(x, y) = (x . y +1)^2 -1, which can directly compute the dot product in a transformed space, simplifying the calculation and enabling non-linear decision boundaries in the original space .

To expand the kernel function k(x, y) = (x . y +1)^2 -1, we first recognize it as a polynomial expansion: (x1y1 + x2y2 + 1)^2, which simplifies to x1^2y1^2 + x2^2y2^2 + 2x1y1x2y2 + 2x1y1 + 2x2y2 + 1. The removal of the constant 1 at the end leaves a mapping implication that relates to an embedded feature space representing a combination of linear and quadratic terms, mapping the original input space to R5, which can be used for complex boundary finding while avoiding explicit high-dimensional computations .

The feature transformation φ(x) = [1, x1, x2, x1x2] corresponds to the kernel function K(x, y) = 1 + x1y1 + x2y2 + x1y1x2y2. This kernel maps the original data into a higher-dimensional space where complex, nonlinear relationships can be modeled using a linear decision boundary in that transformed space .

Applying a polynomial kernel function like k(x, y) = (x . y +1)^2 -1 can enhance the classification capability of an SVM by allowing it to model more complex decision boundaries. This kernel enables the transformation of nonlinear relationships into a space where a linear classifier can find a maximum-margin separator, capturing interactions and variances in the data that linear kernels cannot .

An additional training example placed at either the position (0, 0) or one of the already defined mean points of separation, like (1, 0), could disrupt the linear separability in the feature space φ(x) = [1, x1, x2, x1x2], since it could equalize contributions to the transformed space where linear separation was achieved .

The positive and negative examples given are not linearly separable in the original 2-dimensional space. This is because no straight line can separate the positive examples (1, 1) and (-1, -1) from the negative examples (1, -1) and (-1, 1), as they form opposite corners of a rectangle .

When a support vector is removed from the training data, the SVM decision boundary may change. This is because support vectors are critical in defining the orientation and position of the boundary, and their removal could alter the margin or cause the SVM to re-evaluate which vectors define the boundary .

You might also like