sparselink
Domain-agnostic sparse network inference from tabular data.
sparselink provides a unified Python interface for 20+ network inference algorithms — from LASSO and graphical models to causal discovery and deep learning approaches. All methods share a single fit(X) -> InferenceResult API, making it easy to swap algorithms, benchmark them on synthetic data, and compare results.
Installation
pip install sparselink
Optional extras:
pip install sparselink[causal] # PC, FCI (causal-learn)
pip install sparselink[deep] # DAG-GNN (PyTorch)
pip install sparselink[dev] # pytest, mypy, ruff
Quick Start
import numpy as np
from sparselink import get_method
X = np.random.default_rng(42).standard_normal((100, 20))
method = get_method("lasso")
result = method(alpha=0.01).fit(X)
print(result.adjacency_matrix.shape) # (20, 20)
print(result.edge_list[:5]) # [(src, tgt, weight), ...]
Available Methods
| Category | Methods |
|---|---|
| Regularization | Lasso, Elastic Net, Ridge, LSCO |
| Information-theoretic | CLR, Partial Correlation |
| Graphical models | Graphical LASSO, GLASSO+StARS, Neighborhood Selection |
| Tree / stability | GENIE3, TIGRESS |
| Causal (time-series) | PCMCI, Granger Causality, Transfer Entropy |
| Constraint-based | PC, FCI |
| Continuous optimization | NOTEARS, DAG-GNN |
| Bayesian | BDeu, BGe |
from sparselink import list_methods
print(list_methods())
Method Registry
Methods are registered via the @registry.register decorator and discovered automatically at import time. Use get_method(name) to retrieve any method by its string name — no direct imports needed in application code.
Benchmarking
sparselink includes a benchmarking suite with synthetic network/data generation and evaluation metrics for comparing algorithm performance.
Python API
from sparselink.bench import generate_network, generate_data, evaluate
from sparselink import get_method
net = generate_network(20, topology="scalefree", sparsity=0.1, seed=0)
X = generate_data(net, n_samples=100, noise_std=0.1, seed=0)
result = get_method("genie3")().fit(X)
metrics = evaluate(net, result.adjacency_matrix)
print(f"AUROC={metrics.auroc:.3f} F1={metrics.f1:.3f}")
CLI
# Interactive mode
sparselink
# Infer a network from data
sparselink infer data.csv --method lasso
# Run benchmark
sparselink bench --tier fast,medium --timeout 60
# List available methods
sparselink methods
# System status
sparselink status
# Show previous results
sparselink show benchmark_results.json
Evaluation Metrics
- AUROC, AUPR (threshold-free)
- Precision, Recall, F1, FDR, MCC (best over threshold sweep)
- R² (edge weight accuracy)
Project Structure
src/sparselink/
├── base.py # InferenceMethod ABC
├── types.py # AdjacencyMatrix, EdgeList, InferenceResult
├── registry.py # @registry.register decorator + discovery
├── accel.py # Optional MLX acceleration (Apple Silicon)
├── methods/ # One module per algorithm
└── bench/ # Synthetic data, metrics, runner, CLI
Development
pip install -e ".[dev]"
pytest # tests + coverage (80% gate)
mypy src/ # strict type checking
ruff check src/ tests/ # lint
ruff format src/ tests/ # format
License
MIT
Metadata
Release files for sparselink 1.3.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 | |
|---|---|---|---|
| sparselink-1.3.0.tar.gz | 212.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sparselink-1.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 268.7 kB
Release files / sparselink-1.3.0.tar.gz
| Download URL | sparselink-1.3.0.tar.gz |
|---|---|
| Size | 212.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e6c5266753517c722eed20f4b54e9cfc9e56cf8dbd114455d8f91c3b35b5529
|
|
BLAKE2b-256 checksum How to use checksums |
c43b37ce687e1afa4c1cf0117c66fd45ef60931051f4b62be572433b126201cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 14, 2026.
Transparency logRelease files / sparselink-1.3.0-py3-none-any.whl
| Download URL | sparselink-1.3.0-py3-none-any.whl |
|---|---|
| Size | 56.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0dcd5335d6f8326400b9e6ac8f7ed9530aa8d68e15702c523d9494ded01d7f87
|
|
BLAKE2b-256 checksum How to use checksums |
1d712f87dd88c35f2891d97b9e6324959820f7cca52c72756bfe7f37e7cbe038
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 14, 2026.
Transparency log