Expand description
Lambda path generation for regularized regression.
This module provides utilities for generating a sequence of lambda values for regularization paths, matching the R glmnet implementation’s output/approach.
§Lambda Path Construction
The lambda path follows this geometric decay pattern (following the glmnet R implementation):
lambda[0] = infinity // effectively infinite (all coefficients zero)
lambda[1] = lambda_decay_factor * lambda_max // First "real" lambda
lambda[k] = lambda[k-1] * lambda_decay_factor // Geometric decayWhere (mapping implementation variables to the Friedman et al. paper):
LAMBDA_EFFECTIVE_INFINITY = infinity: Sentinel value (effectively infinite lambda)lambda_max: Theoretical maximum lambda (paper: $\lambda_{max}$)lambda_decay_factor: Geometric decay factor (paper: $(\epsilon)^{1/(K-1)}$)lambda_min_ratio: Minimum lambda ratio (paper: $\epsilon$)eps = 1.0e-6: Implementation constant for stability
§Note on LAMBDA_EFFECTIVE_INFINITY
The first lambda value is set to infinity, which produces all-zero coefficients. This matches glmnet’s behavior and provides a complete view of the regularization path, showing the exact point where each coefficient enters the model as lambda decreases. Users who don’t need this can simply ignore the first element.
Structs§
- Lambda
Path Options - Options for generating a lambda path.
Functions§
- compute_
lambda_ max - Computes
lambda_max: the smallest lambda for which all penalized coefficients are zero. - extract_
lambdas - Extracts a specific set of lambdas from a path.
- make_
lambda_ path - Generates a lambda path.