Python bindings for the Ensmallen library.
Project description
pyensmallen: python bindings for the ensmallen library for numerical optimization
Lightweight python bindings for ensmallen library. Currently supports
- L-BFGS, with intended use for optimisation of smooth objectives for m-estimation
- ADAM (and variants with different step-size routines) - makes use of ensmallen's templatization.
- Frank-Wolfe, with intended use for constrained optimization of smooth losses
- constraints are either lp-ball (lasso, ridge, elastic-net) or simplex
- (Generalized) Method of Moments estimation with ensmallen optimizers.
- this uses ensmallen for optimization [and relies on
jaxfor automatic differentiation to get gradients and jacobians]. This is the main use case forpyensmallenand is the reason for the bindings.
- this uses ensmallen for optimization [and relies on
- Estimator classes for linear, logistic, and Poisson regression with classical and robust inference for unregularized fits
See ensmallen docs for details. The notebooks/ directory walks through several statistical examples.
speed
pyensmallen is very fast. A comprehensive set of benchmarks is available in the benchmarks directory. The benchmarks are run on an intel 12th gen framework laptop. Benchmarks vary data size (sample size and number of covariates) and parametric family (linear, logistic, poisson) and compare pyensmallen with scipy and statsmodels (I initially also tried to keep cvxpy in the comparison set but it was far too slow to be in the running). At large data sizes, pyensmallen is roughly an order of magnitude faster than scipy, which in turn is an order of magnitude faster than statsmodels. So, a single statsmodels run takes around as long as a pyensmallen run that naively uses the nonparametric bootstrap for inference. This makes the bootstrap a viable option for inference in large data settings.
Installation:
Make sure your system has blas installed. On macos, this can be done via brew. Linux systems should have it installed by default. If you are using conda, you can install blas via conda-forge.
Then,
from pypi
uv pip install pyensmallen
from source
- Install
armadilloandensmallenfor your system (build from source, or via conda-forge; I went with the latter) - git clone this repository
- If you are using
uv:uv pip install --python .venv/bin/python meson meson-python ninja pybind11uv pip install --python .venv/bin/python --no-build-isolation -e .
- If you are using vanilla
pipin an activated environment:python -m pip install meson meson-python ninja pybind11python -m pip install --no-build-isolation -e .
- Profit? Or at least minimize loss?
full development environment
To install everything required to run tests and notebooks:
uv pip install --python .venv/bin/python meson meson-python ninja pybind11
uv pip install --python .venv/bin/python --no-build-isolation -e ".[full]"
Vanilla pip equivalent:
python -m pip install meson meson-python ninja pybind11
python -m pip install --no-build-isolation -e ".[full]"
The full extra includes the Python dependencies used by:
- the test suite
- GMM and autodiff examples
- benchmark notebooks
- plotting and notebook tooling
documentation
doc-generation
The repository includes a Quarto documentation site in docs/. The docs are built from three sources:
- hand-written Quarto pages in
docs/*.qmd - generated API reference pages in
docs/reference/*.qmd, built from Python and pybind11 docstrings withquartodoc - executed notebook pages in
docs/notebooks/*.ipynb
Use the render script instead of calling quarto render directly:
scripts/render_docs.sh
The script does the following:
- uses the repository
.venvas the Quarto Python runtime - forces JAX onto CPU so notebook execution is stable during docs builds
- copies the tracked notebooks from
notebooks/intodocs/notebooks/ - runs
quartodocto regenerate the API reference pages from docstrings - runs
quarto render docsto execute the notebooks and build the site
If you need the full docs toolchain first:
uv pip install --python .venv/bin/python meson meson-python ninja pybind11
uv pip install --python .venv/bin/python --no-build-isolation -e ".[full]"
The rendered site lands in docs/_site/. The generated API source pages land in docs/reference/.
from wheel
- download the appropriate
.whlfor your system from the more recent release listed inReleasesand runuv pip install ./pyensmallen...OR - copy the download url and run
uv pip install https://github.com/apoorvalal/pyensmallen/releases/download/<version>/pyensmallen-<version>-<pyversion>-linux_x86_64.whl
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyensmallen-0.4.3.tar.gz.
File metadata
- Download URL: pyensmallen-0.4.3.tar.gz
- Upload date:
- Size: 4.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19920f31e01baf07a85f44f036293c2ee392eb8f16771b6f1b62795f36fdb185
|
|
| MD5 |
a164b3e59f63e1c9442340d6d21d6332
|
|
| BLAKE2b-256 |
3d6685e6846c510b9ef4dfee178d4c3c5b5d5c6cfebc4fbed0c109c343e382f7
|
Provenance
The following attestation bundles were made for pyensmallen-0.4.3.tar.gz:
Publisher:
build.yml on apoorvalal/pyensmallen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyensmallen-0.4.3.tar.gz -
Subject digest:
19920f31e01baf07a85f44f036293c2ee392eb8f16771b6f1b62795f36fdb185 - Sigstore transparency entry: 1064672591
- Sigstore integration time:
-
Permalink:
apoorvalal/pyensmallen@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/apoorvalal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyensmallen-0.4.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyensmallen-0.4.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 17.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b79127aadf6ede452ecad7b8a5d945f0aa607ef3a3cf561e4858f6cb6cb78718
|
|
| MD5 |
2e4af1c80999001e600d12356b1b0cb6
|
|
| BLAKE2b-256 |
08f3cf6f4493f65762b974ba44257c4005a5d8a2756a86c9dba440c666733f5e
|
Provenance
The following attestation bundles were made for pyensmallen-0.4.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
build.yml on apoorvalal/pyensmallen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyensmallen-0.4.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
b79127aadf6ede452ecad7b8a5d945f0aa607ef3a3cf561e4858f6cb6cb78718 - Sigstore transparency entry: 1064672598
- Sigstore integration time:
-
Permalink:
apoorvalal/pyensmallen@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/apoorvalal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyensmallen-0.4.3-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyensmallen-0.4.3-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 15.2 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aff3cd299ec7eb21b513dd635adbc7566dd9f72bde1ddf8294c2995c72686e9e
|
|
| MD5 |
aa7917212c661465eeba613034731873
|
|
| BLAKE2b-256 |
1d17f67ad8b1f79de27c6ef0f09e855f1ebfbe645aaa89a83926c4c1fee4a9a9
|
Provenance
The following attestation bundles were made for pyensmallen-0.4.3-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
build.yml on apoorvalal/pyensmallen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyensmallen-0.4.3-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
aff3cd299ec7eb21b513dd635adbc7566dd9f72bde1ddf8294c2995c72686e9e - Sigstore transparency entry: 1064672596
- Sigstore integration time:
-
Permalink:
apoorvalal/pyensmallen@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/apoorvalal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyensmallen-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyensmallen-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 17.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a204b9c5353d56432762cbec881bbc46d0e5a525330a04cac47ad8bf9ce8944
|
|
| MD5 |
3dbfc742e1af867774a1b3d79c1ab252
|
|
| BLAKE2b-256 |
80f90ae3a76b3726b440d055dbbd64be7b5e1da5a523b3791b77ebb55ad34743
|
Provenance
The following attestation bundles were made for pyensmallen-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
build.yml on apoorvalal/pyensmallen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyensmallen-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
3a204b9c5353d56432762cbec881bbc46d0e5a525330a04cac47ad8bf9ce8944 - Sigstore transparency entry: 1064672601
- Sigstore integration time:
-
Permalink:
apoorvalal/pyensmallen@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/apoorvalal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyensmallen-0.4.3-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyensmallen-0.4.3-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 15.2 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06feac275248aa5c8f7e80d44aa8c5ac812c8950b30a6900ce6c555de2e1de21
|
|
| MD5 |
c5839db917619f00c60c2c9508ddda49
|
|
| BLAKE2b-256 |
c9a27f1a9ea8200f914e948287639bf7f227276f03574020914520412a92cb0e
|
Provenance
The following attestation bundles were made for pyensmallen-0.4.3-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
build.yml on apoorvalal/pyensmallen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyensmallen-0.4.3-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
06feac275248aa5c8f7e80d44aa8c5ac812c8950b30a6900ce6c555de2e1de21 - Sigstore transparency entry: 1064672612
- Sigstore integration time:
-
Permalink:
apoorvalal/pyensmallen@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/apoorvalal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyensmallen-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyensmallen-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 17.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66a3dea7a399e9b1c36926f9bf949de4a5e81fa9dd52d75af95f01e73b1dbe9a
|
|
| MD5 |
51daac8e45f39e72ec26dab2871a5f7c
|
|
| BLAKE2b-256 |
f42ee8f562bd18594060e7d539df4b80b47c335069c64e8ee01d3b4b15fb2a17
|
Provenance
The following attestation bundles were made for pyensmallen-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
build.yml on apoorvalal/pyensmallen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyensmallen-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
66a3dea7a399e9b1c36926f9bf949de4a5e81fa9dd52d75af95f01e73b1dbe9a - Sigstore transparency entry: 1064672609
- Sigstore integration time:
-
Permalink:
apoorvalal/pyensmallen@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/apoorvalal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyensmallen-0.4.3-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyensmallen-0.4.3-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 15.2 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
019fa97338bb80f5f5fb2da1d72327c752b3dc57d9d7dc4e6e00b95062c106ff
|
|
| MD5 |
da664989fb3798c25209e317dde8c9db
|
|
| BLAKE2b-256 |
487a3dfd6312f04a2ecbfbffee3a91d9a7ea027b0729e606cd068c800205d083
|
Provenance
The following attestation bundles were made for pyensmallen-0.4.3-cp310-cp310-macosx_11_0_arm64.whl:
Publisher:
build.yml on apoorvalal/pyensmallen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyensmallen-0.4.3-cp310-cp310-macosx_11_0_arm64.whl -
Subject digest:
019fa97338bb80f5f5fb2da1d72327c752b3dc57d9d7dc4e6e00b95062c106ff - Sigstore transparency entry: 1064672616
- Sigstore integration time:
-
Permalink:
apoorvalal/pyensmallen@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/apoorvalal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@d536edbab27033bb886f1c48b0db57a36a0ce1ae -
Trigger Event:
push
-
Statement type: