question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Spline Transformer

See original GitHub issue

Describe the workflow you want to enable

I propose to add a SplineTransformer to preprocessing. This is similiar to PolynomialFeatures, but gives more flexibility (and numerical stability) for linear models to deal with continuous numerical features.

from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import SplineTransformer
from sklearn.pipeline import make_pipeline

# get data X, y
...
model = make_pipeline(SplineTransformer(degree=3, n_knots=20,
                                        positioning='quantile'),
                      LogisticRegression())
model.fit(X, y)

Describe your proposed solution

Add SplineTransformer and internally use scipy for splines. Start with - 1-dimensional b-splines - equidistant knots - quantile based knots

Additional context

Patsy has an implementation of those that matches the R versions.

References

Eilers, Marx “Flexible Smoothing with B-splines and Penalties” passes the scikit-learn inclusion criteria by some margin 😏

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
thomasjpfancommented, Jul 4, 2020

Me and @amueller have been interested in splines in the context of GAMs which would start with 1-D splines for each feature. I have been planning on pushing this forward for scikit-learn.

3reactions
jnothmancommented, Jul 6, 2020

I think a lot of the feature-based machine learning community could learn more about spline bases in predictive modelling, and it would be valuable to have these available and discussed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sklearn.preprocessing.SplineTransformer
Generate a new feature matrix consisting of n_splines=n_knots + degree - 1 ( n_knots - 1 for extrapolation="periodic" ) spline basis functions (B-splines) ......
Read more >
Basis Expansions and Smoothing Splines - Branch Energy
transformed = transformer.transform(x_points.reshape(-1, ... Let's define a cubic function and add it to the plot above:.
Read more >
Irregularly-Sampled Time Series Modeling with Spline Networks
Observations made in continuous time are often irregular and contain the missing values across different channels.
Read more >
How to Replace a Spline Segment with Straight Lines - YouTube
See more at: http://www.goengineer.com/products/solidworks/Learn how to replace a spline segment with a straight line in SOLIDWORKS.
Read more >
Scikit-learn 1.0 Supports Spline Transformers, Quantile ... - InfoQ
... including spline transformers, quantile regression, online one-class support vector machines (SVM), and an improved plotting API.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found