Skip to main content

Generalized Elastic Net Library

Generalized elastic net is a penalty method for variable selection and regularization in high-dimensional sparse linear models. It generalizes and outperforms the lasso, ridge, and nonnegative elastic net through (1) capturing the penalty weights for individual features or/and interactions between any two features; (2) controling the range of the coefficients.

The algorithm is available through this public Python library. It applys multiplicative updates on a quadratic programming problem but contains absolute values of variables and a rectangle-range constraint. The algorithm is shown to converge monotonically to the global in the publication.

To install

The generalized elastic net library requires Python 3 and is pip friendly. To get started, simply do:

pip install generalized-elastic-net

or check out the code from out GitHub repository. You can now use the package in Python with:

from generalized_elastic_net import GeneralizedElasticNet

Example

Input parameters:

>>> N = 3
>>> K = 4
>>> Xmat = np.random.randn(N, K)
>>> Yvec = np.random.randn(N)
>>> print(Yvec)
[-0.72166018 -0.18367545 -0.77768828]
>>> lam_1 = 0.0034
>>> lam_2 = 0
>>> sigma = np.diag([1] * K)
>>> wvec = np.ones(K)
>>> lowbo = -1e5 * np.ones(K)
>>> upbo = np.inf * np.ones(K)

Fit the model:

>>> s = GeneralizedElasticNet(lam_1=lam_1, lam_2=lam_2, lowbo=lowbo, upbo=upbo, wvec=wvec, sigma=sigma)
>>> s.fit(Xmat=Xmat, Yvec=Yvec)

Output prediction:

>>> print(s.predict(X=Xmat))
[-0.72167257 -0.18245943 -0.77582073]

Output coefficients:

>>> print(s.coef_)
[-21095.74451325 -94129.49591188  25282.3047479  -10810.57632817]

Metadata

Release files for generalized-elastic-net 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for generalized-elastic-net 1.0.1
File Size Uploaded
generalized-elastic-net-1.0.1.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for generalized-elastic-net 1.0.1
File Interpreter ABI Platform
generalized_elastic_net-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / generalized-elastic-net-1.0.1.tar.gz

Download URL generalized-elastic-net-1.0.1.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fea9771c5ffcc0ca3527644670e93d7a64bff9c4e2b8113dc0894ac318240009
BLAKE2b-256 checksum
How to use checksums
c07a2bf6576b54d0ba552b2e607e7df009defc4b0795f52d5a725c3aa04d2cdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release files / generalized_elastic_net-1.0.1-py3-none-any.whl

Download URL generalized_elastic_net-1.0.1-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3b10dd6b33ddc504bb557b9e00acd63b023c6169b8ea13c7a2d770af962a963
BLAKE2b-256 checksum
How to use checksums
09303d58084f2b7e7c44377fbf4577d07b8bfe854d9e7b14b06ef0136b8026ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page