Skip to content

Allow sample_weights in SplineTransformer.fit method #20522

Closed

Description

@mlondschien

This is only relevant for knots="quantile".

Sample weights are central in many applications (e.g. risk modelling in insurance). The missing support for sample weights prohibits the use of the SplineTransformer with knots="quantile" in these applications. Implementing this would be a minor change, making a slight adjustment to SplineTransformer._get_base_knot_positions. Thus IMO the benefit of wider usage would outweigh the slight increase in complexity.

There is a precedent for using sample weights in transformers' fit methods, see e.g. the Normalizer.

I can prepare a PR.

cc @lbittarello @lorentzenchr @ogrisel

Activity

  1. lbittarello commented on Jul 13, 2021

    @lbittarello
    Contributor

    To benefit fully from sample weights, it'd also be ideal for the column transformer passed fit parameters to the transformers, which isn't the case at present (unlike the pipeline), though that's a separate issue.

  2. lorentzenchr commented on Jul 14, 2021

    @lorentzenchr
    Member

    I see the use case for having sample_weight support in SplineTransformer. I also think, that applying the sample weights to the quantiles as weighted quantiles is the right behavior as "weighted splines" don't make sense to me.
    I wonder why QuantileTransformer and KBinsDiscretizer(strategy="quantile") don't support sample_weight.

  3. mlondschien commented on Jul 19, 2021

    @mlondschien
    ContributorAuthor

    Thanks @lorentzenchr. In that case, could you have a look at #20526 and #20528?

  4. glemaitre commented on Jul 21, 2021

    @glemaitre
    Member

    I wonder why QuantileTransformer and KBinsDiscretizer(strategy="quantile") don't support sample_weight.

    I think that they are only missing features :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions