Repository navigation
BUG fix sparse QuantileTransformer subsampling - #35274
Open
rushabh-borkar wants to merge 2 commits into
Open
rushabh-borkar wants to merge 2 commits into
rushabh-borkar wants to merge 2 commits into
Conversation
Co-authored-by: Copilot App <[email protected]>
|
Thank you for opening your first pull request to scikit-learn! 🎉 To help get your contribution reviewed, please make sure that:
|
Co-authored-by: Copilot App <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
Fixes #34857.
What does this implement/fix? Explain your changes.
This PR fixes sparse
QuantileTransformersubsampling whenignore_implicit_zeros=False.Previously, the implementation scaled the number of sampled non-zero values by the column density. For a very sparse feature,
subsample=10_000could therefore retain only a small number of non-zero observations. The resulting quantiles were noisy and could distort the transformed distribution.The implementation now samples up to
subsamplenon-zero values directly and uses weighted percentiles to represent the exact number of implicit zeros. This preserves the zero mass without materializing an array proportional to the number of input rows. Existing behavior is preserved forignore_implicit_zeros=Trueand for columns that do not require subsampling.A regression test uses a very sparse column with 100,000 rows and verifies that the subsampled quantiles remain close to the full-data quantiles. The test fails with the previous density-scaled sampling logic.
A changelog entry was added at
doc/whats_new/upcoming_changes/sklearn.preprocessing/35274.fix.rst.Validation:
git diff --check— passed.python -m compileall -q sklearn\\preprocessing\\_data.py sklearn\\preprocessing\\tests\\test_data.py— passed.Introduce yourself
This contribution addresses the sparse
QuantileTransformersubsampling bug reported in #34857.AI usage disclosure
I used AI assistance for:
Any other comments?
The fix is intentionally limited to the sparse subsampling path and keeps the existing full-materialization behavior for non-subsampled sparse columns.
This pull request includes code written with the assistance of AI.
The code has not yet been reviewed by a human.