Skip to main content

Group Lasso

PyPI Downloads https://travis-ci.org/yngvem/group-lasso.svg?branch=master https://coveralls.io/repos/github/yngvem/group-lasso/badge.svg https://readthedocs.org/projects/group-lasso/badge/?version=latest https://img.shields.io/pypi/l/group-lasso.svg https://img.shields.io/badge/code%20style-black-000000.svg CodeFactor

The group lasso [1] regulariser is a well known method to achieve structured sparsity in machine learning and statistics. The idea is to create non-overlapping groups of covariates, and recover regression weights in which only a sparse set of these covariate groups have non-zero components.

There are several reasons for why this might be a good idea. Say for example that we have a set of sensors and each of these sensors generate five measurements. We don’t want to maintain an unneccesary number of sensors. If we try normal LASSO regression, then we will get sparse components. However, these sparse components might not correspond to a sparse set of sensors, since they each generate five measurements. If we instead use group LASSO with measurements grouped by which sensor they were measured by, then we will get a sparse set of sensors.

An extension of the group lasso regulariser is the sparse group lasso regulariser [2], which imposes both group-wise sparsity and coefficient-wise sparsity. This is done by combining the group lasso penalty with the traditional lasso penalty. In this library, I have implemented an efficient sparse group lasso solver being fully scikit-learn API compliant.

About this project

This project is developed by Yngve Mardal Moe and released under an MIT lisence. I am still working out a few things so changes might come rapidly.

Installation guide

Group-lasso requires Python 3.5+, numpy and scikit-learn. To install group-lasso via pip, simply run the command:

pip install group-lasso

Alternatively, you can manually pull this repository and run the setup.py file:

git clone https://github.com/yngvem/group-lasso.git
cd group-lasso
python setup.py

Documentation

You can read the full documentation on readthedocs.

Examples

There are several examples that show usage of the library here.

Further work

  1. Fully test with sparse arrays and make examples

  2. Make it easier to work with categorical data

  3. Poisson regression

Implementation details

The problem is solved using the FISTA optimiser [3] with a gradient-based adaptive restarting scheme [4]. No line search is currently implemented, but I hope to look at that later.

Although fast, the FISTA optimiser does not achieve as low loss values as the significantly slower second order interior point methods. This might, at first glance, seem like a problem. However, it does recover the sparsity patterns of the data, which can be used to train a new model with the given subset of the features.

Also, even though the FISTA optimiser is not meant for stochastic optimisation, it has to my experience not suffered a large fall in performance when the mini batch was large enough. I have therefore implemented mini-batch optimisation using FISTA, and thus been able to fit models based on data with ~500 columns and 10 000 000 rows on my moderately priced laptop.

Finally, we note that since FISTA uses Nesterov acceleration, is not a descent algorithm. We can therefore not expect the loss to decrease monotonically.

References

Release files for group-lasso 1.5.0

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

Source distribution (sdist)

Source distribution for group-lasso 1.5.0
File Size Uploaded
group-lasso-1.5.0.tar.gz 4.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for group-lasso 1.5.0
File Interpreter ABI Platform
group_lasso-1.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 4.4 MB

Release files / group-lasso-1.5.0.tar.gz

Download URL group-lasso-1.5.0.tar.gz
Size 4.3 MB
Tags Source
SHA-256 checksum
How to use checksums
3a86115fdfa387021c805a8e3bf09c1f1cc1e32b880778ab017488199ef57310
BLAKE2b-256 checksum
How to use checksums
21b4784d01db4eb7f3eafb9f1a9ac6f141d7050aba615cf6e0186ba9ebdaa299
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / group_lasso-1.5.0-py3-none-any.whl

Download URL group_lasso-1.5.0-py3-none-any.whl
Size 33.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a20ad4807834a4438a8829a36e0f355c7633e347aa73502dae8a22fc6e75e977
BLAKE2b-256 checksum
How to use checksums
6312ca38bf6ce7e97ce1b07652efdcec5e69caa0cce8f738afd66268c186fb3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.5.0 This release

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.1.1

2 release files

1.0.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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