8000 MNT Accelerate_examples plot_digits_linkage.py by siavrez · Pull Request #21737 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

MNT Accelerate_examples plot_digits_linkage.py #21737

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 3 commits into from
Nov 26, 2021
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
17 changes: 9 additions & 8 deletions examples/cluster/plot_digits_linkage.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@

from sklearn import manifold, datasets

X, y = datasets.load_digits(return_X_y=True)
digits = datasets.load_digits()
X, y = digits.data, digits.target
n_samples, n_features = X.shape

np.random.seed(0)
Expand All @@ -50,13 +51,13 @@ def plot_clustering(X_red, labels, title=None):
X_red = (X_red - x_min) / (x_max - x_min)

plt.figure(figsize=(6, 4))
for i in range(X_red.shape[0]):
plt.text(
X_red[i, 0],
X_red[i, 1],
str(y[i]),
color=plt.cm.nipy_spectral(labels[i] / 10.0),
fontdict={"weight": "bold", "size": 9},
for digit in digits.target_names:
plt.scatter(
*X_red[y == digit].T,
marker=f"${digit}$",
s=50,
c=plt.cm.nipy_spectral(labels[y == digit] / 10),
alpha=0.5,
)

plt.xticks([])
Expand Down
0