You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add show_data=False option to DecisionBoundaryDisplay.from_estimator #33094
While reviewing @AnneBeyer's #33015 PR, I thought it would be nice to be able to display the decision boundaries of a classifier along with the data points with consistent color maps (at least for classifiers, outlier detectors and regressors) instead of having to a manually scatter plot on the same ax instance.
Describe your proposed solution
Add a new show_data boolean kwarg to the from_estimator method that already accepts the X values as argument. The from_estimator method would then call estimator.predict(X) to find the values of the target to be used to set the colors of the dots of the scatter plot.
The from_estimator could also take an optional y argument with true class labels. When provided, the scatter plot enabled from the show_data=True param of from_estimator would use the provided y values instead of using estimator.predict(X).
The __init__ of the display would then also accept the X and y values.
Ideally, the legend would make it explicit whether the scatter dots represent predictions or true labels, and could be overridden by a data_label kwarg passed to from_estimator.
Maybe show_data=True could even be the default.
Describe alternatives you've considered, if relevant
While it's possible to do scatter plot manually, it's quite verbose and not necessarily trivial to understand if the colors used for the two plots are expected to be consistent or not.
I think people often want to overlay the training set with the decision boundary when generating such plots for educational purposes.
Additional context
@AnneBeyer if you think this is a good feature to add, would be interested in contributing it (as a follow-up to #33015 and related PRs)?
There was discussion about colour consistency, and since it seems like a common thing to add to the plot, and makes enabling colour consistency easier, I would be +1 for a kwarg to do the scatter plot.
Note that this feature will interact with the second item of the list in #33115:
use same selection mechanism for all qualitative cmaps (that have colors)
At the moment, the special casing of tab10 and tab20 make it challenging to achieve consistent colors between the scatter dot and the decision display background color.
Activity
lucyleeow commentedon Jan 16, 2026
There was discussion about colour consistency, and since it seems like a common thing to add to the plot, and makes enabling colour consistency easier, I would be +1 for a kwarg to do the scatter plot.
AnneBeyer commentedon Jan 16, 2026
I also think this could be very useful and will work on a PR to add this feature.
ogrisel commentedon Jan 30, 2026
Note that this feature will interact with the second item of the list in #33115:
At the moment, the special casing of tab10 and tab20 make it challenging to achieve consistent colors between the scatter dot and the decision display background color.
AnneBeyer commentedon Mar 2, 2026
Indeed, I think it makes sense to address the points from that issue first. I opened a first PR for that here: #33419
AnneBeyer commentedon Aug 20, 2026
Note for myself: When adding this, we need to add a special case for when
class_of_interestis notNoneto keep the colors consistent.AnneBeyer commentedon Sep 2, 2026
And also add a test for color consistency when the data to plot only contains a subset of the classes.