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 StandardScaler (and friends?) #15601
Via #15583:
it would be nice to have sample_weight support in StandardScaler. I don't see how to do that for sparse data right now, though (without touching the Cython code).
Touching the cython code doesn't look that hard, but it would require deciding if we want to duplicate the functions to handle the weighted case, or whether we can reuse the exisiting code paths (risking loss in both efficiency and precision).
Computing weighted mean and variance (for non-sparse matrix) in partial_fit requires applying _incremental_mean_and_var twice or developing new (to my knowledge) method similar to _incremental_mean_and_var, but with sample_weight (like here). I believe latter option is far better and should be dealt with another issue. What do you think, guys?
Activity
jnothman commentedon Nov 13, 2019
Touching the cython code doesn't look that hard, but it would require deciding if we want to duplicate the functions to handle the weighted case, or whether we can reuse the exisiting code paths (risking loss in both efficiency and precision).
NicolasHug commentedon Nov 13, 2019
In #14696 we duplicate. I think it's worth it as long as the function is simple enough?
lorentzenchr commentedon Nov 13, 2019
This would also help a "sparse" solution of #3702.
amueller commentedon Nov 13, 2019
Actually, I'm using a numpy/scipy based helper in my PR and I think this should be fine as long as we don't need inplace?
panpiort8 commentedon Nov 27, 2019
I can take that issue
panpiort8 commentedon Nov 30, 2019
Computing weighted mean and variance (for non-sparse matrix) in partial_fit requires applying _incremental_mean_and_var twice or developing new (to my knowledge) method similar to _incremental_mean_and_var, but with sample_weight (like here). I believe latter option is far better and should be dealt with another issue. What do you think, guys?
jnothman commentedon Dec 2, 2019
amueller commentedon Dec 3, 2019
I think we should just use a non-cython variant as I did here:
https://github.com/scikit-learn/scikit-learn/pull/15583/files#diff-ce89de6ba5554a75729d37eca95fc24dR835
panpiort8 commentedon Dec 5, 2019
But we want StandardScaler to compute stats in incremental (batch) manner, which is, I believe, quite different.
lorentzenchr commentedon Feb 10, 2021
#18510 and #18682 added
sample_weighttoStandardScalerfor dense and sparse input.worthy7 commentedon Oct 20, 2024
Why would this be useful for SS? How are the weights used?