<jupyter_start><jupyter_text>Copyright (C) 2016 - 2019 <NAME>(<EMAIL>)https://www.cnblogs.com/pinardPermission given to modify the code as long as you keep this declaration at the top用scikit-learn学习DBSCAN聚类 https://www.cnblogs.com/pinard/p/6217852.html<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets
%matplotlib inline
X1, y1=datasets.make_circles(n_samples=5000, factor=.6,
                                      noise=.05)
X2, y2 = datasets.make_blobs(n_samples=1000, n_features=2, centers=[[1.2,1.2]], cluster_std=[[.1]],
               random_state=9)

X = np.concatenate((X1, X2))
plt.scatter(X[:, 0], X[:, 1], marker='o')
plt.show()
from sklearn.cluster import KMeans
y_pred = KMeans(n_clusters=3, random_state=9).fit_predict(X)
plt.scatter(X[:, 0], X[:, 1], c=y_pred)
plt.show()
from sklearn.cluster import DBSCAN
y_pred = DBSCAN().fit_predict(X)
plt.scatter(X[:, 0], X[:, 1], c=y_pred)
plt.show()
y_pred = DBSCAN(eps = 0.1).fit_predict(X)
plt.scatter(X[:, 0], X[:, 1], c=y_pred)
plt.show()
y_pred = DBSCAN(eps = 0.1, min_samples = 10).fit_predict(X)
plt.scatter(X[:, 0], X[:, 1], c=y_pred)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1724429416737109, 'fraction_numerical': 0.04818258664412511, 'mean_word_length': 4.775609756097561, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '328321', 'license': 'MIT', 'n_tokens_mistral': 513, 'n_tokens_neox': 482, 'n_words': 99, 'path': 'classic-machine-learning/dbscan_cluster.ipynb', 'repo_name': 'yefang008514/machinelearning', 'size': '1202'}