Skip to main content

glmnetpp

Native gaussian elnet (glmnet C++ core) binding for Python.

This package wraps the header-only C++ core of R's glmnet (glmnetpp, the

=4.0 reimplementation) behind a small extern "C" ABI and a ctypes binding. It fits ridge / elastic-net gaussian models that are numerically identical to R glmnet (including the intercept=FALSE refit path) without depending on the R runtime.

Installation

pip install glmnetpp

Heads-up — compiled extension. The numerical work is done by a native C++ extension (glmnetpp/_core.*), built from the vendored glmnetpp C++ core + Eigen (header-only). When a prebuilt wheel is available for your platform/Python, pip install glmnetpp Just Works. When it is not, pip builds from the sdist, which requires a C++17 compiler and the Eigen headers on your machine (see Building from source below). To ship wheels for every platform, build them in CI — see the Publishing wheels note at the end.

Why

R's glmnet(family="gaussian", alpha=0, ...) is the reference. The old glmnet_python wrapper ships a 2013 Fortran GLMnet.f whose intercept=FALSE path diverges from R's current (C++) glmnet by ~0.2–0.3%. The C++ core (glmnetpp) is the same code R 4.1-8 runs, so it matches exactly.

Use

from glmnetpp import fit_gaussian_ridge

intercept, coef, jerr = fit_gaussian_ridge(
    X, y, lam=0.1, alpha=0.0,
    lower_limits=[0.0]*p, upper_limits=[None]*p,
    standardize=True, intercept=True,
)

coef is on the original (unstandardized) scale, matching as.numeric(coef(glmnet(...))).

Building from source

This is a Poetry package. poetry-core owns packaging/metadata/dependencies; it does not compile C extensions itself — instead it runs scripts/build-extension.py, which drives setuptools' build_ext (Eigen discovery + compiler-conditional flags) and builds the extension in-place under src/glmnetpp/.

Build-only dependency: Eigen (header-only).

# either (with Poetry installed):
poetry install
# or (plain pip — uses the poetry-core backend, runs the build script):
pip install -e .

The build script searches for Eigen in this order and picks the first one that contains Eigen/Core:

  1. third_party_eigen/eigen-<version>/ inside the project (what CI uses — drop the header-only Eigen release there and it builds anywhere, no system package needed)
  2. $EIGEN_INCLUDE_DIR
  3. /usr/include/eigen3 (libeigen3-dev)
  4. /usr/lib/R/site-library/RcppEigen/include (r-cran-rcppeigen)
  5. macOS Homebrew (/usr/local/include/eigen3, /opt/homebrew/include/eigen3)
  6. Windows — vcpkg ($VCPKG_ROOT/installed/x64-windows/include/eigen3) or Conda ($CONDA_PREFIX/Library/include/eigen3)

Provenance

The vendored-from-R headers (the C++ glmnetpp core, copied from CRAN glmnet) and the full list of every part copied from R are documented in cpp/glmnetpp_include/README.md in the source tree.

Publishing wheels

Prebuilt wheels are produced by the GitHub Actions workflow in .github/workflows/python-publish.yml. It uses cibuildwheel to build manylinux (Linux), Windows and macOS (x86_64 + arm64) wheels for CPython 3.9–3.13, plus an sdist, and publishes them all to PyPI.

Because the C++ extension needs Eigen at build time, the workflow downloads the header-only Eigen release into third_party_eigen/ inside the project tree before building; scripts/build-extension.py finds it there relative to the repo root, so the same path works on every OS and inside cibuildwheel's manylinux container. (That directory is gitignored — it's a build input, not source.) Each wheel is smoke-tested (import + fit_gaussian_ridge) in CI before it ships, so end users of these platforms never need a C++ compiler or Eigen.

License

GPL-2.0-or-later, inherited from the upstream glmnet / glmnetpp C++ core (these headers are a derivative of that code). See the LICENSE file.

Download files

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

Source Distribution

glmnetpp-0.1.0.tar.gz (68.1 kB view details)

Uploaded Source

Built Distributions

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

glmnetpp-0.1.0-cp313-cp313-win_amd64.whl (127.6 kB view details)

Uploaded CPython 3.13Windows x86-64

glmnetpp-0.1.0-cp313-cp313-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl (4.7 MB view details)

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

