"SupportVectorMachine" (Machine Learning Method)
- Method for Classify.
- Models class probabilities by finding a hyperplane that separates the training data into two classes using a maximum-margin hyperplane.
Details & Suboptions
- Support vector machines are binary classifiers. A kernel function is used to extract features from the examples. At training time, the method finds the maximum-margin hyperplane that separates classes. The multiclass classification problem is reduced to a set of binary classification problems (using a one-vs.-one or a one-vs.-all strategy). The current implementation uses the LibSVM framework in the back end.
- The option "KernelType" allows you to choose the type of kernel to use. Possible settings for "KernelType" include:
-
"RadialBasisFunction" uses an exponential radial basis function as kernel "Polynomial" uses a polynomial function as kernel "Sigmoid" uses a sigmoidal function as kernel "Linear" uses a linear function as kernel - The kernel "RadialBasisFunction" takes the form:
- The kernel "Polynomial" takes the form:
- The kernel "Sigmoid" takes the form:
- The kernel "Linear" takes the form:
- The following options can be given:
-
"BiasParameter" 1 bias term c in polynomial and sigmoid kernels "GammaScalingParameter" Automatic the parameter in the preceding kernels
"KernelType" "RadialBasisFunction" the kernel to use to map to higher dimensions "MulticlassStrategy" Automatic the strategy to use to obtain a multiclass classifier "PolynomialDegree" 3 the degree of the polynomial d in the polynomial kernel - Possible settings for "MulticlassStrategy" include:
-
"OneVersusOne" train a binary classifier for each pair of classes "OneVersusAll" train one binary classifier for each class - The "GammaScalingParameter" controls the influence of the support vectors. Large values of gamma mean small radius of influence.
- The "PolynomialDegree" option is specific to the polynomial kernel type.
- The "MulticlassStrategy" option is used to generalize binary classifiers to a multiclass ones. The "OneVersusOne" strategy tests each class again each other, while the "OneVersusAll" strategy only test each class against the rest of the training set.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Train a classifier function on labeled examples:

https://wolfram.com/xid/0ecilgt0d1grxo0-wxc5bs

Obtain information about the classifier:

https://wolfram.com/xid/0ecilgt0d1grxo0-3656v8


https://wolfram.com/xid/0ecilgt0d1grxo0-tgze8s

Generate some data that is not linearly separable:

https://wolfram.com/xid/0ecilgt0d1grxo0-qxqbpt

https://wolfram.com/xid/0ecilgt0d1grxo0-f99uln

https://wolfram.com/xid/0ecilgt0d1grxo0-fcsxx1

Train a classifier on this dataset:

https://wolfram.com/xid/0ecilgt0d1grxo0-qv36d2

Plot the training set and the probability distribution of each class as a function of the features:

https://wolfram.com/xid/0ecilgt0d1grxo0-ebncen

Options (5)Common values & functionality for each option
"GammaScalingParameter" (1)
Train a classifier with a specific value for the "GammaScalingParameter" suboption:

https://wolfram.com/xid/0ecilgt0d1grxo0-32di5h

The "GammaScalingParameter" controls the influence of the support vectors.
Generate some data and visualize it:

https://wolfram.com/xid/0ecilgt0d1grxo0-k6bh0g

https://wolfram.com/xid/0ecilgt0d1grxo0-ognd2t

Train two classifiers by changing the "GammaScalingParameter":

https://wolfram.com/xid/0ecilgt0d1grxo0-iiulex


https://wolfram.com/xid/0ecilgt0d1grxo0-y7vhhq

Look at how they perform on a test set to see how the radius of influence has changed:

https://wolfram.com/xid/0ecilgt0d1grxo0-ybrfh4

https://wolfram.com/xid/0ecilgt0d1grxo0-7oxbk4

"KernelType" (2)
Train a classifier using a specific "KernelType":

https://wolfram.com/xid/0ecilgt0d1grxo0-773w9i

Train two classifiers using different instances of "KernelType":

https://wolfram.com/xid/0ecilgt0d1grxo0-v5oels

https://wolfram.com/xid/0ecilgt0d1grxo0-83pxw8

https://wolfram.com/xid/0ecilgt0d1grxo0-ggonvm

https://wolfram.com/xid/0ecilgt0d1grxo0-hdclu


"MulticlassStrategy" (1)
Use the "FisherIris" dataset to train two classifiers with different "MulticlassStrategy" options:

https://wolfram.com/xid/0ecilgt0d1grxo0-wrlkvg

https://wolfram.com/xid/0ecilgt0d1grxo0-xzyrpy
Look at their accuracy on a test set. The "OneVersusOne" option typically performs better.

https://wolfram.com/xid/0ecilgt0d1grxo0-l2rzfh

https://wolfram.com/xid/0ecilgt0d1grxo0-coq7kb

"PolynomialDegree" (1)
Use the "Mushroom" training set to train two classifiers using different degrees for the polynomial kernel type:

https://wolfram.com/xid/0ecilgt0d1grxo0-u80tc7

https://wolfram.com/xid/0ecilgt0d1grxo0-iswh3m
Compare the corresponding training times:

https://wolfram.com/xid/0ecilgt0d1grxo0-zxg7vy
