pyprimal
pyprimal: Parametric Simplex Method for Sparse Learning
A native Python package implementing the parametric simplex method for a variety of sparse learning problems including Dantzig selector, sparse SVM, compressed sensing, and quantile regression. The core algorithm is implemented in C++ with Eigen support; Python wraps it via ctypes with no R dependency.
Directory structure
python-package/
├── pyprimal/ Package source
│ ├── core.py Solvers and PrimalResult dataclass
│ ├── libpath.py Shared library loader
│ └── lib/ Compiled libpsm (.so / .dylib)
├── docs/ MkDocs documentation pages
├── examples/ Runnable example scripts
├── tests/ Unit tests (pytest)
├── mkdocs.yml Documentation configuration
└── pyproject.toml Build configuration
Requirements
- Python >= 3.9
- NumPy >= 1.23
- Compiled
libpsmshared library (Linux.soor macOS.dylib) - Optional: matplotlib >= 3.5 for plotting
Installation
From source (recommended):
git clone https://github.com/Gatech-Flash/primal.git
cd primal
# Build the C++ library
make clean && make dylib
# Install the Python package
cd python-package
pip install -e ".[viz,test]"
Optional extras:
pip install -e ".[viz]" # matplotlib for plotting
pip install -e ".[test]" # pytest for testing
pip install -e ".[docs]" # mkdocs for documentation
Verify installation:
python -c "import pyprimal; pyprimal.test()"
Usage
import numpy as np
from pyprimal import dantzig_solver, sparse_svm_solver
# Dantzig selector
rng = np.random.default_rng(42)
X = rng.standard_normal((100, 20))
beta_true = np.array([1]*5 + [0]*15, dtype=float)
y = X @ beta_true + 0.1 * rng.standard_normal(100)
result = dantzig_solver(X, y)
print(result) # summary
result.coef() # coefficients at last iteration
result.coef(3) # coefficients at iteration 3
result.plot() # all three plots
result.plot(1) # regularization path only
# Sparse SVM
y_svm = np.where(X[:, 0] + X[:, 1] > 0, 1.0, -1.0)
result_svm = sparse_svm_solver(X, y_svm)
print(result_svm)
Available solvers
| Function | Problem |
|---|---|
dantzig_solver(X, y) |
Dantzig selector |
sparse_svm_solver(X, y) |
Sparse support vector machine |
compressed_sensing_solver(X, y) |
Compressed sensing |
quantile_regression_solver(X, y, tau=0.5) |
Quantile regression |
All solvers return a PrimalResult dataclass with:
.beta-- coefficient matrix (d x iterN).lambda_-- regularization parameter path.value-- objective function values.df-- degrees of freedom along the path.summary()/print(result)-- formatted summary.coef(n)-- extract coefficients at iteration n (1-based index).plot(n)-- visualize the solution path
Documentation
Build the documentation locally:
pip install -e ".[docs]"
mkdocs build
mkdocs serve # opens at http://127.0.0.1:8000
Developer workflow
# Run tests
pip install -e ".[test]"
pytest tests/ -v
# Build docs
pip install -e ".[docs]"
mkdocs build --strict
Citation
@article{li2018primal,
title={The Parametric Simplex Method for Sparse Learning},
author={Li, Zichong and Shen, Qianli and Zhao, Tuo},
year={2018}
}
License
GPL-3.0
Authors
Zichong Li, Qianli Shen, Tuo Zhao
Maintainer: Tuo Zhao tourzhao@gatech.edu
Metadata
Release files for pyprimal 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyprimal-2.0.0.tar.gz | 538.9 kB | With provenance | Details for pyprimal-2.0.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyprimal-2.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details for pyprimal-2.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| pyprimal-2.0.0-py3-none-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl | Python 3 | none | Linux glibc 2.17+ x86-32, Linux glibc 2.5+ x86-32 | Details for pyprimal-2.0.0-py3-none-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
| pyprimal-2.0.0-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details for pyprimal-2.0.0-py3-none-macosx_11_0_arm64.whl |
Total release size: 2.1 MB
Release files / pyprimal-2.0.0.tar.gz
| Download URL | pyprimal-2.0.0.tar.gz |
|---|---|
| Size | 538.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
478202c151f28596dd7f1793b742532625067be986142f2129031cea0ef48cd3
|
|
BLAKE2b-256 checksum How to use checksums |
05db0681994ea7711b95d9f1a8047a002c3792f95ee7689ff1aaea4c76539c7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.
Transparency logRelease files / pyprimal-2.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyprimal-2.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 550.0 kB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
aaac185ad6a0b4eff51c5db2f5457b0eb89958c78f58060ed4fd38bd6f875a2d
|
|
BLAKE2b-256 checksum How to use checksums |
6605ee3621da8282fe01133af4d4b7e81437314f00052a0073f90ea1178260a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.
Transparency logRelease files / pyprimal-2.0.0-py3-none-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pyprimal-2.0.0-py3-none-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 556.0 kB |
| Tags | Linux glibc 2.17+ x86-32 Linux glibc 2.5+ x86-32 Python 3 |
|
SHA-256 checksum How to use checksums |
34cf9d70a345ceef7dddafd4b9511e21ea802e6d7e5412390db5ff6079e2ac14
|
|
BLAKE2b-256 checksum How to use checksums |
a3c91a769c4a52e53654e635e9d5e8473ceca948e0d0ce541e7a87562c353a4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.
Transparency logRelease files / pyprimal-2.0.0-py3-none-macosx_11_0_arm64.whl
| Download URL | pyprimal-2.0.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 426.9 kB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
14a423ff666d7149ddfba47b5fd39820e66bfe2c2a9e58dd401d315eda03c115
|
|
BLAKE2b-256 checksum How to use checksums |
1a8305434999a9ec8737d0f3f3e0e73fa2909f760a8c9422c3b4f1df7841f967
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.
Transparency logSecurity for pyprimal 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 4 files in this release have been uploaded with provenance metadata.
Attestation for pyprimal-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.