Skip to content

ENH improve visual HTML estimator representation - #26616

Merged
betatim merged 104 commits into
scikit-learn:mainfrom
rcap107:rcap
Oct 25, 2023
Merged

betatim merged 104 commits into
scikit-learn:mainfrom
rcap107:rcap

Conversation

@rcap107

@rcap107 rcap107 commented Jun 19, 2023

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Addressing task 2 in #26595

What does this implement/fix? Explain your changes.

I am working on linking the html repr of the estimator with the documentation link of the estimator.

For the moment I am moving the css stylesheet to a separate file.

Any other comments?

Not ready for merge, the html will be updated further later.

@GaelVaroquaux GaelVaroquaux 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.

A few comments

Comment thread sklearn/base.py Outdated
Comment thread sklearn/base.py Outdated
Comment thread sklearn/base.py Outdated
Comment thread sklearn/utils/_estimator_html_repr.py Outdated
Comment thread sklearn/utils/_estimator_html_repr.py Outdated
@github-actions

github-actions Bot commented Jun 20, 2023 •

Copy link
Copy Markdown

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 4ee853d. Link to the linter CI: here

@GaelVaroquaux GaelVaroquaux 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.

A review, with comments on the tests, @Ines1999

Comment thread doc/developers/develop.rst Outdated
Comment thread doc/developers/develop.rst Outdated
Comment thread doc/developers/develop.rst Outdated
Comment thread ines-test-base.py Outdated
Comment thread ines-test-base.py Outdated
Comment thread ines-test-base.py Outdated
Comment thread ines-test-base.py Outdated
Comment thread ines-test-pipelines.py Outdated
Comment thread ines-test-pipelines.py Outdated

pipeline5 = Pipeline([
('classifier', stacking_classifier)
])

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'm not sure that all these objects are important. We just need one that creates a _VisualBlock

Comment thread ines-test-pipelines.py Outdated
@glemaitre
glemaitre marked this pull request as ready for review October 21, 2023 13:45

@glemaitre glemaitre 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.

I put this PR "ready for review".

In short, I fixed the dark/light mode. I put everything inside a mixin such that it is well tested. I made the way to retrieve the documentation more flexible (providing a callable) in case that what we have in scikit-learn would not be enough (I am thinking ahead in imbalanced-learn. I added the documentation in a specific section with a warning since it is all private for the moment and should be considered experimental.

In a future PR, I think that we should have a section in the User Guide describing how to interact with these diagram/representation. Currently we have a section in the composition section but this is kind of hidden. I am thinking that we should go back to the visualization section and introduce the tool there.

@glemaitre

Copy link
Copy Markdown
Member

pinging @GaelVaroquaux @betatim to finalize this one ;)

@glemaitre glemaitre 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.

Approving myself as well :)

Comment thread sklearn/utils/_estimator_html_repr.py
@GaelVaroquaux

Copy link
Copy Markdown
Member

Should I review this (ie: is my review acceptable, or am I tainted by the fact that I contributed to this PR?)

@glemaitre

Copy link
Copy Markdown
Member

Should I review this (ie: is my review acceptable, or am I tainted by the fact that I contributed to this PR?)

Yes, please. The PR is ready for review.

@GaelVaroquaux

Copy link
Copy Markdown
Member

Looks beautiful to me (this is how it renders under Jupyter, firefox, ubuntu):
image

@glemaitre

Copy link
Copy Markdown
Member

Be aware that I included the feature shown in #27637

The main color background and font color should adapt themselves in notebook and vs-code:

image

For other IDE, it will fallback to the current OS-specific settings. This can be improved in the future.

Comment thread doc/developers/develop.rst Outdated
Comment thread doc/developers/develop.rst Outdated
Comment thread doc/developers/develop.rst Outdated
Comment thread sklearn/utils/_estimator_html_repr.py Outdated
Comment thread sklearn/utils/_estimator_html_repr.py Outdated
Comment thread sklearn/utils/_estimator_html_repr.py
Comment thread sklearn/utils/_estimator_html_repr.py Outdated
Comment thread sklearn/utils/_estimator_html_repr.py Outdated
Comment thread sklearn/utils/_estimator_html_repr.py Outdated
Comment thread sklearn/utils/_estimator_html_repr.py Outdated
@GaelVaroquaux

Copy link
Copy Markdown
Member

Are there still pending comments from Tim to be addressed? Having a look at the PR it seems to me that it's the case, but maybe I am misreading this.

@glemaitre

Copy link
Copy Markdown
Member

I normally addressed all @betatim comments.

@GaelVaroquaux GaelVaroquaux 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. Thanks!!

@GaelVaroquaux

Copy link
Copy Markdown
Member

@betatim : this is good with me.
Please merge if you are happy with the changes.

@betatim
betatim merged commit 458c558 into scikit-learn:main Oct 25, 2023
@betatim

betatim commented Oct 25, 2023

Copy link
Copy Markdown
Member

The future will be colourful! Unless you are using dark mode in which case it'll be a bit more muted :D :D

Thanks a lot for this cool work!

glemaitre added a commit to glemaitre/scikit-learn that referenced this pull request Oct 31, 2023
Co-authored-by: ines.ibnukhsein <ines.ibnukhsein@dataiku.com>
Co-authored-by: Gael Varoquaux <gael.varoquaux@normalesup.org>
Co-authored-by: Ines <ines-99@ukr.net>
Co-authored-by: Lilian <lilian@boulard.fr>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Tim Head <betatim@gmail.com>
@GaelVaroquaux

Copy link
Copy Markdown
Member

Darn, the support of the dark mode kinda screwed up the display in the documentation

https://scikit-learn.org/dev/auto_examples/miscellaneous/plot_estimator_representation.html:
image

@glemaitre

Copy link
Copy Markdown
Member

Feel free to merge #27659 @GaelVaroquaux to fix it :)

REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
Co-authored-by: ines.ibnukhsein <ines.ibnukhsein@dataiku.com>
Co-authored-by: Gael Varoquaux <gael.varoquaux@normalesup.org>
Co-authored-by: Ines <ines-99@ukr.net>
Co-authored-by: Lilian <lilian@boulard.fr>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Tim Head <betatim@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants