Repository navigation
Quantile transformer sample weight - #32761
Conversation
…rcentile, add XFAIL for sparse_data
|
Hmmmm I am running with an issue that seems similar to here: actions/runner#449 |
|
the integration of |
antoinebaker
left a comment
There was a problem hiding this comment.
Thanks @snath-xoc for the PR ! The logic seems fine to me.
I made a few suggestions regarding the docstrings / warning message etc, but I don't have a strong opinion. I let you make your own mind :)
Do not hesitate to ping me when it's ready for another review.
| if sample_weight is None: | ||
| n_samples = X.shape[0] | ||
| else: | ||
| sample_weight = _check_sample_weight(sample_weight, X, dtype=X.dtype) | ||
| n_samples = np.sum(sample_weight) |
There was a problem hiding this comment.
If n_samples stands for the sum of sample weights, we should perhaps mention it in the docstring and warning messages ? But on the other hand it may be too verbose (at each time saying "the number of samples or the total sum of weights if provided").
There was a problem hiding this comment.
Perhaps a middle ground would be to replace total number of samples -> effective number of samples in the warning messages and the n_quantiles docstring ? Maybe we should replace n_samples by a better name ?
There was a problem hiding this comment.
@antoinebaker yes we could use effective_sample_size this was at some point tried in the #30751? Let me update.
There was a problem hiding this comment.
check if it makes sense now?
| if self.n_quantiles > n_samples: | ||
| warnings.warn( | ||
| "n_quantiles (%s) is greater than the total number " | ||
| "of samples (%s). n_quantiles is set to " | ||
| "n_samples." % (self.n_quantiles, n_samples) | ||
| ) |
There was a problem hiding this comment.
Here is the warning message in question in #32761 (comment)
We should set n_quantiles=150 in this doc example now that it's not capped. |
|
@ogrisel @jeremiedbb and @antoinebaker this should be ready now? |
#8691) ~QuantileTransformer now changes behaviour depending on which version of scikit-learn is installed. The goal is to match scikit-learn's behaviour in cuml.~ This commit also fixes a pre-existing bug in the handling of `subsample=None`. This change branches from `main` and targets it because scikit-learn 1.10 hasn't been released yet and will probably only be released at the end of 2026. This means this change does not need to be part of the 26.10 release of cuml. xref scikit-learn/scikit-learn#32761 Closes #8693 Authors: - Tim Head (https://github.com/betatim) Approvers: - Simon Adorf (https://github.com/csadorf) - Jim Crist-Harif (https://github.com/jcrist) URL: #8691
Reference Issues/PRs
Follow up on previously closed PR #31147 and issue #30707
What does this implement/fix? Explain your changes.
Adds sample weights within the QuantileTransformer under preprocessing using the _weighted_percentile function.