Kernel-PCA
import numpy as np
import matplotlib.pyplot as plt
import japanize_matplotlib
from sklearn.datasets import make_circles
実験用のデータ
X, y = make_circles(n_samples=400, factor=0.3, noise=0.15)
fig = plt.figure(figsize=(8, 8))
plt.scatter(X[:, 0], X[:, 1], c=y)
<matplotlib.collections.PathCollection at 0x7fc8e1c9bbe0>
KernelPCA
from sklearn.decomposition import KernelPCA
kpca = KernelPCA(kernel="rbf", degree=2, gamma=3)
X_kpca = kpca.fit_transform(X)
fig = plt.figure(figsize=(8, 8))
plt.scatter(X_kpca[:, 0], X_kpca[:, 1], c=y)
<matplotlib.collections.PathCollection at 0x7fc8e28323a0>