DBSCAN
from sklearn.cluster import DBSCAN from sklearn.datasets import load_iris, make_moons import matplotlib.pyplot as plt noisy_moons = make_moons(n_samples=100, noise=.05)[0] dbscan_pred = DBSCAN(0.3, 6).fit_predict(noisy_moons) plt.figure(figsize=(10, 6)) print(set(dbscan_pred)) for i in set(dbscan_pred): sub_x = noisy_moons[dbscan_pred==i] plt.scatter(sub_x[:,0], sub_x[:,1]) #plt.savefig('noisy_moons_DBSCAN.png') plt.show()
元のデータ
DBSCAN