Skip to content

Add sample_weight support to QuantileTransformer #30707

@antipisa

Description

@antipisa

Describe the workflow you want to enable

Would be good to get sample_weight support for QuantileTransformer for dealing with sparse or imbalanced data, a la #15601.

scaler = QuantileTransformer(output_distribution="normal")

scaler.fit(X, sample_weight=w)

Describe your proposed solution

As far as I know it would just require adding the weight argument to the quantiles_ computation in np.nanpercentile.

KBinsDiscretizer supports sample_weight and with strategy='quantile', encode='ordinal' this behavior can be achieved but it is much, much slower.

Describe alternatives you've considered, if relevant

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ModerateAnything that requires some knowledge of conventions and best practicesNew Feature

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions