Skip to main content

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 jax for automatic differentiation to get gradients and jacobians]. This is the main use case for pyensmallen and is the reason for the bindings.
  • 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

  1. Install armadillo and ensmallen for your system (build from source, or via conda-forge; I went with the latter)
  2. git clone this repository
  3. If you are using uv:
    • uv pip install --python .venv/bin/python meson meson-python ninja pybind11
    • uv pip install --python .venv/bin/python --no-build-isolation -e .
  4. If you are using vanilla pip in an activated environment:
    • python -m pip install meson meson-python ninja pybind11
    • python -m pip install --no-build-isolation -e .
  5. 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 with quartodoc
  • 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 .venv as the Quarto Python runtime
  • forces JAX onto CPU so notebook execution is stable during docs builds
  • copies the tracked notebooks from notebooks/ into docs/notebooks/
  • runs quartodoc to regenerate the API reference pages from docstrings
  • runs quarto render docs to 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 .whl for your system from the more recent release listed in Releases and run uv 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

Documentation

GitHub Pages is served from the gh-pages branch. This repository does not auto-publish the website when master changes, so updating the site is a separate step.

After rendering the documentation site into docs/_site/, publish it with:

scripts/publish_docs.sh

The script:

  • creates a temporary worktree for gh-pages
  • syncs docs/_site/ into that worktree
  • commits the site update if anything changed
  • pushes gh-pages to origin

Metadata

Release files for pyensmallen 0.4.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyensmallen 0.4.5
File Size Uploaded
pyensmallen-0.4.5.tar.gz 4.6 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for pyensmallen 0.4.5
File
pyensmallen-0.4.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
pyensmallen-0.4.5-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
pyensmallen-0.4.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
pyensmallen-0.4.5-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
pyensmallen-0.4.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
pyensmallen-0.4.5-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
pyensmallen-0.4.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
pyensmallen-0.4.5-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
pyensmallen-0.4.5-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
pyensmallen-0.4.5-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 166.8 MB

Release files / pyensmallen-0.4.5.tar.gz

Download URL pyensmallen-0.4.5.tar.gz
Size 4.6 MB
Tags Source
SHA-256 checksum
How to use checksums
3a41d768aa84f3b7287f1c144cf3f738b01080b452e607b4c71e163abeaad154
BLAKE2b-256 checksum
How to use checksums
0af12d4c87f7cc7a1d34ede0189d360d1388d3d89084ae96a448d14fd5fded2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 19, 2026.

Transparency log

Release files / pyensmallen-0.4.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL pyensmallen-0.4.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 17.2 MB
Tags CPython 3.14 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
4d2526f64b87457cff7d89dc64e20179ddbfa41208666db7f14dbef6642b92e1
BLAKE2b-256 checksum
How to use checksums
a5b3c967e0c86c10250f2238688a32102ba9b19cbd34d2fdb93650e7eb8504bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 19, 2026.

Transparency log

Release files / pyensmallen-0.4.5-cp314-cp314-macosx_11_0_arm64.whl

Download URL pyensmallen-0.4.5-cp314-cp314-macosx_11_0_arm64.whl
Size 15.2 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9c5cdd738011a4d4af7dbdeefe260c5fc0d9715e87d3b38d77def678df3ba5fd
BLAKE2b-256 checksum
How to use checksums
83c8662ec5d703751b1bd4f0ff9bd26326cfc6eab1e00feafecdb71f894907d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 19, 2026.

Transparency log

Release files / pyensmallen-0.4.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL pyensmallen-0.4.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 17.2 MB
Tags CPython 3.13 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
80e676328b3e85dd8390b3e485fcd461b181a90713f5e79023c16f542d4afcd5
BLAKE2b-256 checksum
How to use checksums
5523cdb4459ce2e8324d1b8bfc15182f09438d70e00f1de8b59231248d96240a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 19, 2026.

Transparency log

Release files / pyensmallen-0.4.5-cp313-cp313-macosx_11_0_arm64.whl

Download URL pyensmallen-0.4.5-cp313-cp313-macosx_11_0_arm64.whl
Size 15.2 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
28ec1cb9d20bac6672964a5975fc26d4a188dd94dbd98d473ff288960aef2f7e
BLAKE2b-256 checksum
How to use checksums
dff2bff20af4ba7e1e586c7c48e31819f97b94ee842311b26b394dcaec36dffe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 19, 2026.

Transparency log

Release files / pyensmallen-0.4.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL pyensmallen-0.4.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 17.2 MB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
df760a0a660ec326a7889fb891af04b9ec22652dfb2acf30b2d3ab2247dbd625
BLAKE2b-256 checksum
How to use checksums
1bf03ac4e618c547605fde3628368a1d11539eb0a258d9fb1b91a7f782e84cb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 19, 2026.

Transparency log

Release files / pyensmallen-0.4.5-cp312-cp312-macosx_11_0_arm64.whl

Download URL pyensmallen-0.4.5-cp312-cp312-macosx_11_0_arm64.whl
Size 15.2 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e540e9abe93edd82732d30e27180f0f7a2daf09e7eae4762bfeb43df8756dc5d
BLAKE2b-256 checksum
How to use checksums
e360a6844578b8fde11127258b65824729f9542bb8b9ce45a137bb21a94a199d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 19, 2026.

Transparency log

Release files / pyensmallen-0.4.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL pyensmallen-0.4.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 17.2 MB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
70e9e18ba6681bc409c749bca5f1d28c732791b27903efc9a7c5435ae3213bd6
BLAKE2b-256 checksum
How to use checksums
cc6f3fe26ada3c97db7862dec46b607e17924a0733603b69d3a17bcb8601e110
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 19, 2026.

Transparency log

Release files / pyensmallen-0.4.5-cp311-cp311-macosx_11_0_arm64.whl

Download URL pyensmallen-0.4.5-cp311-cp311-macosx_11_0_arm64.whl
Size 15.2 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3774a589e9f130de0c302c4f9af0a01b08720c744ae091bb55334d605de0130a
BLAKE2b-256 checksum
How to use checksums
b7ed8f1e69b66f8d00b02bc341b483713da308749b091d90afebbbd28d7ff5f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 19, 2026.

Transparency log

Release files / pyensmallen-0.4.5-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL pyensmallen-0.4.5-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 17.2 MB
Tags CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
78c7df62d22fff3400efbc259b2f78de492637db8127c18917d87a19203a002e
BLAKE2b-256 checksum
How to use checksums
80265901d6452510ec7c041e60cd2e777b9eb0d0fc57ce5bdf299e441279bf0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 19, 2026.

Transparency log

Release files / pyensmallen-0.4.5-cp310-cp310-macosx_11_0_arm64.whl

Download URL pyensmallen-0.4.5-cp310-cp310-macosx_11_0_arm64.whl
Size 15.2 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
50537ecdc879944bf84b96af4b09cbd95347404e1125f0fa838382f7d10fcb13
BLAKE2b-256 checksum
How to use checksums
4911aceb8ba537293f4c613f697d479b4a063965100074f8ffa89f9afeaf8806
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.5 This release

11 release files

0.4.4

7 release files

0.4.3

7 release files

0.4.2

4 release files

0.4.1

7 release files

0.3.2

7 release files

0.2.9

7 release files

0.2.7

7 release files

0.2.6

7 release files

0.0.3

6 release files

0.0.2

6 release files

0.0.1

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page