Skip to content

Add show_data=False option to DecisionBoundaryDisplay.from_estimator #33094

Open

Description

@ogrisel

Describe the workflow you want to enable

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)?

Also cc @lucyleeow @glemaitre in case you already discussed this in the past.

Activity

  1. added
    Needs Triage
    Needs Decision - Include Feature
    and removed
    Needs Triage
    on Jan 16, 2026
  2. lucyleeow commented on Jan 16, 2026

    @lucyleeow
    Member

    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.

  3. AnneBeyer commented on Jan 16, 2026

    @AnneBeyer
    Member

    I also think this could be very useful and will work on a PR to add this feature.

  4. removed
    Needs Decision - Include Feature
    on Jan 19, 2026
  5. ogrisel commented on Jan 30, 2026

    @ogrisel
    MemberAuthor

    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.

  6. AnneBeyer commented on Mar 2, 2026

    @AnneBeyer
    Member

    Note that this feature will interact with the second item of the list in #33115

    Indeed, I think it makes sense to address the points from that issue first. I opened a first PR for that here: #33419

  7. AnneBeyer commented on Aug 20, 2026

    @AnneBeyer
    Member

    Note for myself: When adding this, we need to add a special case for when class_of_interest is not None to keep the colors consistent.

  8. AnneBeyer commented on Sep 2, 2026

    @AnneBeyer
    Member

    And also add a test for color consistency when the data to plot only contains a subset of the classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions