pyensmallen

pyensmallen provides Python bindings for the ensmallen optimization library, with a focus on econometrics and supervised learning workflows.

Install

Base install:

uv pip install pyensmallen

Development install with all test and notebook dependencies:

uv pip install --python .venv/bin/python ".[full]"

Editable install in this repository:

uv pip install --python .venv/bin/python meson meson-python ninja pybind11
uv pip install --python .venv/bin/python --no-build-isolation -e ".[full]"

What is included

  • Optimizers: L_BFGS, FrankWolfe, SimplexFrankWolfe, and Adam variants
  • Objective helpers: linear, logistic, and Poisson losses
  • Estimator classes: LinearRegression, LogisticRegression, PoissonRegression
  • Inference: classical and robust sandwich standard errors for unregularized OLS and QMLE-style logit and Poisson
  • GMM support with JAX autodiff

Documentation map

  • Optimizers: low-level optimizer classes and when to use them
  • Benchmarks: runtime and convergence comparisons against SciPy and statsmodels
  • Estimators: supervised estimators, fitted attributes, and inference
  • Notebooks: examples and benchmark notebooks in this repository

Runtime benchmark snapshot

Runtime benchmark comparing pyensmallen, scipy, and statsmodels across model families, sample sizes, and parameter counts.

  • pyensmallen remains fastest in most medium/large configurations, with widening gaps at larger n.
  • The practical implication is cheaper repeated estimation loops: bootstrap inference, model sweeps, and sensitivity analysis become much more tractable.
  • SciPy generally tracks second, while statsmodels is often slower at scale; this compounds heavily in resampling workflows.

Notes

  • The full extra installs Python packages required to run tests and notebooks.
  • Quarto itself is an external CLI. Render this site with scripts/render_docs.sh.