Skip to main content

Python bindings for the Ensmallen library.

Project description

pyensmallen-experimental: 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-experimental and is the reason for the bindings.

See ensmallen docs for details. The notebooks/ directory walks through several statistical examples.

speed

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

pip install pyensmallen-experimental

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. pip install -e .
  4. Profit? Or at least minimize loss?

from wheel

  • download the appropriate .whl for your system from the more recent release listed in Releases and run pip install ./pyensmallen-experimental... OR
  • copy the download url and run pip install https://github.com/apoorvalal/pyensmallen-experimental/releases/download/<version>/pyensmallen-experimental-<version>-<pyversion>-linux_x86_64.whl

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_experimental-0.2.7124.tar.gz (3.3 MB view details)

Uploaded Source

File details

Details for the file pyensmallen_experimental-0.2.7124.tar.gz.

File metadata

File hashes

Hashes for pyensmallen_experimental-0.2.7124.tar.gz
Algorithm Hash digest
SHA256 451664a0b430e1ec5dc6efd4e87da57e2090c1a16c781b656c0f3edae8551883
MD5 40f3e3671e093cf953b17b56e156a688
BLAKE2b-256 6bfb44e3a57faf8c7965d9a9e185cb09b3d959b4dcf2508a66ef6a12dbd399dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyensmallen_experimental-0.2.7124.tar.gz:

Publisher: build.yml on gauravmanmode/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