Group Lasso package for Python
Project description
Group Lasso package for Python.
## Installation Guide
### Using pip
The easiest way to install GroupLasso is using pip
` pip install GroupLasso `
### Building from source
Run the following commands:
` git clone https://github.com/AnchorBlues/GroupLasso.git cd GroupLasso python setup.py install `
## Getting started Here is the GroupLassoRegressor model:
`python from grouplasso import GroupLassoRegressor `
Create sample dataset: `python import numpy as np np.random.seed(0) X = np.random.randn(10, 3) # target variable is strongly correlated with 0th feature. y = X[:, 0] + np.random.randn(10) * 0.1 `
Set group_ids, which specify group membership: `python # 0th feature and 1st feature are the same group. group_ids = np.array([0, 0, 1]) `
You can now train Group Lasso: `python model = GroupLassoRegressor(group_ids=group_ids, random_state=42, verbose=False, alpha=1e-1) model.fit(X, y) `
Note that all the members of a particular group are either selected(coef_ != 0) or not selected(coef_ == 0). `python model.coef_ # array([ 0.84795715, -0.01193528, -0. ]) `
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
File details
Details for the file GroupLasso-0.2.0.tar.gz
.
File metadata
- Download URL: GroupLasso-0.2.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8987f2d6cbab53abe3004157db8a393fa73d36562bda265a7ed737d62e8109b |
|
MD5 | ef70c633d23ba93b1c7248a20b017b19 |
|
BLAKE2b-256 | 015bfae57ef7287a257bd0afd64e34aece245e01b67e7a0257c4c784f0cd08df |