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)
Metadata
Release files for glmnet 2.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| glmnet-2.2.1.tar.gz | 90.1 kB | Without provenance | Details for glmnet-2.2.1.tar.gz |
Built distributions (wheels)
Total release size: 6.2 MB
Release files / glmnet-2.2.1.tar.gz
| Download URL | glmnet-2.2.1.tar.gz |
|---|---|
| Size | 90.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3222bca2e901b3f60c2dc22df7aeba6bb9c7b6451b44cbbe1b91084b66f14481
|
|
BLAKE2b-256 checksum How to use checksums |
6fe55f60a59da4840202837c07335e92a6f041952e446847d966bd21da72a95d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / glmnet-2.2.1-cp38-cp38-manylinux2010_x86_64.whl
| Download URL | glmnet-2.2.1-cp38-cp38-manylinux2010_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.8 Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
e94c17af595055c64b70be4b7389ea9ba636cae4cb47933d32ba247d76c8bd7d
|
|
BLAKE2b-256 checksum How to use checksums |
4529e3fc33e29b576aad5878e61f17301e335dad7637cdfb85a799f3224c3d2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / glmnet-2.2.1-cp38-cp38-macosx_10_9_x86_64.whl
| Download URL | glmnet-2.2.1-cp38-cp38-macosx_10_9_x86_64.whl |
|---|---|
| Size | 421.7 kB |
| Tags | CPython 3.8 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
383d4dcd52d135e75c507e04de30116380328696c02f3cbcd6fafd6bc24db82a
|
|
BLAKE2b-256 checksum How to use checksums |
a6f6662b611320e92e4f4bdc168da242cd4e0c3e32633ef3cb230646893405d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / glmnet-2.2.1-cp37-cp37m-manylinux2010_x86_64.whl
| Download URL | glmnet-2.2.1-cp37-cp37m-manylinux2010_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
aa43a8b43b1713c0615ebc6b44558592ec61cb39df0c17c752066ed9501550f3
|
|
BLAKE2b-256 checksum How to use checksums |
8dd08d19e49b8ce8c4a4ea145c65ca05ed19f34217e7f99e23e653b803b61b13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / glmnet-2.2.1-cp37-cp37m-macosx_10_9_x86_64.whl
| Download URL | glmnet-2.2.1-cp37-cp37m-macosx_10_9_x86_64.whl |
|---|---|
| Size | 421.6 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
def0820c5a9b6ba50a325f52c430b6df5e2eade52f14dce8d4642ce0a1c83b6f
|
|
BLAKE2b-256 checksum How to use checksums |
ce703a10f7165e082fc27f9745ae771b57100e369d09100b39da736ed0ef5308
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / glmnet-2.2.1-cp36-cp36m-manylinux2010_x86_64.whl
| Download URL | glmnet-2.2.1-cp36-cp36m-manylinux2010_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
1c93e9b53728eba6a24eb852674c048a16efd35a96894e2e5847fc3d8b15ff04
|
|
BLAKE2b-256 checksum How to use checksums |
2f6bb85e409f5084b4f436c6518d4c33195ac4ca03804b79100dd9f8e2a1304d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / glmnet-2.2.1-cp36-cp36m-macosx_10_9_x86_64.whl
| Download URL | glmnet-2.2.1-cp36-cp36m-macosx_10_9_x86_64.whl |
|---|---|
| Size | 421.6 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
5cd722447ef285fa77897f788ba6971cc3edd4d6d308e81549bf2c7db076815a
|
|
BLAKE2b-256 checksum How to use checksums |
25597e6553de9fd6adcf1780e7bf2a091b8d6b773795328c42ce985da63518c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for glmnet 2.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.