Expand description
Ridge and Lasso regression (glmnet-compatible implementations).
This module provides regularized regression methods that are compatible with R’s glmnet package. The implementations follow the same objective functions, standardization conventions, and scaling approaches as glmnet.
§Objective Function
The elastic net objective (which includes ridge and lasso as special cases) is:
minimize over (β₀, β):
(1/(2n)) * Σᵢ (yᵢ - β₀ - xᵢᵀβ)²
+ λ * [(1 - α) * ||β||₂² / 2 + α * ||β||₁]Where:
α = 0: Ridge regression (L2 penalty)α = 1: Lasso regression (L1 penalty)β₀(intercept) is never penalizedλcontrols the overall penalty strength
§Standardization
By default, predictors are standardized before fitting (matching glmnet’s
standardize=TRUE default):
- Each column of X is centered to mean 0 (if intercept is used)
- Each column is scaled to unit variance
- Coefficients are returned on the original scale
§Compatibility with glmnet
These implementations match R’s glmnet behavior:
- Same objective function form
- Same standardization defaults
- Intercept is never penalized
- Coefficients are returned on original data scale
§Modules
preprocess- Data standardization utilitiesridge- Ridge regression (L2 penalty)lasso- Lasso regression (L1 penalty)path- Lambda path generation for regularization paths
Re-exports§
pub use lasso::lasso_fit;pub use lasso::LassoFit;pub use lasso::LassoFitOptions;pub use path::make_lambda_path;pub use path::LambdaPathOptions;pub use preprocess::standardize_xy;pub use preprocess::unstandardize_coefficients;pub use preprocess::StandardizationInfo;pub use ridge::ridge_fit;pub use ridge::RidgeFit;pub use ridge::RidgeFitOptions;
Modules§
- lasso
- Lasso regression (L1-regularized linear regression).
- path
- Lambda path generation for regularized regression.
- preprocess
- Data preprocessing for regularized regression.
- ridge
- Ridge regression (L2-regularized linear regression).