Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC Refactor plot_kmeans_digits.py to use DecisionBoundaryDisplay - #34515

Merged
StefanieSenger merged 6 commits into
scikit-learn:mainfrom
lisaleemcb:addplots_DecisionBoundaryDisplay_issue33980
Jul 21, 2026
Merged

DOC Refactor plot_kmeans_digits.py to use DecisionBoundaryDisplay#34515
StefanieSenger merged 6 commits into
scikit-learn:mainfrom
lisaleemcb:addplots_DecisionBoundaryDisplay_issue33980

Conversation

@lisaleemcb

@lisaleemcb lisaleemcb commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

✅ In particular following the pull request checklist will increase the likelihood
of having maintainers review your PR:
https://scikit-learn.org/dev/developers/contributing.html#pull-request-checklist

Reference Issues/PRs

Addresses #33980 . See also #33119 .

What does this implement/fix? Explain your changes.

Updated the plot in the example using K-mean on digits dataset to use the DecisionBoundaryDisplay.

@AnneBeyer

Copy link
Copy Markdown
Contributor

@mcvincekova, would you be interested in reviewing this one?

@lisaleemcb lisaleemcb changed the title updated plot to use the DecisionBoundaryDisplay Addresses issue #33980 and #3319 - updated plot to use the DecisionBoundaryDisplay Jul 19, 2026
@lisaleemcb
lisaleemcb marked this pull request as ready for review July 19, 2026 12:23
@AnneBeyer

Copy link
Copy Markdown
Contributor

Thank you @lisaleemcb, LGTM!

@StefanieSenger, could you have a look as well?

Comment thread examples/cluster/plot_kmeans_digits.py Outdated
Comment on lines +165 to +166
# Put the result into a color plot
Z = Z.reshape(xx.shape)
plt.figure(1)
plt.clf()
plt.imshow(
Z,
interpolation="nearest",
extent=(xx.min(), xx.max(), yy.min(), yy.max()),
cmap=plt.cm.Paired,
aspect="auto",
origin="lower",
DecisionBoundaryDisplay.from_estimator(

@mcvincekova mcvincekova Jul 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Nitpick] I find the comment # Put the result into a color plot a bit generic,
maybe something along the lines of: # Plot the K-means decision regions would be more informative?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need this comment at all anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@StefanieSenger StefanieSenger changed the title Addresses issue #33980 and #3319 - updated plot to use the DecisionBoundaryDisplay DOC Refactor plot_kmeans_digits.py to use DecisionBoundaryDisplay Jul 21, 2026

@StefanieSenger StefanieSenger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work, @lisaleemcb! :)

I've left a few comments as well.

Comment thread examples/cluster/plot_kmeans_digits.py Outdated
Comment thread examples/cluster/plot_kmeans_digits.py
Comment thread examples/cluster/plot_kmeans_digits.py Outdated
Comment on lines +165 to +166
# Put the result into a color plot
Z = Z.reshape(xx.shape)
plt.figure(1)
plt.clf()
plt.imshow(
Z,
interpolation="nearest",
extent=(xx.min(), xx.max(), yy.min(), yy.max()),
cmap=plt.cm.Paired,
aspect="auto",
origin="lower",
DecisionBoundaryDisplay.from_estimator(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need this comment at all anymore.

@StefanieSenger StefanieSenger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @lisaleemcb, let's

  1. figure out the colour map with @AnneBeyer,
  2. also add a random_state to KMeans while we're at it, so we get the same plot ever time (we try to keep our examples deterministic, unless we want to demonstrate non-deterministic behaviour)

Then this can get merged. :)

Comment thread examples/cluster/plot_kmeans_digits.py Outdated
Comment thread examples/cluster/plot_kmeans_digits.py

@StefanieSenger StefanieSenger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now looks great! Thank you for your work, @lisaleemcb!

@StefanieSenger
StefanieSenger enabled auto-merge (squash) July 21, 2026 20:18
@StefanieSenger
StefanieSenger merged commit 1283953 into scikit-learn:main Jul 21, 2026
38 checks passed
prady0t pushed a commit to prady0t/scikit-learn that referenced this pull request Sep 2, 2026
@jeremiedbb jeremiedbb mentioned this pull request Sep 8, 2026
14 tasks
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Sep 9, 2026
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants