Skip to main content

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 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyensmallen-0.4.5.tar.gz (4.6 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyensmallen-0.4.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (17.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyensmallen-0.4.5-cp314-cp314-macosx_11_0_arm64.whl (15.2 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pyensmallen-0.4.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (17.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyensmallen-0.4.5-cp313-cp313-macosx_11_0_arm64.whl (15.2 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyensmallen-0.4.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (17.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyensmallen-0.4.5-cp312-cp312-macosx_11_0_arm64.whl (15.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyensmallen-0.4.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (17.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyensmallen-0.4.5-cp311-cp311-macosx_11_0_arm64.whl (15.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyensmallen-0.4.5-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (17.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyensmallen-0.4.5-cp310-cp310-macosx_11_0_arm64.whl (15.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file pyensmallen-0.4.5.tar.gz.

File metadata

  • Download URL: pyensmallen-0.4.5.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

Hashes for pyensmallen-0.4.5.tar.gz
Algorithm Hash digest
SHA256 3a41d768aa84f3b7287f1c144cf3f738b01080b452e607b4c71e163abeaad154
MD5 fda4e0cf9e2ea02ab09e85fcd8b235b0
BLAKE2b-256 0af12d4c87f7cc7a1d34ede0189d360d1388d3d89084ae96a448d14fd5fded2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyensmallen-0.4.5.tar.gz:

Publisher: build.yml on apoorvalal/pyensmallen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyensmallen-0.4.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyensmallen-0.4.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4d2526f64b87457cff7d89dc64e20179ddbfa41208666db7f14dbef6642b92e1
MD5 8fdc7a9a83e0e527519166bfd29b4bb9
BLAKE2b-256 a5b3c967e0c86c10250f2238688a32102ba9b19cbd34d2fdb93650e7eb8504bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyensmallen-0.4.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yml on apoorvalal/pyensmallen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyensmallen-0.4.5-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyensmallen-0.4.5-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9c5cdd738011a4d4af7dbdeefe260c5fc0d9715e87d3b38d77def678df3ba5fd
MD5 dffa4ccb0f0a0175ac83780c299819b2
BLAKE2b-256 83c8662ec5d703751b1bd4f0ff9bd26326cfc6eab1e00feafecdb71f894907d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyensmallen-0.4.5-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: build.yml on apoorvalal/pyensmallen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyensmallen-0.4.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyensmallen-0.4.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 80e676328b3e85dd8390b3e485fcd461b181a90713f5e79023c16f542d4afcd5
MD5 1df184daf9a19dce152a8f009c67a05c
BLAKE2b-256 5523cdb4459ce2e8324d1b8bfc15182f09438d70e00f1de8b59231248d96240a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyensmallen-0.4.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yml on apoorvalal/pyensmallen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyensmallen-0.4.5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyensmallen-0.4.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28ec1cb9d20bac6672964a5975fc26d4a188dd94dbd98d473ff288960aef2f7e
MD5 ae53bab533c6451901c07ab34cda2fc9
BLAKE2b-256 dff2bff20af4ba7e1e586c7c48e31819f97b94ee842311b26b394dcaec36dffe

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyensmallen-0.4.5-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: build.yml on apoorvalal/pyensmallen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyensmallen-0.4.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyensmallen-0.4.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 df760a0a660ec326a7889fb891af04b9ec22652dfb2acf30b2d3ab2247dbd625
MD5 8f0f82e39148f5580f7586324bbf2e8e
BLAKE2b-256 1bf03ac4e618c547605fde3628368a1d11539eb0a258d9fb1b91a7f782e84cb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyensmallen-0.4.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yml on apoorvalal/pyensmallen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyensmallen-0.4.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyensmallen-0.4.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e540e9abe93edd82732d30e27180f0f7a2daf09e7eae4762bfeb43df8756dc5d
MD5 de090332aa30ceee74ca2ce3ea4cd98b
BLAKE2b-256 e360a6844578b8fde11127258b65824729f9542bb8b9ce45a137bb21a94a199d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyensmallen-0.4.5-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: build.yml on apoorvalal/pyensmallen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyensmallen-0.4.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyensmallen-0.4.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 70e9e18ba6681bc409c749bca5f1d28c732791b27903efc9a7c5435ae3213bd6
MD5 8ced5e51a4c9b2e2e36cce89f104586a
BLAKE2b-256 cc6f3fe26ada3c97db7862dec46b607e17924a0733603b69d3a17bcb8601e110

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyensmallen-0.4.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yml on apoorvalal/pyensmallen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyensmallen-0.4.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyensmallen-0.4.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3774a589e9f130de0c302c4f9af0a01b08720c744ae091bb55334d605de0130a
MD5 ed27b11bfc1492a0b6907602a816c17f
BLAKE2b-256 b7ed8f1e69b66f8d00b02bc341b483713da308749b091d90afebbbd28d7ff5f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyensmallen-0.4.5-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: build.yml on apoorvalal/pyensmallen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyensmallen-0.4.5-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyensmallen-0.4.5-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 78c7df62d22fff3400efbc259b2f78de492637db8127c18917d87a19203a002e
MD5 64e197f0c312d4e6c8050a5bb5f4c631
BLAKE2b-256 80265901d6452510ec7c041e60cd2e777b9eb0d0fc57ce5bdf299e441279bf0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyensmallen-0.4.5-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yml on apoorvalal/pyensmallen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyensmallen-0.4.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyensmallen-0.4.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 50537ecdc879944bf84b96af4b09cbd95347404e1125f0fa838382f7d10fcb13
MD5 d9f487a42a74310fcdc0208623e6c52d
BLAKE2b-256 4911aceb8ba537293f4c613f697d479b4a063965100074f8ffa89f9afeaf8806

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyensmallen-0.4.5-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: build.yml on apoorvalal/pyensmallen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page