Fix HTML display performance when user has many features - #34362
Conversation
ogrisel
left a comment
There was a problem hiding this comment.
Please add a changelog entry to document the fix of this performance bug.
I think we could test more specifically at the edges of the _MAX_DISPLAY_FEATURES value.
Besides, LGTM.
| @pytest.mark.parametrize( | ||
| "num_features, expected_count", | ||
| [ | ||
| (200, "200"), |
There was a problem hiding this comment.
Let's also add a test for the boundary case with 101 features. And also check that the truncation does not happen for exactly 100 features.
ogrisel
left a comment
There was a problem hiding this comment.
LGTM, thank you very much for the fix.
AnneBeyer
left a comment
There was a problem hiding this comment.
Thank you @DeaMariaLeon, LGTM! I tested it with the minimal reproducer from the issue and can confirm that it runs smoothly. I also think limiting the copying to the first 100 is fine in these cases.
One small nit/question (unrelated to the changes in this PR):
Would it be very complicated to align the scroll bar to the width of the features box?
ArturoAmorQ
left a comment
There was a problem hiding this comment.
Merging after @ogrisel and @AnneBeyer's approvals. Thanks @DeaMariaLeon :)
|
Thanks for the approvals! @AnneBeyer I implemented your feedback (removed a width constrain). Now the table is always as wide as it's parent (the "features-container" division), so the scroll is aligned as you mentioned. |
Backports scikit-learn/scikit-learn#34362, which fixes sluggish HTML representation of estimators with many features. The fix landed after the 1.9.0 release; drop it once we update to the version that includes it. Also drop nilearn's !=1.9.0 scikit-learn exclusion, which was added specifically for this issue. Assisted-by: Claude Sonnet 4.6 <[email protected]>
Backports scikit-learn/scikit-learn#34362, which fixes sluggish HTML representation of estimators with many features. The fix landed after the 1.9.0 release; drop the patch once we update to the version that includes it. Assisted-by: Claude Sonnet 4.6 <[email protected]>
Backports scikit-learn/scikit-learn#34362, which fixes sluggish HTML representation of estimators with many features. The fix landed after the 1.9.0 release; drop the patch once we update to the version that includes it. Assisted-by: Claude Sonnet 4.6 <[email protected]>
Backports scikit-learn/scikit-learn#34362, which fixes sluggish HTML representation of estimators with many features. The fix landed after the 1.9.0 release; drop the patch once we update to the version that includes it. Assisted-by: Claude Sonnet 4.6 <[email protected]>
Backports scikit-learn/scikit-learn#34362, which fixes sluggish HTML representation of estimators with many features. The fix landed after the 1.9.0 release; drop the patch once we update to the version that includes it. Assisted-by: Claude Sonnet 4.6 <[email protected]>
Backports scikit-learn/scikit-learn#34362, which fixes sluggish HTML representation of estimators with many features. The fix landed after the 1.9.0 release; drop the patch once we update to the version that includes it. Assisted-by: Claude Sonnet 4.6 <[email protected]>
Reference Issues/PRs
Fixes #34203
What does this implement/fix? Explain your changes.
Sets a maximum number of displayed features, and it only lets the user to copy-paste the first 100 features.
I wonder if it makes sense to copy-paste millions of features to the clipboard. That's why I'm proposing this way.
First time contributor introduction
AI usage disclosure
I used AI assistance for:
Any other comments?