Skip to content

MNT Deprecate multiclass_colors in favour of label_colors in DecisionBoundaryDisplay - #34092

Merged
lucyleeow merged 12 commits into
scikit-learn:mainfrom
AnneBeyer:dbd_deprecate_cmap_and_colors
Jun 10, 2026
Merged

lucyleeow merged 12 commits into
scikit-learn:mainfrom
AnneBeyer:dbd_deprecate_cmap_and_colors

Conversation

@AnneBeyer

@AnneBeyer AnneBeyer commented May 22, 2026 •

Copy link
Copy Markdown
Member

Reference Issues/PRs

Towards #33115 (pre-requisite for Point 4: unify binary and multiclass color-handling)

What does this implement/fix? Explain your changes.

Renames the parameter multiclass_colors as label_colors target_colors and the attribute multiclass_colors_ as label_colors_ target_colors_ , respectively.
This is done so that in a next step, binary problems can also use this parameter/attribute for plotting decision boundaries (which will in turn remove the current inconsistencies when zooming in on the plot, making it binary internally when only two classes are visible, see #33211).

I also adapted all examples accordingly.

AI usage disclosure

I used AI assistance for:

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Any other comments?

I went with label_colors (suggested by @lucyleeow here), but now I'm not sure if something more generic like plot_colors would actually be better given that we also support regression. WDYT?
Taking up the suggestion from this comment below, I went with target_colors now.

(The branch was named for the next step, but then I realised that it probably makes sense to first do this deprecation in a separate PR.)

Imported `matplotlib` module.

multiclass_colors : str or list of matplotlib colors, default=None
label_colors : str or list of matplotlib colors, default=None

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a private function, this can be renamed without a deprecation here, right?

('viridis') is used.

.. versionadded:: 1.7
.. versionchanged:: 1.9

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should happen with this versionchanged note? Will it simply be removed in 1.12 or should it be preserved in label_colors?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting point. I would lean towards removing it in 1.12, to keep the docstring cleaner - we have some very long parameter docstrings with 4+ note entries, some from very old (<v0.20) versions.
Its documented in the changelog, if someone really wanted to dig.

@AnneBeyer
AnneBeyer marked this pull request as draft May 24, 2026 08:53

@lucyleeow lucyleeow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but now I'm not sure if something more generic like plot_colors would actually be better given that we also support regression. WDYT?

Good point. What about target_colors ?

('viridis') is used.

.. versionadded:: 1.7
.. versionchanged:: 1.9

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting point. I would lean towards removing it in 1.12, to keep the docstring cleaner - we have some very long parameter docstrings with 4+ note entries, some from very old (<v0.20) versions.
Its documented in the changelog, if someone really wanted to dig.

@AnneBeyer AnneBeyer added this to Labs May 27, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Labs May 27, 2026
@AnneBeyer AnneBeyer moved this from Todo to Blocked in Labs May 27, 2026
@AnneBeyer
AnneBeyer marked this pull request as ready for review May 29, 2026 13:41
@AnneBeyer AnneBeyer moved this from Blocked to In progress in Labs May 29, 2026

@lucyleeow lucyleeow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just a nit

.. versionadded:: 1.10
`multiclass_colors` was renamed to `target_colors`

multiclass_colors : str or list of matplotlib colors, default=None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be moved to the end as well

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This as well.

class_of_interest=None,
multiclass_colors=None,
target_colors=None,
multiclass_colors="deprecated", # TODO(1.12): remove

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we usually put deprecated parameters at the end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnneBeyer Can we make this change?

@lucyleeow lucyleeow added the Waiting for Second Reviewer First reviewer is done, need a second one! label May 30, 2026
@AnneBeyer AnneBeyer mentioned this pull request Jun 7, 2026
2 of 4 tasks

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits otherwise lgtm

class_of_interest=None,
multiclass_colors=None,
target_colors=None,
multiclass_colors="deprecated", # TODO(1.12): remove

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnneBeyer Can we make this change?

.. versionadded:: 1.10
`multiclass_colors` was renamed to `target_colors`

multiclass_colors : str or list of matplotlib colors, default=None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This as well.

response,
multiclass_colors=None,
target_colors=None,
multiclass_colors="deprecated", # TODO(1.12): remove

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here regarding order.

@AnneBeyer

Copy link
Copy Markdown
Member Author

Thank you for the feedback @lucyleeow and @thomasjpfan!
I updated the ordering. In from_estimator(), we also have the **kwargs, so I moved it before that in this case.

@lucyleeow

Copy link
Copy Markdown
Member

Thank you!

@lucyleeow
lucyleeow merged commit 59335ca into scikit-learn:main Jun 10, 2026
33 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in Labs Jun 10, 2026
prady0t pushed a commit to prady0t/scikit-learn that referenced this pull request Sep 2, 2026
@AnneBeyer
AnneBeyer deleted the dbd_deprecate_cmap_and_colors branch September 2, 2026 11:59
@jeremiedbb jeremiedbb mentioned this pull request Sep 8, 2026
14 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:inspection Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants