Adapted from an appendix of my MS thesis.
Support Vector Machine
The support vector machine (SVM) solves the binary classification task. It is a supervised learning task where we have a set of examples along with their corresponding binary labels . Given a training set we would like to estimate parameters of the model that will give the smallest classification error. In the case of binary classification, we divide the vector space into two parts corresponding to the positive and negative classes. In the following we consider a particularly convenient partition, which is to linear split the space using a hyperplane [1].
Separating Hyperplane
Let example be an element of the data space, and consider a function parameterized by and [1].
We define the hyperplane that separates the two classes in our binary classification problem as follows where the vector is normal to the hyperplane and is the intercept [1].
We can derive that is a normal vector to the hyperplane by choosing any two examples and on the hyperplane and showing that the vector between them is orthogonal to . Since we have chosen and to be on the hyperplane, this implies that and and hence . Therefore, we obtain that is orthogonal to any vector on the hyperplane [1].
When presented with a test example, we classify the example as positive or negative depending on the side of the hyperplane on which it occurs. Note that the equation not only defines a hyperplane, it additionally defines a direction. In other words, it defines the positive and negative side of the hyperplane. Geometrically, the positive examples lie above the hyperplane and the negative examples below the hyperplane. When training the classifier, we want to ensure that the examples with positive labels are on the positive side, and the examples with negative labels are on the negative side [1].
Equivalently, these two conditions can be expressed in a single equation [1].
For a dataset that is linearly separable, we have infinitely many candidate hyperplanes, and therefore classifiers, that solve our classification problem without any training error. To find a unique solution, we can choose the separating hyperplane that maximizes margin between the positive and negative examples. In other words, we want the positive and negative examples to be separated by a large margin. For this purpose, we can make use of the fact that the closest point on the hyperplane to a given point is obtained by the orthogonal projection [1].
Consider a hyperplane and an example that is on the positive side of the hyperplane so that . We want to compute the distance of from the hyperplane. We do so by considering the orthogonal projection of onto the hyperplane, which we denote by . Since is orthogonal to the hyperplane we know that the distance is just a scaling of the length of this vector . If the length of is known, then we can use this scaling factor to work out the absolute distance between and . For convenience, we use a vector of unit length [1].
Say that we would like the positive examples to be further than from the hyperplane, and the negative examples to be further than distance in the negative direction from the hyperplane. In other words, we combine the requirements that examples are at least distance away from the hyperplane in the positive and negative directions into one single inequality. Since we are interested only the direction, we add an assumption to our model that the parameter vector is of unit length , where we use the Euclidean norm . This assumption allows a more intuitive interpretation of the distance [1].
Collecting these three requirements into a single constrained optimization problem, we obtain the following objective [1].
Probability Calibration
The SVM is a binary classifier that does not naturally lend itself to a probabilistic interpretation. Platt scaling is one approach to converting the raw output of the linear function into a calibrated class probability estimate that involves an additional calibration step [1]. The idea is to compute , where is the log-odds, or logit, of the SVM scores, and are estimated via maximum likelihood on a validation set, and comes from logistic regression [3].
In other words, for the binary classification case, Platt scaling uses logistic regression on the SVM scores, fit by an additional cross-validation on the training data. The cross-validation involved in Platt scaling is an expensive operation for large datasets [2]. Platt’s method is also known to have theoretical issues. This method can easily overfit resulting in overconfident calibrated probabilities [3].
Naturally, one could take a more Bayesian view of the classifier output by estimating a posterior distribution using Bayesian logistic regression. The Bayesian view also includes the specification of the prior, which includes design choices such as conjugacy with the likelihood. Additionally, one could consider latent functions as priors, which results in Gaussian process classification (a topic for a future post) [1].
References
- Deisenroth, Marc Peter, Faisal, Aldo, Ong, Cheng Soon (2020) Mathematics for Machine Learning. Cambridge University Press.
- Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., Blondel, M., Prettenhofer, P., Weiss, R., Dubourg, V., Vanderplas, J., Passos, A., Cournapeau, D., Brucher, M., Perrot, M., Duchesnay, E. (2011) Scikit-learn: Machine Learning in Python. Journal of Machine Learning Research.
- Kevin P. Murphy (2023) Probabilistic Machine Learning: Advanced Topics. MIT Press.
![Example of an SVM linearly separating two classes of data points by a margin [2].](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frm6q2vs0xcrdts1s8znm.png)



Top comments (0)