DOC Refactor plot_kmeans_digits.py to use DecisionBoundaryDisplay - #34515
Conversation
|
@mcvincekova, would you be interested in reviewing this one? |
|
Thank you @lisaleemcb, LGTM! @StefanieSenger, could you have a look as well? |
| # 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( |
There was a problem hiding this comment.
[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?
There was a problem hiding this comment.
I think we don't need this comment at all anymore.
StefanieSenger
left a comment
There was a problem hiding this comment.
Thanks for your work, @lisaleemcb! :)
I've left a few comments as well.
| # 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( |
There was a problem hiding this comment.
I think we don't need this comment at all anymore.
StefanieSenger
left a comment
There was a problem hiding this comment.
Thank you @lisaleemcb, let's
- figure out the colour map with @AnneBeyer,
- also add a
random_statetoKMeanswhile 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. :)
StefanieSenger
left a comment
There was a problem hiding this comment.
This now looks great! Thank you for your work, @lisaleemcb!
✅ 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.