Skip to main content

Build status Latest version on conda forge Latest version on PyPI Supported python versions for python-glmnet

This is a Python wrapper for the fortran library used in the R package glmnet. While the library includes linear, logistic, Cox, Poisson, and multiple-response Gaussian, only linear and logistic are implemented in this package.

The API follows the conventions of Scikit-Learn, so it is expected to work with tools from that ecosystem.

Installation

requirements

python-glmnet requires Python version >= 3.6, scikit-learn, numpy, and scipy. Installation from source or via pip requires a Fortran compiler.

conda

conda install -c conda-forge glmnet

pip

pip install glmnet

source

glmnet depends on numpy, scikit-learn and scipy. A working Fortran compiler is also required to build the package. For Mac users, brew install gcc will take care of this requirement.

git clone git@github.com:civisanalytics/python-glmnet.git
cd python-glmnet
python setup.py install

Usage

General

By default, LogitNet and ElasticNet fit a series of models using the lasso penalty (α = 1) and up to 100 values for λ (determined by the algorithm). In addition, after computing the path of λ values, performance metrics for each value of λ are computed using 3-fold cross validation. The value of λ corresponding to the best performing model is saved as the lambda_max_ attribute and the largest value of λ such that the model performance is within cut_point * standard_error of the best scoring model is saved as the lambda_best_ attribute.

The predict and predict_proba methods accept an optional parameter lamb which is used to select which model(s) will be used to make predictions. If lamb is omitted, lambda_best_ is used.

Both models will accept dense or sparse arrays.

Regularized Logistic Regression

from glmnet import LogitNet

m = LogitNet()
m = m.fit(x, y)

Prediction is similar to Scikit-Learn:

# predict labels
p = m.predict(x)
# or probability estimates
p = m.predict_proba(x)

Regularized Linear Regression

from glmnet import ElasticNet

m = ElasticNet()
m = m.fit(x, y)

Predict:

p = m.predict(x)

Download files

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

Source Distribution

glmnet-2.2.1.tar.gz (90.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

glmnet-2.2.1-cp38-cp38-manylinux2010_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

glmnet-2.2.1-cp38-cp38-macosx_10_9_x86_64.whl (421.7 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

glmnet-2.2.1-cp37-cp37m-manylinux2010_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

glmnet-2.2.1-cp37-cp37m-macosx_10_9_x86_64.whl (421.6 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

glmnet-2.2.1-cp36-cp36m-manylinux2010_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

glmnet-2.2.1-cp36-cp36m-macosx_10_9_x86_64.whl (421.6 kB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

File details

Details for the file glmnet-2.2.1.tar.gz.

File metadata

  • Download URL: glmnet-2.2.1.tar.gz
  • Upload date:
  • Size: 90.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1.post20200622 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for glmnet-2.2.1.tar.gz
Algorithm Hash digest
SHA256 3222bca2e901b3f60c2dc22df7aeba6bb9c7b6451b44cbbe1b91084b66f14481
MD5 ca6e15cd110d732245af7159aff61878
BLAKE2b-256 6fe55f60a59da4840202837c07335e92a6f041952e446847d966bd21da72a95d

See more details on using hashes here.

File details

Details for the file glmnet-2.2.1-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: glmnet-2.2.1-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for glmnet-2.2.1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 e94c17af595055c64b70be4b7389ea9ba636cae4cb47933d32ba247d76c8bd7d
MD5 cd96f9c075690c6400c08f38b4df00bd
BLAKE2b-256 4529e3fc33e29b576aad5878e61f17301e335dad7637cdfb85a799f3224c3d2c

See more details on using hashes here.

File details

Details for the file glmnet-2.2.1-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: glmnet-2.2.1-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 421.7 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for glmnet-2.2.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 383d4dcd52d135e75c507e04de30116380328696c02f3cbcd6fafd6bc24db82a
MD5 a059fd21d3d2c23d4e536e2ba9f44a25
BLAKE2b-256 a6f6662b611320e92e4f4bdc168da242cd4e0c3e32633ef3cb230646893405d9

See more details on using hashes here.

File details

Details for the file glmnet-2.2.1-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: glmnet-2.2.1-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for glmnet-2.2.1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 aa43a8b43b1713c0615ebc6b44558592ec61cb39df0c17c752066ed9501550f3
MD5 c24fef3bd23eb9ab220dcca897c75671
BLAKE2b-256 8dd08d19e49b8ce8c4a4ea145c65ca05ed19f34217e7f99e23e653b803b61b13

See more details on using hashes here.

File details

Details for the file glmnet-2.2.1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: glmnet-2.2.1-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 421.6 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for glmnet-2.2.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 def0820c5a9b6ba50a325f52c430b6df5e2eade52f14dce8d4642ce0a1c83b6f
MD5 62aff936adbca03459c1facbfb3d446c
BLAKE2b-256 ce703a10f7165e082fc27f9745ae771b57100e369d09100b39da736ed0ef5308

See more details on using hashes here.

File details

Details for the file glmnet-2.2.1-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: glmnet-2.2.1-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for glmnet-2.2.1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 1c93e9b53728eba6a24eb852674c048a16efd35a96894e2e5847fc3d8b15ff04
MD5 0d4140cbdd70adf4055bb49cbd426729
BLAKE2b-256 2f6bb85e409f5084b4f436c6518d4c33195ac4ca03804b79100dd9f8e2a1304d

See more details on using hashes here.

File details

Details for the file glmnet-2.2.1-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: glmnet-2.2.1-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 421.6 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for glmnet-2.2.1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5cd722447ef285fa77897f788ba6971cc3edd4d6d308e81549bf2c7db076815a
MD5 0d3be91f48b1ce9c826fe37a5170fcd5
BLAKE2b-256 25597e6553de9fd6adcf1780e7bf2a091b8d6b773795328c42ce985da63518c6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.2.1 This release

7 files

2.2.0

4 files

2.1.1

2 files

2.0.0

1 file

1.0.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page