Parametric Simplex Method for Sparse Learning
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyprimal-2.0.0.tar.gz.
File metadata
- Download URL: pyprimal-2.0.0.tar.gz
- Upload date:
- Size: 538.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
478202c151f28596dd7f1793b742532625067be986142f2129031cea0ef48cd3
|
|
| MD5 |
52a91c594b06d57f0194b8ed84d8a84f
|
|
| BLAKE2b-256 |
05db0681994ea7711b95d9f1a8047a002c3792f95ee7689ff1aaea4c76539c7f
|
Provenance
The following attestation bundles were made for pyprimal-2.0.0.tar.gz:
Publisher:
build-publish.yml on ShenQianli/primal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyprimal-2.0.0.tar.gz -
Subject digest:
478202c151f28596dd7f1793b742532625067be986142f2129031cea0ef48cd3 - Sigstore transparency entry: 1006391658
- Sigstore integration time:
-
Permalink:
ShenQianli/primal@e6de894b0ae08f5ceeb7ebd94eb6fc6747bccc43 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/ShenQianli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-publish.yml@e6de894b0ae08f5ceeb7ebd94eb6fc6747bccc43 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyprimal-2.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyprimal-2.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 550.0 kB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaac185ad6a0b4eff51c5db2f5457b0eb89958c78f58060ed4fd38bd6f875a2d
|
|
| MD5 |
cf6f914d818c8605e34455aed8fc1ea9
|
|
| BLAKE2b-256 |
6605ee3621da8282fe01133af4d4b7e81437314f00052a0073f90ea1178260a4
|
Provenance
The following attestation bundles were made for pyprimal-2.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
build-publish.yml on ShenQianli/primal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyprimal-2.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
aaac185ad6a0b4eff51c5db2f5457b0eb89958c78f58060ed4fd38bd6f875a2d - Sigstore transparency entry: 1006391669
- Sigstore integration time:
-
Permalink:
ShenQianli/primal@e6de894b0ae08f5ceeb7ebd94eb6fc6747bccc43 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/ShenQianli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-publish.yml@e6de894b0ae08f5ceeb7ebd94eb6fc6747bccc43 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyprimal-2.0.0-py3-none-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pyprimal-2.0.0-py3-none-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 556.0 kB
- Tags: Python 3, manylinux: glibc 2.17+ i686, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34cf9d70a345ceef7dddafd4b9511e21ea802e6d7e5412390db5ff6079e2ac14
|
|
| MD5 |
c9a2df6d42961eecb281ee8dbdb35d85
|
|
| BLAKE2b-256 |
a3c91a769c4a52e53654e635e9d5e8473ceca948e0d0ce541e7a87562c353a4e
|
Provenance
The following attestation bundles were made for pyprimal-2.0.0-py3-none-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl:
Publisher:
build-publish.yml on ShenQianli/primal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyprimal-2.0.0-py3-none-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl -
Subject digest:
34cf9d70a345ceef7dddafd4b9511e21ea802e6d7e5412390db5ff6079e2ac14 - Sigstore transparency entry: 1006391665
- Sigstore integration time:
-
Permalink:
ShenQianli/primal@e6de894b0ae08f5ceeb7ebd94eb6fc6747bccc43 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/ShenQianli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-publish.yml@e6de894b0ae08f5ceeb7ebd94eb6fc6747bccc43 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyprimal-2.0.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyprimal-2.0.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 426.9 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14a423ff666d7149ddfba47b5fd39820e66bfe2c2a9e58dd401d315eda03c115
|
|
| MD5 |
e1c8dfddec84416e8a36312a54d1869f
|
|
| BLAKE2b-256 |
1a8305434999a9ec8737d0f3f3e0e73fa2909f760a8c9422c3b4f1df7841f967
|
Provenance
The following attestation bundles were made for pyprimal-2.0.0-py3-none-macosx_11_0_arm64.whl:
Publisher:
build-publish.yml on ShenQianli/primal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyprimal-2.0.0-py3-none-macosx_11_0_arm64.whl -
Subject digest:
14a423ff666d7149ddfba47b5fd39820e66bfe2c2a9e58dd401d315eda03c115 - Sigstore transparency entry: 1006391663
- Sigstore integration time:
-
Permalink:
ShenQianli/primal@e6de894b0ae08f5ceeb7ebd94eb6fc6747bccc43 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/ShenQianli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-publish.yml@e6de894b0ae08f5ceeb7ebd94eb6fc6747bccc43 -
Trigger Event:
push
-
Statement type: