Adaptive Lasso
A scikit-learn compatible implementation of the Adaptive Lasso algorithm for feature selection and regression.
Overview
Adaptive Lasso is an extension of the standard Lasso method that provides improved feature selection properties through weighted L1 penalties. It assigns different weights to different coefficients in the L1 penalty, usually based on preliminary estimates of the coefficients.
This implementation follows the scikit-learn API design and can be used as a drop-in replacement for other scikit-learn linear models.
Installation
pip install adalasso
Usage
from adalasso import AdaptiveLasso
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
# Generate sample data
X, y = make_regression(n_samples=100, n_features=20, n_informative=5, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
# Initialize and fit the model
model = AdaptiveLasso(alpha=0.1, gamma=1.0)
model.fit(X_train, y_train)
# Make predictions
y_pred = model.predict(X_test)
# Access model coefficients
print("Coefficients:", model.coef_)
print("Intercept:", model.intercept_)
Parameters
alpha: Regularization strengthgamma: Power parameter for the adaptive weightsfit_intercept: Whether to calculate the interceptmax_iter: Maximum number of iterationstol: Tolerance for optimization
See the class documentation for a full list of parameters.
Development
Running Tests
To run the tests, you'll need to install the development dependencies:
pip install pytest pytest-cov
Then run the tests with:
pytest --cov=adalasso adalasso/tests/
Visualization Examples
Regularization Path Comparison
The following figure shows how coefficients evolve with different regularization strengths for standard Lasso versus Adaptive Lasso:
Feature Selection Performance
This figure demonstrates how Adaptive Lasso performs better at selecting the correct number of non-zero features across different regularization strengths:
References
- Zou, H. (2006). The adaptive lasso and its oracle properties. Journal of the American Statistical Association, 101(476), 1418-1429.
License
MIT License
Metadata
Release files for adalasso 0.1.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 | |
|---|---|---|---|---|
| adalasso-0.1.1.tar.gz | 7.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| adalasso-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.6 kB
Release files / adalasso-0.1.1.tar.gz
| Download URL | adalasso-0.1.1.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ca7ba3f185e4e8b4253343c6c200ff2b93b89e89236059c2961e0bf09d962fb
|
|
BLAKE2b-256 checksum How to use checksums |
c12b2541cef05925d42fad4d6c10108c50c1ce4a16bb8e3a620ebdda9283090b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.15
|
Release files / adalasso-0.1.1-py3-none-any.whl
| Download URL | adalasso-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b9bd9d61f0e660c8d33719bc93fe134e7a41f29e60df2ca6cfe741efdb0be3a
|
|
BLAKE2b-256 checksum How to use checksums |
e0bae18d5d8657112a747e66cd323d24af73fd6067031e0f77dbff56fb99e730
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.15
|
Security for adalasso 0.1.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.