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.

Metadata

Release files for glmnetpp 0.1.0

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

Source distribution (sdist)

Source distribution for glmnetpp 0.1.0
File Size Uploaded
glmnetpp-0.1.0.tar.gz 68.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for glmnetpp 0.1.0
File
glmnetpp-0.1.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
glmnetpp-0.1.0-cp313-cp313-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
glmnetpp-0.1.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
glmnetpp-0.1.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
glmnetpp-0.1.0-cp312-cp312-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
glmnetpp-0.1.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
glmnetpp-0.1.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
glmnetpp-0.1.0-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
glmnetpp-0.1.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
glmnetpp-0.1.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
glmnetpp-0.1.0-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
glmnetpp-0.1.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
glmnetpp-0.1.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
glmnetpp-0.1.0-cp39-cp39-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
glmnetpp-0.1.0-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details

Total release size: 15.1 MB

Release files / glmnetpp-0.1.0.tar.gz

Download URL glmnetpp-0.1.0.tar.gz
Size 68.1 kB
Tags Source
SHA-256 checksum
How to use checksums
79c10187d6fa277cc9d3bae0446aea3643e2eee4ca94547c38a9c188c5170c40
BLAKE2b-256 checksum
How to use checksums
836c586aceb4cac310e572168fede183a09bb2083e77749fb5e59a09442c9fad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp313-cp313-win_amd64.whl

Download URL glmnetpp-0.1.0-cp313-cp313-win_amd64.whl
Size 127.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
16837341c259353a4c72ab00563579cb397a3f0109da24ddffbd650c2d1c222d
BLAKE2b-256 checksum
How to use checksums
1493e3058e85b65237d3a9283a1beb638611a7fc62d20beaeebc1575257b227f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp313-cp313-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl

Download URL glmnetpp-0.1.0-cp313-cp313-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl
Size 4.7 MB
Tags CPython 3.13 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f1d14f6899a9ad7efc5c5eb4bdcdf034b994494e12960bc9a96f318356dbde7a
BLAKE2b-256 checksum
How to use checksums
8123ee896367c10c77448606474f2bc8e775dd72d99c1e8ed39a298cfcd992c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL glmnetpp-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Size 103.4 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
765be1ea12ca405c0465f830f56cc7913935b3902aaa5d4274cc90c97f65190e
BLAKE2b-256 checksum
How to use checksums
fad2238ac2ed6e9fb4306fccb820bcd4d9caa129abc13c20acb98ab8b4c3b2ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp312-cp312-win_amd64.whl

Download URL glmnetpp-0.1.0-cp312-cp312-win_amd64.whl
Size 106.1 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
c0a6ab0619d1628593ad50a70061a50b538e814a9d9e28e897b83e74a128402a
BLAKE2b-256 checksum
How to use checksums
efe5a03b4aa3237492f102371056f819be85de7f702a252db7cf14b7731a3563
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp312-cp312-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl

Download URL glmnetpp-0.1.0-cp312-cp312-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl
Size 3.8 MB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
64eac88d881512b46484192fc33cd7a7f3a13d240cf18ad4c8515e7e179a2494
BLAKE2b-256 checksum
How to use checksums
5fb80d3aaab890359c76852c604c66f5bba29bedb3f1fd944a077a289f315bcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL glmnetpp-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Size 86.8 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
717e0b1e7b6113055a66a1ce65da269cc44cb58dc35cfaf8ba88fc4ac630ad4b
BLAKE2b-256 checksum
How to use checksums
80064bb354513a0e7ea11f7d930a2baf8d13824048a72233bb004bd66c52dd37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp311-cp311-win_amd64.whl

Download URL glmnetpp-0.1.0-cp311-cp311-win_amd64.whl
Size 84.6 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
7451e9b509c5c1675b2c474cdb3eba15945b77cc34fd38cdf33bf3c2b08cfdd5
BLAKE2b-256 checksum
How to use checksums
b507ed65dac0ba992f50dacc8d101a630087ca6bb89e3afb6d53ad30a21f797a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl

Download URL glmnetpp-0.1.0-cp311-cp311-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl
Size 2.9 MB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
59178568724d584ea8258db85a20e18ff47cd50dce4167121de33b16025f709c
BLAKE2b-256 checksum
How to use checksums
f685ab51c9be0176fbd26377c94728b774c0bfe3cac1ce19a0fb7af1e0a7463f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL glmnetpp-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Size 70.3 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fe2e3947effd8e859d942e119f9b57855f93c46dc8bfe1f976452d171f8fc028
BLAKE2b-256 checksum
How to use checksums
099ad69cc635c6a5a2e69c1d8ba7dda879482f8ade39fb8835bef2ca8fa467c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp310-cp310-win_amd64.whl

Download URL glmnetpp-0.1.0-cp310-cp310-win_amd64.whl
Size 63.2 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
ee893d16f075868a2134772a960602ba3858c9a3002579cc60f914c0bfb26133
BLAKE2b-256 checksum
How to use checksums
553b39c5a65dcdf142227a4998c3908129a87913f9cb73c9540a1fc8cd7b63ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl

Download URL glmnetpp-0.1.0-cp310-cp310-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl
Size 1.9 MB
Tags CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
8ff6621b387db9d6bd2e16a4eb311e1bd0aedb47c5fd251528d04dfb938f6fe2
BLAKE2b-256 checksum
How to use checksums
f44f3e01ec15dba314c1e24bf08df08388ad87f5ceb51d34b7a8a6363033a262
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL glmnetpp-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Size 53.7 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
07cf3d007467258aecd9dea354334ac95f478cd11a491e09ffdacbaa32149ef0
BLAKE2b-256 checksum
How to use checksums
67ed1c765816d88f05b2665ed23a6379480ba616e73bfd924bf27cbb8773f086
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp39-cp39-win_amd64.whl

Download URL glmnetpp-0.1.0-cp39-cp39-win_amd64.whl
Size 41.7 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
a6242fec3e62f69135a37cdb36e02648bf1db2064f23a292cdff2537d40e19d5
BLAKE2b-256 checksum
How to use checksums
f83cbc8e37959b68ec6b268748e009fbb3d6adbe9b3d8900c54fea7b57c387f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp39-cp39-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl

Download URL glmnetpp-0.1.0-cp39-cp39-manylinux_2_28_x86_64.manylinux_2_24_x86_64.whl
Size 966.3 kB
Tags CPython 3.9 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
3d7b98fc679a7c38e5a7d847c0b8ed4f123efef6c04b3ddd748dcd4ebcc8beeb
BLAKE2b-256 checksum
How to use checksums
a8b00ae1ff5cb3cddb40f4abb4d1a9443fdeb93354f9ef8a241826c6bd44d697
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / glmnetpp-0.1.0-cp39-cp39-macosx_11_0_arm64.whl

Download URL glmnetpp-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Size 37.1 kB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
723b76d984e658f0a13bb0b9bde8204769da5d9c57c113109d369fea7738ad97
BLAKE2b-256 checksum
How to use checksums
15087582bccfa9dd0e7da75d745b1f8dc7e090bd9d2b267376debdb1400a4d9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

16 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