跳转到主要内容

Python中的大规模稀疏线性分类、回归和排序

项目描述

https://github.com/scikit-learn-contrib/lightning/actions/workflows/main.yml/badge.svg?branch=master https://zenodo.org/badge/DOI/10.5281/zenodo.200504.svg

lightning

lightning是一个用于Python中大规模线性分类、回归和排序的库。

亮点

  • 遵循scikit-learn API约定

  • 支持密集和稀疏数据表示

  • 计算密集的部分使用Cython实现

支持的求解器

  • 原坐标下降

  • 对偶坐标下降(SDCA,Prox-SDCA)

  • SGD,AdaGrad,SAG,SAGA,SVRG

  • FISTA

示例

示例说明如何在News20数据集上使用分组Lasso惩罚学习多类分类器(参考:Blondel等人,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))

依赖关系

lightning需要Python >= 3.7,setuptools,Joblib,Numpy >= 1.12,SciPy >= 0.19和scikit-learn >= 0.19。从源代码构建还需要Cython和一个可工作的C/C++编译器。要运行测试,您还需要pytest。

安装

lightning的稳定版本在主要平台上都有预编译的二进制文件,可以使用pip安装

pip install sklearn-contrib-lightning

或conda

conda install -c conda-forge sklearn-contrib-lightning

可以从lightning的git仓库安装其开发版本。在这种情况下,假设您已经安装了git版本控制系统、一个可工作的C++编译器、Cython和numpy开发库。要安装开发版本,请输入

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

文档

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

在GitHub上

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

引用

如果您使用此软件,请引用它。以下是一个BibTex片段,您可以使用它

@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}
}

其他引用格式可在其Zenodo条目中找到。

作者

  • Mathieu Blondel

  • Manoj Kumar

  • Arnaud Rachez

  • Fabian Pedregosa

  • Nikita Titov

项目详情


下载文件

下载您平台上的文件。如果您不确定要选择哪一个,请了解更多关于安装包的信息。

源分布

sklearn-contrib-lightning-0.6.2.post0.tar.gz (70.1 kB 查看散列)

上传时间

构建分布

sklearn_contrib_lightning-0.6.2.post0-cp310-cp310-win_amd64.whl (640.1 kB 查看散列)

上传时间 CPython 3.10 Windows x86-64

sklearn_contrib_lightning-0.6.2.post0-cp310-cp310-macosx_10_9_x86_64.whl (665.3 kB 查看散列)

上传时间 CPython 3.10 macOS 10.9+ x86-64

sklearn_contrib_lightning-0.6.2.post0-cp39-cp39-win_amd64.whl (639.5 kB 查看散列)

上传于 CPython 3.9 Windows x86-64

sklearn_contrib_lightning-0.6.2.post0-cp39-cp39-win32.whl (545.7 kB 查看哈希值)

上传于 CPython 3.9 Windows x86

sklearn_contrib_lightning-0.6.2.post0-cp39-cp39-macosx_10_9_x86_64.whl (665.2 kB 查看哈希值)

上传于 CPython 3.9 macOS 10.9+ x86-64

sklearn_contrib_lightning-0.6.2.post0-cp38-cp38-win_amd64.whl (644.0 kB 查看哈希值)

上传于 CPython 3.8 Windows x86-64

sklearn_contrib_lightning-0.6.2.post0-cp38-cp38-win32.whl (549.5 kB 查看哈希值)

上传于 CPython 3.8 Windows x86

sklearn_contrib_lightning-0.6.2.post0-cp38-cp38-macosx_10_9_x86_64.whl (653.9 kB 查看哈希值)

上传于 CPython 3.8 macOS 10.9+ x86-64

sklearn_contrib_lightning-0.6.2.post0-cp37-cp37m-win_amd64.whl (627.0 kB 查看哈希值)

上传于 CPython 3.7m Windows x86-64

sklearn_contrib_lightning-0.6.2.post0-cp37-cp37m-win32.whl (538.6 kB 查看哈希值)

上传于 CPython 3.7m Windows x86

sklearn_contrib_lightning-0.6.2.post0-cp37-cp37m-macosx_10_9_x86_64.whl (646.9 kB 查看散列值)

上传时间 CPython 3.7m macOS 10.9+ x86-64

由以下支持