Download presentation
Presentation is loading. Please wait.
Published byMarvin Dickerson Modified over 8 years ago
1
Classifiers Given a feature representation for images, how do we learn a model for distinguishing features from different classes? Zebra Non-zebra Decision boundary
2
Classifiers Given a feature representation for images, how do we learn a model for distinguishing features from different classes? Today: Nearest neighbor classifiers Linear classifiers: support vector machines Later: Boosting Decision trees and forests Deep neural networks (hopefully)
3
Review: Nearest Neighbor Classifier
4
Assign label of nearest training data point to each test data point from Duda et al.
5
Review: K-Nearest Neighbors For a new point, find the k closest points from training data Labels of the k points “vote” to classify k = 5
6
Distance functions for bags of features Euclidean distance: L1 distance: χ 2 distance: Histogram intersection (similarity): Hellinger kernel (similarity):
7
Review: Linear classifiers
8
Find linear function (hyperplane) to separate positive and negative examples Which hyperplane is best?
9
Support vector machines Find hyperplane that maximizes the margin between the positive and negative examples C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and Knowledge Discovery, 1998A Tutorial on Support Vector Machines for Pattern Recognition
10
Support vector machines Find hyperplane that maximizes the margin between the positive and negative examples Margin Support vectors C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and Knowledge Discovery, 1998A Tutorial on Support Vector Machines for Pattern Recognition Distance between point and hyperplane: For support vectors, Therefore, the margin is 2 / ||w||
11
Finding the maximum margin hyperplane 1.Maximize margin 2 / ||w|| 2.Correctly classify all training data: Quadratic optimization problem: C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and Knowledge Discovery, 1998A Tutorial on Support Vector Machines for Pattern Recognition
12
Finding the maximum margin hyperplane Solution: C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and Knowledge Discovery, 1998A Tutorial on Support Vector Machines for Pattern Recognition Learned weight (nonzero only for support vectors)
13
Finding the maximum margin hyperplane Solution: b = y i – w·x i for any support vector Classification function (decision boundary): Notice that it relies on an inner product between the test point x and the support vectors x i Solving the optimization problem also involves computing the inner products x i · x j between all pairs of training points C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and Knowledge Discovery, 1998A Tutorial on Support Vector Machines for Pattern Recognition
14
What if the data is not linearly separable? Separable: Non-separable: C: tradeoff constant, ξ i : slack variable (positive) Whenever margin is ≥ 1, ξ i = 0 Whenever margin is < 1,
15
What if the data is not linearly separable? Maximize margin Minimize classification mistakes
16
What if the data is not linearly separable? Demo: http://cs.stanford.edu/people/karpathy/svmjs/demohttp://cs.stanford.edu/people/karpathy/svmjs/demo Margin +1 0
17
Datasets that are linearly separable work out great: But what if the dataset is just too hard? We can map it to a higher-dimensional space: 0x 0 x 0 x x2x2 Nonlinear SVMs Slide credit: Andrew Moore
18
Φ: x → φ(x) Nonlinear SVMs General idea: the original input space can always be mapped to some higher-dimensional feature space where the training set is separable: Slide credit: Andrew Moore
19
Nonlinear SVMs The kernel trick: instead of explicitly computing the lifting transformation φ(x), define a kernel function K such that K(x, y) = φ(x) · φ(y) (to be valid, the kernel function must satisfy Mercer’s condition) This gives a nonlinear decision boundary in the original feature space: C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining and Knowledge Discovery, 1998A Tutorial on Support Vector Machines for Pattern Recognition
20
Nonlinear kernel: Example Consider the mapping x2x2
21
Polynomial kernel:
22
Gaussian kernel Also known as the radial basis function (RBF) kernel: The corresponding mapping φ(x) is infinite- dimensional!
23
Gaussian kernel SV’s
24
Gaussian kernel Also known as the radial basis function (RBF) kernel: The corresponding mapping φ(x) is infinite- dimensional! What is the role of parameter σ ? What if σ is close to zero? What if σ is very large?
25
Kernels for bags of features Histogram intersection kernel: Hellinger kernel: Generalized Gaussian kernel: D can be L1, Euclidean, χ 2 distance, etc. J. Zhang, M. Marszalek, S. Lazebnik, and C. Schmid, Local Features and Kernels for Classifcation of Texture and Object Categories: A Comprehensive Study, IJCV 2007Local Features and Kernels for Classifcation of Texture and Object Categories: A Comprehensive Study
26
Summary: SVMs for image classification 1.Pick an image representation (in our case, bag of features) 2.Pick a kernel function for that representation 3.Compute the matrix of kernel values between every pair of training examples 4.Feed the kernel matrix into your favorite SVM solver to obtain support vectors and weights 5.At test time: compute kernel values for your test example and each support vector, and combine them with the learned weights to get the value of the decision function
27
What about multi-class SVMs? Unfortunately, there is no “definitive” multi- class SVM formulation In practice, we have to obtain a multi-class SVM by combining multiple two-class SVMs One vs. others Traning: learn an SVM for each class vs. the others Testing: apply each SVM to test example and assign to it the class of the SVM that returns the highest decision value One vs. one Training: learn an SVM for each pair of classes Testing: each learned SVM “votes” for a class to assign to the test example
28
SVMs: Pros and cons Pros Many publicly available SVM packages: http://www.kernel-machines.org/software http://www.kernel-machines.org/software Kernel-based framework is very powerful, flexible SVMs work very well in practice, even with very small training sample sizes Cons No “direct” multi-class SVM, must combine two-class SVMs Computation, memory –During training time, must compute matrix of kernel values for every pair of examples –Learning can take a very long time for large-scale problems
29
SVMs for large-scale datasets Efficient linear solvers LIBLINEAR, PEGASOSLIBLINEARPEGASOS Explicit approximate embeddings: define an explicit mapping φ(x) such that φ(x) · φ(y) approximates K(x, y) and train a linear SVM on top of that embedding Random Fourier features for the Gaussian kernel (Rahimi and Recht, 2007) Embeddings for additive kernels, e.g., histogram intersection (Maji et al., 2013, Vedaldi and Zisserman, 2012)
30
Summary: Classifiers Nearest-neighbor and k-nearest-neighbor classifiers Support vector machines Linear classifiers Margin maximization Non-separable case The kernel trick Multi-class SVMs Large-scale SVMs Of course, there are many other classifiers out there Neural networks, boosting, decision trees/forests, …
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.