pub fn make_lambda_path(
x: &Matrix,
y: &[f64],
options: &LambdaPathOptions,
penalty_factor: Option<&[f64]>,
intercept_col: Option<usize>,
) -> Vec<f64>Expand description
Generates a lambda path.
lambda[0] = inf // Large value (all coefficients zero)
lambda[1] = lambda_decay_factor * lambda_max // First real lambda
lambda[k] = lambda[k-1] * lambda_decay_factor // Geometric decayWhere:
lambda_max = max(|X^T y|) / max(alpha, 1e-3): Theoretical lambda_maxlambda_decay_factor = max(lambda_min_ratio, eps)^(1/(nlambda-1)): Geometric decay factoreps = 1.0e-6: Minimum lambda_min_ratio value
§Arguments
x- Standardized design matrix (n × p), columns are unit normy- Standardized response vector (||y|| = 1)options- Lambda path generation optionspenalty_factor- Optional per-feature penalty factorsintercept_col- Index of intercept column (typically 0)
§Returns
A vector of lambda values in decreasing order.
§First Lambda (LAMBDA_EFFECTIVE_INFINITY)
The first lambda value is set to infinity, which effectively produces
all-zero coefficients. This matches R’s cursed behavior.
PROOF OF CONCEPT/R EQUIVALENCE: We may want to make this optional in future versions.
§Default lambda_min_ratio
Following glmnet:
- If
n >= p:lambda_min_ratio = 0.0001 - If
n < p:lambda_min_ratio = 0.01