-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
ENH: Display the number of output features #31937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
I wonder if I can have feedback before I add/fix more tests. |
|
One feedback of @ogrisel IRL is to directly show the feature names using the same pattern than "Parameters". I personally agree with @jeremiedbb feedback: I would like something smaller. Also write now, we have to mention "output features" instead of simply "features" because of the ambiguity input/output when attached to the estimator. So the proposal to make the "feature" being blocks leaving on their own is nice I think because there is not ambiguity anymore. |
|
I'll work on this, thanks for the feedback. Just:
Should I add the feature names on this PR? I remember @glemaitre saying that they should be added on a separate PR. |
I want to dissociate it at first but since we are going to create a new block, it might be better to have directly the feature names as well. |
a2c76ba to
9c93171
Compare
glemaitre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It really looks good. Now I just think that we need to work more in depth for the tests but the code is clean.
| max-height: 10em; | ||
| overflow: auto; | ||
| scrollbar-width: thin; | ||
| padding: .25em .5em; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be inline with other tables. FYI, we don't need to take care about the vertical scrolling bar. The text will not overlap with it.
| padding: .25em .5em; | |
| padding: .25em 0.1rem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glemaitre this change makes on a jupyter notebook to have a higher space for the other tables. It would look like this:

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I included the change anyway.
|
|
||
| def test_features_number_not_included(): | ||
| est = LogisticRegression(C=10.0, fit_intercept=False) | ||
| assert "Output features" not in estimator_html_repr(est) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create a test_features.py file to add those new test. I think that you need to update those tests. I think that we can test:
- Make sure that we don't show anything when the estimator is not fitted
- Make sure that we have have the boxes when the estimator is fitted
- Make sure that we have the right feature names in the table
- Make sure that it have the expected number of "X features" when having a column transformer in a pipeline
- Make sure that thing works even with
Transformerthat do not provide the full scikit-learn API. In short, we should add asklearn.utils._testing.MinimalTransformerin aPipelineand check that it does not crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - but I'm using estimator_html_repr to test. I wonder what think about that.
| # | ||
| print( | ||
| "accuracy of the best model from randomized search: " | ||
| "accuracy of the best model from randomized search: " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remember to revert this change for the final merge ;)
|
|
||
| estimator_html_repr(model) | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot wrote the tests that follow.
WDYT?
|
It will be worth adding a changelog for this improvement as well. |


Reference Issues/PRs
Towards #26595
What does this implement/fix? Explain your changes.
This is part of "Display the (public) fitted attributes".
Any other comments?
Example
