skpoly
skpoly provides drop-in polynomial feature generators that integrate with scikit-learn pipelines. The library focuses on smooth orthogonal bases such as Bernstein and Legendre polynomials, letting you capture non-linear structure with well-conditioned numerical behavior.
The project expands on the the blog series, beginning with the post “Are polynomial features the root of all evil?”.
Documentation
Explore the documentation.
Quick start
Create a pipeline that first rescales each input dimension and then expands it with Bernstein features before fitting a linear model:
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import MinMaxScaler
from sklearn.linear_model import Ridge
from skpoly import BernsteinFeatures
pipeline = make_pipeline(
MinMaxScaler(),
BernsteinFeatures(degree=8),
Ridge(alpha=1e-2),
)
pipeline.fit(X_train, y_train)
y_pred = pipeline.predict(X_test)
The MinMaxScaler step keeps every feature inside the default [0, 1] range assumed by
the polynomial bases, which in turn preserves the well-conditioned behavior of the
Bernstein and Legendre transforms.
Pairwise interaction features
For multivariate inputs you can enable tensor-product features to model pairwise (and higher-order) interactions between coordinates. Setting tensor_product=True expands the basis with every combination of the univariate polynomials:
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import MinMaxScaler
from sklearn.linear_model import LogisticRegression
from skpoly import LegendreFeatures
pipeline = make_pipeline(
MinMaxScaler(),
LegendreFeatures(degree=5, tensor_product=True),
LogisticRegression(),
)
Development
Clone the repository and install dependencies using uv:
git clone https://github.com/alexshtf/skpoly.git
cd skpoly
uv venv
source .venv/bin/activate
uv sync
Using uv keeps dependency resolution fast and reproducible.
Citation
- Use the
CITATION.cfffile. Most reference managers and services like GitHub's "Cite this repository" option can import the citation metadata directly fromCITATION.cff. - Grab the BibTeX entry. If you prefer to add the reference manually, cite the project as follows.
@software{Shtoff_skpoly_2025,
author = {Alex Shtoff},
title = {skpoly: Polynomial basis transformers for scikit-learn},
url = {https://github.com/alexshtf/skpoly},
version = {0.1.0},
year = {2025}
}
Metadata
Release files for skpoly 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| skpoly-0.1.2.tar.gz | 115.4 kB | Without provenance | Details for skpoly-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| skpoly-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for skpoly-0.1.2-py3-none-any.whl |
Total release size: 122.4 kB
Release files / skpoly-0.1.2.tar.gz
| Download URL | skpoly-0.1.2.tar.gz |
|---|---|
| Size | 115.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6aa9878e19f24b14f97789bbc07f4b01b1657a9bc47898f27734faca19dee0a0
|
|
BLAKE2b-256 checksum How to use checksums |
8518cc8df26a38ffc8b6a72ee0098c4be3dac99bfd91b95f8409a4c99f7cb9fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.2
|
Release files / skpoly-0.1.2-py3-none-any.whl
| Download URL | skpoly-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e35bf34adc442d52dd1425b8a9efd6ae5a47f2abef976cf6ed183d004ef4f3e
|
|
BLAKE2b-256 checksum How to use checksums |
1012224ded95cff3c5212ca2c6241a57666f6b50d72f8ec4b80ac297be1dcb91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.2
|
Security for skpoly 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.