Skip to content

FEA SplineTransformer difference penalty #20760

Open

Description

@lorentzenchr

Describe the workflow you want to enable

When using SplineTransformer as part of a larger feature preprocessing pipeline that ends in a linear model, e.g. Ridge, I'd like the splines to get a penalty on the (first) differences of the coefficients instead of the usual L2 penalty:

alpha * sum(squared_norm(np.diff(coef))) 

instead of

alpha * sum(squared_norm(coef))

The reason is that such a penalty penalizes the curvature (integral over square of second derivatives of splines) and therefore has better interpolation and smoothness properties.
The B-splines would then be called P-splines, see Eilers & Marx "Flexible smoothing with B-splines and penalties" https://doi.org/10.1214/ss/1038425655
Properties (see Chapter 5):

  • P-splines show no boundary effects, as many types of kernel smoothers do.
  • P-splines can fit polynomial data exactly (with polynomial degree=k, a P-spline with k+1 difference penalty or higher)
  • P-splines can conserve moments of the data. For a GLM with canonical link with P-splines of degree k+1 and a penalty of order k+1, or higher, it holds that sum_i x_i^k y_true_i = sum_i x_i^k y_predict_i.
    => 1st order P-splines conserve zero, first and 2nd momentum on training data.

Describe your proposed solution

I see 2 solutions:

  1. Somehow (SLEP006 ?) pass the information that those columns are B-splines and should get a different penalty to the final linear regressor.
  2. Add an additional option to SplineTransformer, like diff=True, that triggers to return np.diff(X) instead of X. The usual L2 penalty of, e.g. Ridge, is then equivalent to L2 of the difference of coefficients of the original X.
  3. Further ideas?

Activity

  1. ogrisel commented on Sep 27, 2021

    @ogrisel
    Member

    instead of

    alpha * sum(np.diff(coef))

    you mean instead of:

    alpha * squared_norm(coef)

    right?

    Solution 2 seems like a low maintenance solution.

    Out of curiosity, I would be interested in seeing a case where a ridge penalty on diff spline features yields a significantly different outcomes to using the original features. That would help me get a clearer picture of the inductive bias of such a reparametrization of spline linear models.

  2. lorentzenchr commented on Sep 27, 2021

    @lorentzenchr
    MemberAuthor

    Yes, I'll correct that.

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