Skip to main content

Large-scale sparse linear classification, regression and ranking in Python

Project description

https://travis-ci.org/scikit-learn-contrib/lightning.svg?branch=master https://ci.appveyor.com/api/projects/status/onn6yba9ckerlvme/branch/master?svg=true

lightning

lightning is a library for large-scale linear classification, regression and ranking in Python.

Highlights:

  • follows the scikit-learn API conventions

  • supports natively both dense and sparse data representations

  • computationally demanding parts implemented in Cython

Solvers supported:

  • primal coordinate descent

  • dual coordinate descent (SDCA, Prox-SDCA)

  • SGD, AdaGrad, SAG, SAGA, SVRG

  • FISTA

Example

Example that shows how to learn a multiclass classifier with group lasso penalty on the News20 dataset (c.f., Blondel et al. 2013):

from sklearn.datasets import fetch_20newsgroups_vectorized
from lightning.classification import CDClassifier

# Load News20 dataset from scikit-learn.
bunch = fetch_20newsgroups_vectorized(subset="all")
X = bunch.data
y = bunch.target

# Set classifier options.
clf = CDClassifier(penalty="l1/l2",
                   loss="squared_hinge",
                   multiclass=True,
                   max_iter=20,
                   alpha=1e-4,
                   C=1.0 / X.shape[0],
                   tol=1e-3)

# Train the model.
clf.fit(X, y)

# Accuracy
print(clf.score(X, y))

# Percentage of selected features
print(clf.n_nonzero(percentage=True))

Dependencies

lightning requires Python >= 2.7, setuptools, Numpy >= 1.3, SciPy >= 0.7 and scikit-learn >= 0.15. Building from source also requires Cython and a working C/C++ compiler. To run the tests you will also need nose >= 0.10.

Installation

Precompiled binaries for the stable version of lightning are available for the main platforms and can be installed using pip:

pip install sklearn-contrib-lightning

or conda:

conda install -c https://conda.anaconda.org/scikit-learn-contrib lightning

The development version of lightning can be installed from its git repository. In this case it is assumed that you have the git version control system, a working C++ compiler, Cython and the numpy development libraries. In order to install this verion, type:

git clone https://github.com/scikit-learn-contrib/lightning.git
cd lightning
python setup.py build
sudo python setup.py install

Documentation

http://contrib.scikit-learn.org/lightning/

On Github

https://github.com/scikit-learn-contrib/lightning

Authors

  • Mathieu Blondel, 2012-present

  • Manoj Kumar, 2015-present

  • Arnaud Rachez, 2016-present

  • Fabian Pedregosa, 2016-present

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

sklearn_contrib_lightning-0.1.0-cp27-cp27m-win_amd64.whl (400.4 kB view details)

Uploaded CPython 2.7m Windows x86-64

sklearn_contrib_lightning-0.1.0-cp27-cp27m-win32.whl (358.9 kB view details)

Uploaded CPython 2.7m Windows x86

File details

Details for the file sklearn_contrib_lightning-0.1.0-cp27-cp27m-win_amd64.whl.

File metadata

File hashes

Hashes for sklearn_contrib_lightning-0.1.0-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 9a13bc88d72e0e6f38c554bde7804f9b3adfe02c74a0e7841317cbe856ffbc9c
MD5 b52fcd2d48bac1608a27f74cefd7a8d1
BLAKE2b-256 41b7749522de61b101b95b227ad0b421c5220ac43d5e2f6b1bbb30bff4699742

See more details on using hashes here.

File details

Details for the file sklearn_contrib_lightning-0.1.0-cp27-cp27m-win32.whl.

File metadata

File hashes

Hashes for sklearn_contrib_lightning-0.1.0-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 8fb3fabb612a5d4340241c6e4be769345927180f8d78d8b747c81078b8b3c790
MD5 17a1a66b4b3c6412fc5e017c4d28082e
BLAKE2b-256 a4debabf8e8eba9c56f6d4cc1552b6eb28483fd7a46fbaf3599df33a76e66c86

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page