Skip to content

Commit 5c5628d

Browse files
committed
Pushing the docs to dev/ for branch: main, commit bfcb5a400efcfc82483bc0e2f233214c63b9157e
1 parent 17cf9b1 commit 5c5628d

File tree

1,249 files changed

+4389
-4389
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,249 files changed

+4389
-4389
lines changed
Binary file not shown.
Binary file not shown.

dev/_downloads/8025056f1d24411e898c2d0086371880/plot_optics.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"# Authors: Shane Grigsby <[email protected]>\n# Adrin Jalali <[email protected]>\n# License: BSD 3 clause\n\nfrom sklearn.cluster import OPTICS, cluster_optics_dbscan\nimport matplotlib.gridspec as gridspec\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n# Generate sample data\n\nnp.random.seed(0)\nn_points_per_cluster = 250\n\nC1 = [-5, -2] + 0.8 * np.random.randn(n_points_per_cluster, 2)\nC2 = [4, -1] + 0.1 * np.random.randn(n_points_per_cluster, 2)\nC3 = [1, -2] + 0.2 * np.random.randn(n_points_per_cluster, 2)\nC4 = [-2, 3] + 0.3 * np.random.randn(n_points_per_cluster, 2)\nC5 = [3, -2] + 1.6 * np.random.randn(n_points_per_cluster, 2)\nC6 = [5, 6] + 2 * np.random.randn(n_points_per_cluster, 2)\nX = np.vstack((C1, C2, C3, C4, C5, C6))\n\nclust = OPTICS(min_samples=50, xi=0.05, min_cluster_size=0.05)\n\n# Run the fit\nclust.fit(X)\n\nlabels_050 = cluster_optics_dbscan(\n reachability=clust.reachability_,\n core_distances=clust.core_distances_,\n ordering=clust.ordering_,\n eps=0.5,\n)\nlabels_200 = cluster_optics_dbscan(\n reachability=clust.reachability_,\n core_distances=clust.core_distances_,\n ordering=clust.ordering_,\n eps=2,\n)\n\nspace = np.arange(len(X))\nreachability = clust.reachability_[clust.ordering_]\nlabels = clust.labels_[clust.ordering_]\n\nplt.figure(figsize=(10, 7))\nG = gridspec.GridSpec(2, 3)\nax1 = plt.subplot(G[0, :])\nax2 = plt.subplot(G[1, 0])\nax3 = plt.subplot(G[1, 1])\nax4 = plt.subplot(G[1, 2])\n\n# Reachability plot\ncolors = [\"g.\", \"r.\", \"b.\", \"y.\", \"c.\"]\nfor klass, color in zip(range(0, 5), colors):\n Xk = space[labels == klass]\n Rk = reachability[labels == klass]\n ax1.plot(Xk, Rk, color, alpha=0.3)\nax1.plot(space[labels == -1], reachability[labels == -1], \"k.\", alpha=0.3)\nax1.plot(space, np.full_like(space, 2.0, dtype=float), \"k-\", alpha=0.5)\nax1.plot(space, np.full_like(space, 0.5, dtype=float), \"k-.\", alpha=0.5)\nax1.set_ylabel(\"Reachability (epsilon distance)\")\nax1.set_title(\"Reachability Plot\")\n\n# OPTICS\ncolors = [\"g.\", \"r.\", \"b.\", \"y.\", \"c.\"]\nfor klass, color in zip(range(0, 5), colors):\n Xk = X[clust.labels_ == klass]\n ax2.plot(Xk[:, 0], Xk[:, 1], color, alpha=0.3)\nax2.plot(X[clust.labels_ == -1, 0], X[clust.labels_ == -1, 1], \"k+\", alpha=0.1)\nax2.set_title(\"Automatic Clustering\\nOPTICS\")\n\n# DBSCAN at 0.5\ncolors = [\"g\", \"greenyellow\", \"olive\", \"r\", \"b\", \"c\"]\nfor klass, color in zip(range(0, 6), colors):\n Xk = X[labels_050 == klass]\n ax3.plot(Xk[:, 0], Xk[:, 1], color, alpha=0.3, marker=\".\")\nax3.plot(X[labels_050 == -1, 0], X[labels_050 == -1, 1], \"k+\", alpha=0.1)\nax3.set_title(\"Clustering at 0.5 epsilon cut\\nDBSCAN\")\n\n# DBSCAN at 2.\ncolors = [\"g.\", \"m.\", \"y.\", \"c.\"]\nfor klass, color in zip(range(0, 4), colors):\n Xk = X[labels_200 == klass]\n ax4.plot(Xk[:, 0], Xk[:, 1], color, alpha=0.3)\nax4.plot(X[labels_200 == -1, 0], X[labels_200 == -1, 1], \"k+\", alpha=0.1)\nax4.set_title(\"Clustering at 2.0 epsilon cut\\nDBSCAN\")\n\nplt.tight_layout()\nplt.show()"
29+
"# Authors: Shane Grigsby <[email protected]>\n# Adrin Jalali <[email protected]>\n# License: BSD 3 clause\n\nfrom sklearn.cluster import OPTICS, cluster_optics_dbscan\nimport matplotlib.gridspec as gridspec\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n# Generate sample data\n\nnp.random.seed(0)\nn_points_per_cluster = 250\n\nC1 = [-5, -2] + 0.8 * np.random.randn(n_points_per_cluster, 2)\nC2 = [4, -1] + 0.1 * np.random.randn(n_points_per_cluster, 2)\nC3 = [1, -2] + 0.2 * np.random.randn(n_points_per_cluster, 2)\nC4 = [-2, 3] + 0.3 * np.random.randn(n_points_per_cluster, 2)\nC5 = [3, -2] + 1.6 * np.random.randn(n_points_per_cluster, 2)\nC6 = [5, 6] + 2 * np.random.randn(n_points_per_cluster, 2)\nX = np.vstack((C1, C2, C3, C4, C5, C6))\n\nclust = OPTICS(min_samples=50, xi=0.05, min_cluster_size=0.05)\n\n# Run the fit\nclust.fit(X)\n\nlabels_050 = cluster_optics_dbscan(\n reachability=clust.reachability_,\n core_distances=clust.core_distances_,\n ordering=clust.ordering_,\n eps=0.5,\n)\nlabels_200 = cluster_optics_dbscan(\n reachability=clust.reachability_,\n core_distances=clust.core_distances_,\n ordering=clust.ordering_,\n eps=2,\n)\n\nspace = np.arange(len(X))\nreachability = clust.reachability_[clust.ordering_]\nlabels = clust.labels_[clust.ordering_]\n\nplt.figure(figsize=(10, 7))\nG = gridspec.GridSpec(2, 3)\nax1 = plt.subplot(G[0, :])\nax2 = plt.subplot(G[1, 0])\nax3 = plt.subplot(G[1, 1])\nax4 = plt.subplot(G[1, 2])\n\n# Reachability plot\ncolors = [\"g.\", \"r.\", \"b.\", \"y.\", \"c.\"]\nfor klass, color in zip(range(0, 5), colors):\n Xk = space[labels == klass]\n Rk = reachability[labels == klass]\n ax1.plot(Xk, Rk, color, alpha=0.3)\nax1.plot(space[labels == -1], reachability[labels == -1], \"k.\", alpha=0.3)\nax1.plot(space, np.full_like(space, 2.0, dtype=float), \"k-\", alpha=0.5)\nax1.plot(space, np.full_like(space, 0.5, dtype=float), \"k-.\", alpha=0.5)\nax1.set_ylabel(\"Reachability (epsilon distance)\")\nax1.set_title(\"Reachability Plot\")\n\n# OPTICS\ncolors = [\"g.\", \"r.\", \"b.\", \"y.\", \"c.\"]\nfor klass, color in zip(range(0, 5), colors):\n Xk = X[clust.labels_ == klass]\n ax2.plot(Xk[:, 0], Xk[:, 1], color, alpha=0.3)\nax2.plot(X[clust.labels_ == -1, 0], X[clust.labels_ == -1, 1], \"k+\", alpha=0.1)\nax2.set_title(\"Automatic Clustering\\nOPTICS\")\n\n# DBSCAN at 0.5\ncolors = [\"g.\", \"r.\", \"b.\", \"c.\"]\nfor klass, color in zip(range(0, 4), colors):\n Xk = X[labels_050 == klass]\n ax3.plot(Xk[:, 0], Xk[:, 1], color, alpha=0.3)\nax3.plot(X[labels_050 == -1, 0], X[labels_050 == -1, 1], \"k+\", alpha=0.1)\nax3.set_title(\"Clustering at 0.5 epsilon cut\\nDBSCAN\")\n\n# DBSCAN at 2.\ncolors = [\"g.\", \"m.\", \"y.\", \"c.\"]\nfor klass, color in zip(range(0, 4), colors):\n Xk = X[labels_200 == klass]\n ax4.plot(Xk[:, 0], Xk[:, 1], color, alpha=0.3)\nax4.plot(X[labels_200 == -1, 0], X[labels_200 == -1, 1], \"k+\", alpha=0.1)\nax4.set_title(\"Clustering at 2.0 epsilon cut\\nDBSCAN\")\n\nplt.tight_layout()\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/fe139d44b92c775a3b44dcefd61ea1bb/plot_optics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@
8888
ax2.set_title("Automatic Clustering\nOPTICS")
8989

9090
# DBSCAN at 0.5
91-
colors = ["g", "greenyellow", "olive", "r", "b", "c"]
92-
for klass, color in zip(range(0, 6), colors):
91+
colors = ["g.", "r.", "b.", "c."]
92+
for klass, color in zip(range(0, 4), colors):
9393
Xk = X[labels_050 == klass]
94-
ax3.plot(Xk[:, 0], Xk[:, 1], color, alpha=0.3, marker=".")
94+
ax3.plot(Xk[:, 0], Xk[:, 1], color, alpha=0.3)
9595
ax3.plot(X[labels_050 == -1, 0], X[labels_050 == -1, 1], "k+", alpha=0.1)
9696
ax3.set_title("Clustering at 0.5 epsilon cut\nDBSCAN")
9797

dev/_downloads/scikit-learn-docs.zip

-4.1 KB
Binary file not shown.
-26 Bytes
-204 Bytes
96 Bytes
62 Bytes
9 Bytes

0 commit comments

Comments
 (0)