Sparse linear regression models
Project description
Sparse Linear Regression Models
:warning: this package is currently largely lacking in unit-tests. Use at your own risk!
sparse-lm includes several regularized regression estimators that are absent in the
sklearn.linear_model
module. The estimators in sparse-lm are designed to fit right into
scikit-lean by inheriting from their base
LinearModel
. But the underlying optimization problem is expressed and solved by
leveraging cvxpy.
Available regression models
- Ordinary Least Squares (
sklearn
may be a better option) - Lasso (
sklearn
may be a better option) - Group Lasso, Overlap Group Lasso & Sparse Group Lasso
- Adaptive versions of Lasso, Group Lasso, Overlap Group Lasso & Sparse Group Lasso
- Best subset selection, ridged best subset, L0, L1L0 & L2L0
(
gurobi
recommended for performance) - Best group selection, ridged best group selection, grouped L0, grouped L2L0
(
gurobi
recommended for performance)
Installation
From pypi:
pip install sparse-lm
Usage
If you already use scikit-learn, using sparse-lm will be very easy
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=200, n_features=5000, random_state=0)
alasso = AdaptiveLasso(fit_intercept=False)
param_grid = {'alpha': np.logsppace(-7, -2)}
cvsearch = GridSearchCV(alasso, param_grid)
cvsearch.fit(X, y)
print(cvsearch.best_params_)
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
sparse-lm-0.1.0.tar.gz
(209.9 kB
view details)
Built Distribution
sparse_lm-0.1.0-py3-none-any.whl
(21.8 kB
view details)
File details
Details for the file sparse-lm-0.1.0.tar.gz
.
File metadata
- Download URL: sparse-lm-0.1.0.tar.gz
- Upload date:
- Size: 209.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd3a6247253ce24cc79918a2f560b3c1dae3bbb72f39f0c0ad0b9f5302e0a2d1 |
|
MD5 | 750ff044a336fd7a60a86fe3d6de4116 |
|
BLAKE2b-256 | 72510675fbe148a4cdf104da5bde187c5b779a4a341ed5a0aafa900b3ad2c7a4 |
File details
Details for the file sparse_lm-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: sparse_lm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c4a8d1b8871303b0327fe2056011f934cc8ff6bc16678eeff0d577d89da48c6 |
|
MD5 | 7692eda6bc8ed0483d1e1edda5d74038 |
|
BLAKE2b-256 | 6ace0fe9d5560610a59e9f337501e7d07e67f53e23a9e585a721d89255f8456a |