Skip to main content

Sparse Linear Regression Models

test Codacy Badge pre-commit.ci status pypi version Static Badge

sparse-lm includes several (structured) sparse linear regression estimators that are absent in the sklearn.linear_model module. The estimators in sparse-lm are designed to fit right into scikit-learn, but the underlying optimization problem is expressed and solved by leveraging cvxpy.


Available regression models

  • Lasso, Group Lasso, Overlap Group Lasso, Sparse Group Lasso & Ridged Group Lasso.
  • Adaptive versions of Lasso, Group Lasso, Overlap Group Lasso, Sparse Group Lasso & Ridged Group Lasso.
  • Best Subset Selection, Ridged Best Subset, L0, L1L0 & L2L0 (all with optional grouping of parameters)

Installation

sparse-lm is available on PyPI, and can be installed via pip:

pip install sparse-lm

Additional information on installation can be found the documentation here.

Basic usage

If you already use scikit-learn, using sparse-lm will be very easy. Just use any model like you would any linear model in scikit-learn:

import numpy as np
from sklearn.datasets import make_regression
from sklearn.model_selection import GridSearchCV
from sparselm.model import AdaptiveLasso

X, y = make_regression(n_samples=100, n_features=80, n_informative=10, random_state=0)
alasso = AdaptiveLasso(fit_intercept=False)
param_grid = {'alpha': np.logspace(-8, 2, 10)}

cvsearch = GridSearchCV(alasso, param_grid)
cvsearch.fit(X, y)
print(cvsearch.best_params_)

For more details on use and functionality have a look at the examples and API sections of the documentation.

Contributing

We welcome any contributions that you think may improve the package! Please have a look at the contribution guidelines in the documentation.

Metadata

Release files for sparse-lm 0.5.2

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

Source distribution (sdist)

Source distribution for sparse-lm 0.5.2
File Size Uploaded Provenance Actions
sparse-lm-0.5.2.tar.gz 492.2 kB Without provenance Details for sparse-lm-0.5.2.tar.gz

Release files / sparse-lm-0.5.2.tar.gz

Download URL sparse-lm-0.5.2.tar.gz
Size 492.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fe9552952e5c76c9bcd55fe0583cb0e7b40bcb7ca1235c0ec9df1599608d9b70
BLAKE2b-256 checksum
How to use checksums
99ef6b1ec8c549563d3e3ca3ee713b1e7129573f175df9a16e4044a57e8b9cae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Security for sparse-lm 0.5.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

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