Add Spline Transformer
See original GitHub issueDescribe 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:
- Created 3 years ago
- Reactions:2
- Comments:14 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.