You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add sample_weight support to QuantileTransformer #30707
@antipisa would you be interested in contributing a PR? There is already a common test named check_sample_weight_equivalence_on_dense_data that should be triggered as soon as you add the sample_weight kwarg to fit. Once this is done, the following command should pick it up:
pytest -k "check_sample_weight_equivalence and QuantileTransformer" sklearn/tests/test_common.py -v -s
You might want to adjust some non-default parameter values for that check in PER_ESTIMATOR_CHECK_PARAMS in sklearn/utils/_test_common/instance_generator.py.
Note that when subsampling is enabled, we need to follow a similar strategy as implemented in KBinsDiscretizer. At the time of writing, the code for KBinsDiscretizer in main is still half broken, but there is a fix that is almost ready to be merged: #29907. You can take a look at this PR for inspiration.
We are working on tooling to help test the case where the estimator's fit is stochastic (depends on random_state which is the case when subsampling is enabled). You can track the latest progress here: #16298 (comment)
a quick update: the feature request is now being actively worked on in PR #32761, which builds on the previous effort in #31147 and incorporates the unified _weighted_percentile implementation suggested in the reviews
the progress looks promising, and it should bring full sample_weight support to QuantileTransformer once finalized.
QuantileTransformer.fit now accepts sample_weight following the merge of #32761, which appears to address the request here. Is there any remaining work covered by this issue, or can it be closed?
Activity
lesteve commentedon Jan 23, 2025
Searching in the issue tracker, looks like this feature is in scope if I understand correctly #20522 (comment).
cc @snath-xoc and @jeremiedbb for an informed opinion, since they have been working on sample weights support recently.
[-]Add sample_weight support to QuantileTransformer?[/-][+]Add sample_weight support to QuantileTransformer[/+]ogrisel commentedon Feb 3, 2025
@antipisa would you be interested in contributing a PR? There is already a common test named
check_sample_weight_equivalence_on_dense_datathat should be triggered as soon as you add thesample_weightkwarg tofit. Once this is done, the following command should pick it up:You might want to adjust some non-default parameter values for that check in
PER_ESTIMATOR_CHECK_PARAMSinsklearn/utils/_test_common/instance_generator.py.Note that when subsampling is enabled, we need to follow a similar strategy as implemented in
KBinsDiscretizer. At the time of writing, the code forKBinsDiscretizerinmainis still half broken, but there is a fix that is almost ready to be merged: #29907. You can take a look at this PR for inspiration.We are working on tooling to help test the case where the estimator's
fitis stochastic (depends onrandom_statewhich is the case when subsampling is enabled). You can track the latest progress here: #16298 (comment)kaekkr commentedon Apr 3, 2025
I will take this!
Mohataseem89 commentedon Dec 8, 2025
a quick update: the feature request is now being actively worked on in PR #32761, which builds on the previous effort in #31147 and incorporates the unified
_weighted_percentileimplementation suggested in the reviewsthe progress looks promising, and it should bring full
sample_weightsupport toQuantileTransformeronce finalized.csadorf commentedon Sep 29, 2026
QuantileTransformer.fitnow acceptssample_weightfollowing the merge of #32761, which appears to address the request here. Is there any remaining work covered by this issue, or can it be closed?