Generalized Elastic Net
Project description
Generalized Elastic Net Library
- Version:
- Released:
- Publication: [arXiv]
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]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for generalized-elastic-net-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51fe0bea3a8b9f00245470229b7e595bce6bf55af37fc52015f7bafc2ee1f64b |
|
MD5 | 97011009fa7b5c5fabf5d01a6b9a45b2 |
|
BLAKE2b-256 | 609bd1c5ea3582f0955a4fdf13a5f75572b9c3da1cc41c887b6f96ccc9b6cde8 |
Hashes for generalized_elastic_net-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de753275e115d40099b34c114897f7cb8b1fb274d68e49384b203d4f985822f0 |
|
MD5 | c4d43e45dfe6f5491124260f31129545 |
|
BLAKE2b-256 | dbc16524019511bde30385048c777378a5e429f89ab6a4397438fb056d185b25 |