Conversation
There was a problem hiding this comment.
I didn't check the details but from a cursory glance this looks great. Please feel free to ping me once CI is green.
I think it would be great to also find a way to include a non regression test for #32866, that is, that different regions are assigned distinct colors when n_classes is large.
EDIT: maybe inspecting the levels would be a way to achieve this, for instance by including/adapting the test of #32866.
For However, adding the level check part from PR #32867 when |
| "Blues", | ||
| ["red", "green", "blue"], | ||
| (None, 3), | ||
| (None, 15), |
There was a problem hiding this comment.
This test will fail for ("tab10", 15), which I will address in a follow-up PR.
| ("plasma", 15), | ||
| ("Blues", 3), | ||
| ("Blues", 15), | ||
| (["red", "green", "blue"], 3), |
There was a problem hiding this comment.
I had to combine colors and number of classes here because the list version has to match the exact number of classes.
| else: | ||
| assert_allclose(disp.surface_.colors, colors) | ||
|
|
||
| # non-regression test for issue #32866 with `contour` (currently still fails) |
There was a problem hiding this comment.
This can be fixed by integrating the approach proposed in #32867 once this is merged.
ogrisel
left a comment
There was a problem hiding this comment.
Here is an early pass of feedback with a focus on the meaning of this display and the "n_classes" params when we use this to display the output of the predict method for a regressor.
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
…ithub.com/AnneBeyer/scikit-learn into multiclass_colors_DecisionBoundaryDisplay
|
Thank you for all the comments @lucyleeow! In order to keep this PR on point, I'll only address those related to making For the remaining points, which are equally valid, I'll try to summarize them here so we don't forget anything. Those should be addressed in follow-up PRs, though.
Please add if I missed anything! |
Co-authored-by: Lucy Liu <jliu176@gmail.com>
|
I think I addressed all comments @lucyleeow. There are also a few remaining questions where feedback would be welcome. |
ogrisel
left a comment
There was a problem hiding this comment.
I had another look at this PR and this LGTM as it is. It's already a big improvement. +1 for merge and tackling the remaining points discussed in linked issues in follow-up PRs.
|
@lucyleeow ok for merge? |
lucyleeow
left a comment
There was a problem hiding this comment.
Thanks for all your work on this, it was quite complicated in the end.
Some nits only and a question but LGTM and fine to merge.
|
Thank you for all the feedback @lucyleeow and @ogrisel! I think now it is good to go. |
|
Thanks for your work and your patience @AnneBeyer ! Merging! |

Reference Issues/PRs
Fixes #32872
and thepredictpart of #32866What does this implement/fix? Explain your changes.
Previously, the case distinction for binary vs. multiclass was made based on the response dimension (see #32918 for reference), which led to multiclass
predictignoring themulticlass_colorsparameter.The colors are now selected based on the
n_classesdisplay class variable, which is extracted infrom_estimator.Note that a distinction based on the response shape still has to be made for plotting.
in two cases (contourandpcolormesh). I'm not sure if there is a more elegant solution, but I didn't find a way to handlepcolormeshin the same way forpredictas in the other cases.I adapted the docstrings and the exmple and added the response functions to the tests (and adapted them accordingly).
EDIT: The output of the code in issue #32872 now looks like this (Note that the levels problem from #32866 is still there for

predict, but this PR is only concerned with making it use the same color map as the other methods, which it does now):Since every class is plotted separately now (as it was already for response methodpredict_probaanddecision_function), this also fixes thelevelsissue noted in #32866. However, there are white lines between the classes forpredictwithcountourf. If this is a problem (and using pcolormesh is not an option for any reason), the current approach will need to be adapted further.AI usage disclosure
I used AI assistance for:
Any other comments?
I also added a test for the default value for
multiclass_colors, which was missing.