8000 DOC: Update notebook-style example plot_dbscan by AmarCodes-22 · Pull Request #22568 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
8000

DOC: Update notebook-style example plot_dbscan #22568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions examples/cluster/plot_dbscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@
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
)

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
Expand All @@ -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.
Expand Down
0