Skip to main content

Adaptive Lasso implementation following scikit-learn API

Project description

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 strength
  • gamma: Power parameter for the adaptive weights
  • fit_intercept: Whether to calculate the intercept
  • max_iter: Maximum number of iterations
  • tol: Tolerance for optimization

See the class documentation for a full list of parameters.

Visualization Examples

Regularization Path Comparison

The following figure shows how coefficients evolve with different regularization strengths for standard Lasso versus Adaptive Lasso:

Adaptive Lasso Regularization Path

Feature Selection Performance

This figure demonstrates how Adaptive Lasso performs better at selecting the correct number of non-zero features across different regularization strengths:

Feature Selection vs Regularization

References

  • Zou, H. (2006). The adaptive lasso and its oracle properties. Journal of the American Statistical Association, 101(476), 1418-1429.

License

MIT License

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

adalasso-0.1.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

adalasso-0.1.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file adalasso-0.1.0.tar.gz.

File metadata

  • Download URL: adalasso-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.15

File hashes

Hashes for adalasso-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c1e9905be0ac8571ff5f0efd1aef204dba4ed084e7373d8bb3f8c580953ef952
MD5 dd448f9cc6f081d3ac914185bf02350c
BLAKE2b-256 3db66ebb9fd70a7b19c37279bf85f04d3dd2081a238d9afe4eeb482370af7edd

See more details on using hashes here.

File details

Details for the file adalasso-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: adalasso-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.15

File hashes

Hashes for adalasso-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd9a682d0003e6c8eaabefe6a63f83117209aed5f7ff908db14e4e1113647a74
MD5 6c4baa179d6015470e22cf7c30b1f114
BLAKE2b-256 f33a0e6f1471b7ba64712737deab537d1695e07bb9dc0c1541d934038d9cf71e

See more details on using hashes here.

Supported by

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