Support Vector Machine
Support Vector Machine
sklearn.datasets.make_blobs(n_samples=100,
n_features=2, centers=3, cluster_std=1.0,
center_box=(-10.0, 10.0), shuffle=True,
random_state=None)
EXPLANATION
Let's see the result of an actual fit to this data: we will use
Scikit-Learn's support vector classifier to train an SVM
model on this data. For the time being, we will use a linear
kernel and set the C parameter to a very large number
(we'll discuss the meaning of these in more depth
momentarily).
To better visualize what's happening here, let's create a
quick convenience function that will plot SVM decision
boundaries for us:
A key to this classifier's success is that for the fit, only the We can see this, for example, if we plot the model learned
position of the support vectors matter; any points further from the first 60 points and first 120 points of this dataset:
from the margin which are on the correct side do not
modify the fit! Technically, this is because these points do
not contribute to the loss function used to fit the model, so
their position and number do not matter so long as they do
not cross the margin.
Where SVM becomes extremely powerful is when it is
combined with kernels. We have seen a version of kernels
before, in the basis function regressions of In Depth:
Linear Regression. There we projected our data into
higher-dimensional space defined by polynomials and
Gaussian basis functions, and thereby were able to fit for
nonlinear relationships with a linear classifier.
To
for 60 training points. In the right panel, we have doubled motivate the need for kernels, let's look at some data that
the number of training points, but the model has not is not linearly separable:
changed: the three support vectors from the left panel are
still the support vectors from the right panel. This
insensitivity to the exact behavior of distant points is one
of the strengths of the SVM model.