text: from sklearn.datasets import make_moons
  from sklearn.preprocessing import StandardScaler
  from sklearn.cluster import DBSCAN
  import matplotlib.pyplot as plt
  import mglearn
  
  X, y = make_moons(n_samples=200, noise=0.05, random_state=0)
  
  # # 将数据缩放成平均值为 0，方差为 1
  scaler = StandardScaler()
  scaler.fit(X)
  X_scaled = scaler.transform(X)
  
  dbscan = DBSCAN()
  clusters = dbscan.fit_predict(X_scaled)
  
  # 绘制簇分配
  plt.figure(figsize=(11, 4.5))
  plt.subplots_adjust(left=0.32, right=0.68)
  plt.scatter(X_scaled[:, 0], X_scaled[:, 1], c=clusters, cmap=mglearn.cm2, s=60)
  plt.xlabel("Feature 0")
  plt.ylabel("Feature 1")
  
  fig, axes = plt.subplots(1, 2, figsize=(11, 4.5),
                           subplot_kw={'xticks': (), 'yticks': ()})
  plt.subplots_adjust(left=0.08, right=0.92)
  
  # make a list of eps to use
  eps_diffs = [DBSCAN(eps=0.2), DBSCAN(eps=0.7)]
  
  for ax, eps_diff in zip(axes, eps_diffs):
      clusters = eps_diff.fit_predict(X_scaled)
      # plot the cluster assignments
      ax.scatter(X_scaled[:, 0], X_scaled[:, 1], c=clusters, cmap='Paired',s=60)
      ax.set_title("DBSCAN eps : {:.2f}".format(eps_diff.eps))
      ax.set_xlabel("Feature 0")
      ax.set_ylabel("Feature 1")
  
  plt.show()
  