Repository navigation
DOC Use DecisionBoundaryDisplay colors for scatter in Nearest Neighbors Classification example - #33849
Merged
jeremiedbb merged 2 commits intoApr 24, 2026
Conversation
AnneBeyer
commented
Apr 24, 2026
| scatter = disp.ax_.scatter(X.iloc[:, 0], X.iloc[:, 1], c=y, edgecolors="k") | ||
| cmap = mpl.colors.ListedColormap(disp.multiclass_colors_) | ||
| scatter = disp.ax_.scatter( | ||
| X.iloc[:, 0], X.iloc[:, 1], c=y, cmap=cmap, edgecolors="k" |
Member
Author
There was a problem hiding this comment.
I think it would make more sense to also only plot the training portion of X here, or mark train and test data points differently, or simply use all data for fitting the classifier. X_test is only used for deriving the grid boundaries in the DecisionBoundaryDisplay, but I will come back to this once #33094 is addressed.
Member
There was a problem hiding this comment.
The decision regions would be same, so maybe it's just to not have too many points, or to show the generalisation capability so the decision on the test set. Mixing both, represented differently, might make the plot less readable.
26 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
Towards #33557
What does this implement/fix? Explain your changes.
Re-use colors from the DecisionBoundaryDisplay for the scatter plot in the Nearest Neighbors Classification example.
I also moved the legend to the right because the difference around the blue data point was almost covered by the legend.
AI usage disclosure
I used AI assistance for:
Any other comments?