Skip to content

Support clusterers in DecisionBoundaryDisplay #33119

Open

Description

@ThexXTURBOXx

Describe the workflow you want to enable

So far, response_method="auto" does not resolve correctly (list of options as for classifiers instead of predict).
The approach I implemented is: using PCA, followed by DBSCAN and Logistic Regression as a final step.
Properly showing the relevant datapoints, categorised/colored by their identified clusters, would be great without an extra call to scatter.

Describe your proposed solution

As per discussion linked below, proper support for clusterers should be added to DecisionBoundaryDisplay.

Describe alternatives you've considered, if relevant

Simply plotting a scatterplot on top does not necessarily yield the same class colors, because the clusters are not necessarily ordered in the same way as the y values.

Additional context

#33015 (comment)

Activity

  1. removed
    Needs Triage
    on Jan 21, 2026
  2. ogrisel commented on Jan 21, 2026

    @ogrisel
    Member

    I think there are two independent issues:

    For the first point, I think we could limit clusterer support to the predict response method. Some clustering algorithms might be able to compute continuous cluster membership scores, but I we don't have a unified API for this, hence I would keep this out of the scope of this issue.

    Furthermore, it's possible that some clustering algorithm do not expose a predict method. Only fit_predict or the labels_ fitted attribute. I think response_method="auto" should use the labels_ attribute in this case.

  3. ogrisel commented on Jan 21, 2026

    @ogrisel
    Member

    We might also need to extend an example to demonstrate the use of DecisionBoundaryDisplay.from_estimator on clustering problems.

  4. shiffiH commented on Jan 22, 2026

    @shiffiH

    If OK,I’ll take this on and start working on fixing response_method="auto" for clusterers using labels_ when predict isn’t available. Just checking - does that match your expectation? Either way, I can start.

  5. moved this from Todo to In progress in Labson Jan 26, 2026
  6. AnneBeyer commented on Jan 28, 2026

    @AnneBeyer
    Member

    Furthermore, it's possible that some clustering algorithm do not expose a predict method. Only fit_predict or the labels_ fitted attribute. I think response_method="auto" should use the labels_ attribute in this case.

    This case is a bit more complicated. To plot the decision boundary, we calculate the responses for an evenly spaced meshgrid (based on the min and max of X) in from_estimator, so the given estimator has to implement at least predict. If I'm not missing anything, we can't support any estimators that don't have that.

    If my assumption is correct, resolving response_method="auto" can be simplified to the default value ["decision_function", "predict_proba", "predict"] for all estimators, which will be resolved into predict if the others are not implemented once this PR gets merged. The case where predict is not implemented will then be handled by an AttributeError in sklearn.utils.validation._check_response_method, and all that is left here to do would be to make this clear in the docstrings and extend the tests to include clusterers (that implement predict).

    Please correct me, if I missed anything, I'm not that familiar with clustering applications yet.

  7. AnneBeyer commented on Feb 4, 2026

    @AnneBeyer
    Member

    Side note: I just learned about the inductive clustering example. We could add something like that in cases where a clusterer doesn't implement predict, but maybe this is too much of a special interest application? Maybe we could instead link to this example in the docs for people to use it themselves if they need to.

  8. moved this from In progress to Todo in Labson Feb 16, 2026
  9. lucyleeow commented on Nov 12, 2026

    @lucyleeow
    Member

    Just doing some housekeeping.

    So far, response_method="auto" does not resolve correctly (list of options as for classifiers instead of predict).

    How do you want it to resolve for clusterers? Do you want it to use predict or (from what I can tell from @AnneBeyer's comment) do you want it to work for clusterers that do not have a predict method?
    Note on 'auto', it does cycle through (in order) ["decision_function", "predict_proba", "predict"], so it does get to predict.
    (AFAICT I don't think there is anything to be done here)

    For the second point, I think issue #33094 covers it.

    I think this issue may be able to be closed - if there are no objections I will close in a few days.

  10. AnneBeyer commented on Nov 23, 2026

    @AnneBeyer
    Member

    Just some historical context:

    Note on 'auto', it does cycle through (in order) ["decision_function", "predict_proba", "predict"], so it does get to predict.

    This wasn't the case when this issue was opened (back then it threw an error for clusterers for anything other than response_method="predict"). This was fixed in #33126, though.

    So in principle, this is already supported now, but what is left to do is to

    While none of these are code changes, I think it could still be worth keeping this open until those are done.

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