SMV 3
SMV 3
Neil Zhang
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 2
Optimal margin classifier
Objective function
Derive on blackboard
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 4
Sensitive to outliers
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 5
Soft margin classification
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 7
Summary of linear SVM classifier
Find the maximized margin between two classes
https://scikit-learn.org/stable/modules/generated/sklearn
.svm.LinearSVC.html
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 8
Non-linearly separable
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 9
Adding polynomial features
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 10
How we handle non-linearity?
Feature mapping
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 11
Inner product is computationally expensive
To solve the optimization problem, we need to calculate the dot products of the
transformed features.
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 12
Kernel trick
Get the same result without adding the polynomial features.
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 13
An example kernel
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 14
Why applying kernel trick is better?
Reduce computational complexity
In this case,
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 15
Test a kennel is valid or not
Find the underlying transformation
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 16
Polynomial kernel
degree-M polynomials
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 17
Gaussian Radial Basis Function (RBF) Kernel
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 18
Gaussian kernel has infinite dimensionality
Taylor’s series expansion
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 19
Gaussian RBF kernel trick
More regularized Less regularized
Underfitting Overfitting
Less regularized
Overfitting
(Figure from Géron figure 5-9) 20
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023
Summary: Why SVM?
Optimal margin classifier
Note: Kernel trick is not limited to SVM, it can be applied to any algorithm
that involves inner products.
https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 21
Question
● Can an SVM classifier output a confidence score when it classifies an
instance? What about a probability?
● An SVM classifier can output the distance between the test instance
and the decision boundary, and you can use this as a confidence
score. However, this score cannot be directly converted into an
estimation of the class probability.
● If you set probability=True when creating an SVM in Scikit-Learn,
then after training it will calibrate the probabilities using Logistic
Regression on the SVM’s scores (trained by an additional five-fold
cross-validation on the training data).
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 22
Some concepts we did not cover
Representer theorem
Lagrange duality
Karush–Kuhn–Tucker conditions
Dual form
Gram matrix
Support Vector Machine, ECE 208/408 - The Art of Machine Learning, Spring 2023 23