glmnetpp-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (103.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

glmnetpp-0.1.0-cp312-cp312-win_amd64.whl (106.1 kB view details)

Uploaded CPython 3.12Windows x86-64

glmnetpp-0.1.0-cp312-cp312-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl (3.8 MB view details)

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

glmnetpp-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (86.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

glmnetpp-0.1.0-cp311-cp311-win_amd64.whl (84.6 kB view details)

Uploaded CPython 3.11Windows x86-64

glmnetpp-0.1.0-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl (2.9 MB view details)

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

glmnetpp-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (70.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

glmnetpp-0.1.0-cp310-cp310-win_amd64.whl (63.2 kB view details)

Uploaded CPython 3.10Windows x86-64

glmnetpp-0.1.0-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl (1.9 MB view details)

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

glmnetpp-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (53.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

glmnetpp-0.1.0-cp39-cp39-win_amd64.whl (41.7 kB view details)

Uploaded CPython 3.9Windows x86-64

glmnetpp-0.1.0-cp39-cp39-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl (966.3 kB view details)

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

glmnetpp-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (37.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file glmnetpp-0.1.0.tar.gz.

File metadata

  • Download URL: glmnetpp-0.1.0.tar.gz
  • Upload date:
  • Size: 68.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for glmnetpp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 79c10187d6fa277cc9d3bae0446aea3643e2eee4ca94547c38a9c188c5170c40
MD5 1c90dc8b171f316529a5e113f0e39dde
BLAKE2b-256 836c586aceb4cac310e572168fede183a09bb2083e77749fb5e59a09442c9fad

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: glmnetpp-0.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 127.6 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for glmnetpp-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 16837341c259353a4c72ab00563579cb397a3f0109da24ddffbd650c2d1c222d
MD5 67a3ef6c7b1881669155786e3407c9a4
BLAKE2b-256 1493e3058e85b65237d3a9283a1beb638611a7fc62d20beaeebc1575257b227f

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp313-cp313-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for glmnetpp-0.1.0-cp313-cp313-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 f1d14f6899a9ad7efc5c5eb4bdcdf034b994494e12960bc9a96f318356dbde7a
MD5 1e87d2612caed9192a02c0109bc728a8
BLAKE2b-256 8123ee896367c10c77448606474f2bc8e775dd72d99c1e8ed39a298cfcd992c8

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for glmnetpp-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 765be1ea12ca405c0465f830f56cc7913935b3902aaa5d4274cc90c97f65190e
MD5 7fbf274de10414002ef4696f661362c4
BLAKE2b-256 fad2238ac2ed6e9fb4306fccb820bcd4d9caa129abc13c20acb98ab8b4c3b2ec

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: glmnetpp-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 106.1 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for glmnetpp-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c0a6ab0619d1628593ad50a70061a50b538e814a9d9e28e897b83e74a128402a
MD5 b1566ca97c8f75c8b7a2ecc811b2c50e
BLAKE2b-256 efe5a03b4aa3237492f102371056f819be85de7f702a252db7cf14b7731a3563

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp312-cp312-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for glmnetpp-0.1.0-cp312-cp312-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 64eac88d881512b46484192fc33cd7a7f3a13d240cf18ad4c8515e7e179a2494
MD5 76e25e0f4553a3aa7891663179595ef3
BLAKE2b-256 5fb80d3aaab890359c76852c604c66f5bba29bedb3f1fd944a077a289f315bcf

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for glmnetpp-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 717e0b1e7b6113055a66a1ce65da269cc44cb58dc35cfaf8ba88fc4ac630ad4b
MD5 f619369379d8db40a798c9324751f81e
BLAKE2b-256 80064bb354513a0e7ea11f7d930a2baf8d13824048a72233bb004bd66c52dd37

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: glmnetpp-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 84.6 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for glmnetpp-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7451e9b509c5c1675b2c474cdb3eba15945b77cc34fd38cdf33bf3c2b08cfdd5
MD5 71f4e832851219d810b4f45ffe14ca61
BLAKE2b-256 b507ed65dac0ba992f50dacc8d101a630087ca6bb89e3afb6d53ad30a21f797a

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for glmnetpp-0.1.0-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 59178568724d584ea8258db85a20e18ff47cd50dce4167121de33b16025f709c
MD5 e5ef4f9d63271e7cfad31c50e9892a10
BLAKE2b-256 f685ab51c9be0176fbd26377c94728b774c0bfe3cac1ce19a0fb7af1e0a7463f

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for glmnetpp-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fe2e3947effd8e859d942e119f9b57855f93c46dc8bfe1f976452d171f8fc028
MD5 a4b293fb65b7c817cb39e42895da50fe
BLAKE2b-256 099ad69cc635c6a5a2e69c1d8ba7dda879482f8ade39fb8835bef2ca8fa467c8

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: glmnetpp-0.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 63.2 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for glmnetpp-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ee893d16f075868a2134772a960602ba3858c9a3002579cc60f914c0bfb26133
MD5 f1d0876fcc44251364f70f00975c786c
BLAKE2b-256 553b39c5a65dcdf142227a4998c3908129a87913f9cb73c9540a1fc8cd7b63ee

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for glmnetpp-0.1.0-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 8ff6621b387db9d6bd2e16a4eb311e1bd0aedb47c5fd251528d04dfb938f6fe2
MD5 2a0ec4dbd3541cdbe96cc36f2920e2a7
BLAKE2b-256 f44f3e01ec15dba314c1e24bf08df08388ad87f5ceb51d34b7a8a6363033a262

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for glmnetpp-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 07cf3d007467258aecd9dea354334ac95f478cd11a491e09ffdacbaa32149ef0
MD5 979567295a316639fb587b935e78768a
BLAKE2b-256 67ed1c765816d88f05b2665ed23a6379480ba616e73bfd924bf27cbb8773f086

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: glmnetpp-0.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 41.7 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for glmnetpp-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a6242fec3e62f69135a37cdb36e02648bf1db2064f23a292cdff2537d40e19d5
MD5 d2f5c9ada187b7c56c83acf15364894b
BLAKE2b-256 f83cbc8e37959b68ec6b268748e009fbb3d6adbe9b3d8900c54fea7b57c387f0

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp39-cp39-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for glmnetpp-0.1.0-cp39-cp39-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 3d7b98fc679a7c38e5a7d847c0b8ed4f123efef6c04b3ddd748dcd4ebcc8beeb
MD5 d9df7625dd51f7372425a77eb412a8b0
BLAKE2b-256 a8b00ae1ff5cb3cddb40f4abb4d1a9443fdeb93354f9ef8a241826c6bd44d697

See more details on using hashes here.

File details

Details for the file glmnetpp-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for glmnetpp-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 723b76d984e658f0a13bb0b9bde8204769da5d9c57c113109d369fea7738ad97
MD5 b31d45232efa6ec0294495e911696442
BLAKE2b-256 15087582bccfa9dd0e7da75d745b1f8dc7e090bd9d2b267376debdb1400a4d9a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

16 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