Large-scale sparse linear classification, regression and ranking in Python
Project description
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 >= 3.6, setuptools, Joblib, Numpy >= 1.12, SciPy >= 0.19 and scikit-learn >= 0.19. Building from source also requires Cython and a working C/C++ compiler. To run the tests you will also need pytest.
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 conda-forge sklearn-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 the development version, type:
git clone https://github.com/scikit-learn-contrib/lightning.git
cd lightning
python setup.py install
Documentation
On GitHub
Citing
If you use this software, please cite it. Here is a BibTex snippet that you can use:
@misc{lightning_2016,
author = {Blondel, Mathieu and
Pedregosa, Fabian},
title = {{Lightning: large-scale linear classification,
regression and ranking in Python}},
year = 2016,
doi = {10.5281/zenodo.200504},
url = {https://doi.org/10.5281/zenodo.200504}
}
Other citing formats are available in its Zenodo entry.
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
Built Distributions
Hashes for sklearn-contrib-lightning-0.6.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72579fcf2df9b546997baa5e271f28adf898b5f68c6c6c718bbb53ea15d011c5 |
|
MD5 | 6a025bc5211c191a0b0bafe8e1b06532 |
|
BLAKE2b-256 | 69364cb7ac6c4b193372890cc426c0d4175adea4631b119d4b5e37f9a846f75e |
Hashes for sklearn_contrib_lightning-0.6.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9aff9cd54ae9a66b815e7a1fdcba4df0ccb948071843dd4e05e4a255292f597f |
|
MD5 | e7e08aeeb7638696d34c8dd8bcaa8599 |
|
BLAKE2b-256 | d3dd345c5c4e84024c20873731e3c076c3e228414fca6e4c8c2c93adeaed3b24 |
Hashes for sklearn_contrib_lightning-0.6.1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b670377d5c02da528c4e6527b95947619995f673a749e640bf1b95a74b3fde77 |
|
MD5 | 5e24a29db32fc5fa47ab7799191a7ff0 |
|
BLAKE2b-256 | 59005d64f820bdff538f6e02186c632a9ae89d25fc099d71dc9494988f1ca04e |
Hashes for sklearn_contrib_lightning-0.6.1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5220da0a09793e32863c38ecd24cb9e9dea363e5693c2dd6139030ebebf787f |
|
MD5 | e4d8f7f7ccbfac27bf7ae4124d085cfb |
|
BLAKE2b-256 | 84f00bf95592bc7d7295ddd294ef370e4a4918ab730f20bc9f4997bce35b5493 |
Hashes for sklearn_contrib_lightning-0.6.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70bebc28a51ceb6211e66fa5d47a9417181d5d98ac0181c45ed2507a7b049b51 |
|
MD5 | 60ed60c3ffa2ca15e5f3fb374aba4ca1 |
|
BLAKE2b-256 | 955608dce4f943749a620e588df3653566df6c609d0c869cd9146567e09a6252 |
Hashes for sklearn_contrib_lightning-0.6.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59353d4acfd86cd003628e9da255526d52b73e4c18ce869ae85752ee97cb477b |
|
MD5 | cd9855645625a8809e7ce0fac427f02a |
|
BLAKE2b-256 | 877d65d7260bf7ae8d5ac716c63b6abfed50c125efefc2b63e6f9647df1fc9f0 |
Hashes for sklearn_contrib_lightning-0.6.1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98b71e4357b9c8f4844f6c849ab6590462775d083fa3f018caf867386bc970bc |
|
MD5 | 3c09a19723c606ea9e3c505b981faae0 |
|
BLAKE2b-256 | a75a34cb5694c4a79332454765cfa7e995d8db47ff377854ea3aa34b4197afaa |
Hashes for sklearn_contrib_lightning-0.6.1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d691a218cd40322c8d9f924f3cd9f831f9a386a0964873181d6b1617f0c14d4f |
|
MD5 | fa01a91b872ff646faba078596157a42 |
|
BLAKE2b-256 | 37703522a7c69fce0533ab09c77f2b0d83db4b6e032443db7d93a211774d299f |
Hashes for sklearn_contrib_lightning-0.6.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce0e61eddf832aa929a46c21f0ad071b4ef1634447445d31f95fc7ab2e9ced0b |
|
MD5 | b2bffc1666dc33951e1db34c0a80e26b |
|
BLAKE2b-256 | 8b6f334ebc9ba7713711e4a0e8b67c9fa88228edd43b6fd32063cf759245dbbe |
Hashes for sklearn_contrib_lightning-0.6.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46f5f3404fa521dee3009193d8a26109f2b299ac4b3d575eb644ff743d79c464 |
|
MD5 | 677090b9cbb1aceffc1f16db9064d8ff |
|
BLAKE2b-256 | 141fc3ba4aa048e9bcfc28460e693079048effa267391f55a65ac3321b5baf7a |
Hashes for sklearn_contrib_lightning-0.6.1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cec9fb3f495caedf063792e86de2c627aa81428206c9506ee5ebff615ea27e6 |
|
MD5 | 8cb350b85ca13453726547f98cbd7050 |
|
BLAKE2b-256 | 078b338706adae6f879a711d969182727e49e62e91f60ab6dc7f8e30e50d1144 |
Hashes for sklearn_contrib_lightning-0.6.1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f9281822b7ef8b486d4a04bc8b427b4f7a516c8d0ac85aa08d91e82bec2b8eb |
|
MD5 | 889007c46d263d298f6925c8329925fb |
|
BLAKE2b-256 | 850fce7cb033816606e59b005e3e2cff03faba8b50a32a08951008b6fb953471 |
Hashes for sklearn_contrib_lightning-0.6.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 471776975462c159d610c377f56add4b94220c57e6202d909e8b881e421ff1a8 |
|
MD5 | 8d69649efd4222a01f4a7aa7cb112b66 |
|
BLAKE2b-256 | 4247b51d9527895f3c52e76c5ec1e7c9d193e776d1897061d092b8271c230864 |
Hashes for sklearn_contrib_lightning-0.6.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7b1e1e171685663a1c7c9a7e29e0e7279f7ddb22ac5b7f97b4969cea1692632 |
|
MD5 | e3be161699b175138a2148b7af49d588 |
|
BLAKE2b-256 | 3f0df490d9c5124dcfd93ebb10b9bfbe51d6b8af322c602b306e95176ad53b97 |
Hashes for sklearn_contrib_lightning-0.6.1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 150a9e345a74ec086cccb30c757d4b41a72681df1e00f0c9c496e1df0297d909 |
|
MD5 | d935c21f2a1c189be78f306e71b2bcc3 |
|
BLAKE2b-256 | 24f41847ea3244235bec4f8a12451b1b96413e1a39a74139eaf06401c75298b2 |
Hashes for sklearn_contrib_lightning-0.6.1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8521d7697f2cfa1f07a4855a68a07b17da800ca5bdfe669f93c40f962af9872 |
|
MD5 | e1c421f8f8deb33430688c2f505f2aeb |
|
BLAKE2b-256 | 2c1d024f62431d381bfa9902d112d1fda4a4ffe299114ac823acf7d482ce1cab |
Hashes for sklearn_contrib_lightning-0.6.1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88e01dc1eff9360c7d6c61cc38f14a6ace2cf88fc618feb248fc5d84c469a928 |
|
MD5 | 3e3755b03a49bc8363d258339c5f007f |
|
BLAKE2b-256 | 60a1b147195af06dcdbfb9ab721c14446e87cd7d848f0c0b3fe2bd277bc81c7c |