非線形で円に対応できると割と柔軟なアルゴリズムではないかと思います(精度や説明性は別として)。そこでScikit-Learnのデータセットで実際にやってみました。
データセット
from sklearn.datasets import make_circles
x, y = make_circles(1000, factor=.1, noise=.1)
plt.scatter(x[:, 0], x[:, 1], c=y, s=50, cmap='brg')
これに対応したアルゴリズムを紹介しようと思います。
決定境界描画関数
import numpy as np
import matplotlib.pyplot as plt
def visualize_classifier(model, X, y, ax=None, cmap='brg'):
ax = ax or plt.gca()
# Plot the training points
ax.scatter(X[:, 0], X[:, 1], c=y, s=30, cmap=cmap,
clim=(y.min(), y.max()), zorder=3)
ax.axis('tight')
ax.axis('off')
xlim = ax.get_xlim()
ylim = ax.get_ylim()
# fit the estimator
model.fit(X, y)
xx, yy = np.meshgrid(np.linspace(*xlim, num=200),
np.linspace(*ylim, num=200))
Z = model.predict(np.c_[xx.ravel(), yy.ravel()]).reshape(xx.shape)
# Create a color plot with the results
n_classes = len(np.unique(y))
contours = ax.contourf(xx, yy, Z, alpha=0.3,
levels=np.arange(n_classes + 1) - 0.5,
cmap=cmap, clim=(y.min(), y.max()),
zorder=1)
ax.set(xlim=xlim, ylim=ylim)