Non-linear examples

To show the power of kernel SVMs, we're going to solve two problems. The first one is simpler but purely non-linear and the dataset is generated through the make_circles() built-in function:

from sklearn.datasets import make_circles  nb_samples = 500 X, Y = make_circles(n_samples=nb_samples, noise=0.1)

A plot of this dataset is shown in the following graph:

Test dataset for an RBF SVM

As it's possible to see, a linear classifier can never separate the two sets and every approximation will contain on average 50% misclassifications. A logistic regression example is shown here:

from sklearn.linear_model import LogisticRegression ...

Get Machine Learning Algorithms - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.