diff --git a/examples/cluster/plot_dbscan.py b/examples/cluster/plot_dbscan.py index f4293941569ce..620ee6bdcb86e 100644 --- a/examples/cluster/plot_dbscan.py +++ b/examples/cluster/plot_dbscan.py @@ -16,8 +16,9 @@ from sklearn.preprocessing import StandardScaler -# ############################################################################# +# %% # Generate sample data +# -------------------- centers = [[1, 1], [-1, -1], [1, -1]] X, labels_true = make_blobs( n_samples=750, centers=centers, cluster_std=0.4, random_state=0 @@ -25,8 +26,9 @@ X = StandardScaler().fit_transform(X) -# ############################################################################# +# %% # Compute DBSCAN +# -------------- db = DBSCAN(eps=0.3, min_samples=10).fit(X) core_samples_mask = np.zeros_like(db.labels_, dtype=bool) core_samples_mask[db.core_sample_indices_] = True @@ -48,8 +50,9 @@ ) print("Silhouette Coefficient: %0.3f" % metrics.silhouette_score(X, labels)) -# ############################################################################# +# %% # Plot result +# ----------- import matplotlib.pyplot as plt # Black removed and is used for noise instead.