Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix HTML display performance when user has many features - #34362

Merged
ArturoAmorQ merged 11 commits into
scikit-learn:mainfrom
DeaMariaLeon:many-features
Jun 23, 2026
Merged

Fix HTML display performance when user has many features #34362
ArturoAmorQ merged 11 commits into
scikit-learn:mainfrom
DeaMariaLeon:many-features

Conversation

@DeaMariaLeon

Copy link
Copy Markdown
Member

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?

@github-actions github-actions Bot added module:utils CI:Linter failure The linter CI is failing on this PR labels Jun 22, 2026
@DeaMariaLeon
DeaMariaLeon marked this pull request as ready for review June 22, 2026 12:15
@DeaMariaLeon DeaMariaLeon moved this to Todo in Labs Jun 22, 2026
@DeaMariaLeon DeaMariaLeon moved this from Todo to In progress in Labs Jun 22, 2026
@DeaMariaLeon DeaMariaLeon moved this from In progress to Blocked in Labs Jun 22, 2026
@github-actions github-actions Bot removed the CI:Linter failure The linter CI is failing on this PR label Jun 22, 2026

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

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"),

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.

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 ogrisel 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, thank you very much for the fix.

@AnneBeyer AnneBeyer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Image

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

Merging after @ogrisel and @AnneBeyer's approvals. Thanks @DeaMariaLeon :)

@ArturoAmorQ
ArturoAmorQ enabled auto-merge (squash) June 23, 2026 12:24
@DeaMariaLeon

Copy link
Copy Markdown
Member Author

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.

@ArturoAmorQ
ArturoAmorQ merged commit aeadb51 into scikit-learn:main Jun 23, 2026
36 checks passed
@github-project-automation github-project-automation Bot moved this from Blocked to Done in Labs Jun 23, 2026
@DeaMariaLeon
DeaMariaLeon deleted the many-features branch June 23, 2026 13:22
prady0t pushed a commit to prady0t/scikit-learn that referenced this pull request Sep 2, 2026
jherland added a commit to jherland/nixpkgs that referenced this pull request Sep 6, 2026
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]>
jherland added a commit to jherland/nixpkgs that referenced this pull request Sep 6, 2026
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]>
jherland added a commit to jherland/nixpkgs that referenced this pull request Sep 6, 2026
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]>
jherland added a commit to jherland/nixpkgs that referenced this pull request Sep 6, 2026
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]>
jherland added a commit to jherland/nixpkgs that referenced this pull request Sep 7, 2026
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]>
jherland added a commit to jherland/nixpkgs that referenced this pull request Sep 7, 2026
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]>
@jeremiedbb jeremiedbb mentioned this pull request Sep 8, 2026
14 tasks
jeremiedbb pushed a commit to jeremiedbb/scikit-learn that referenced this pull request Sep 9, 2026
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.

Performance issue with HTML representations of estimators with 'many' features with sklearn 1.9.0

4 participants