Shrinkage

Ridge

Ridge shrinks coefficients continuously and usually leaves them nonzero. Its constraint region is a disk. This is a squared L2 penalty, which differs from the unsquared norm used by Group LASSO.

R(β)=λ2∥β∥22. R(\beta) = \frac{\lambda}{2}\|\beta\|_2^2.

Constraint region

Feasible region for ridge; the shaded set includes its boundary.

λ=2\lambda = 2: β12+β22≤1\beta_1^2 + \beta_2^2 \leq 1. See the plot conventions for the fixed budget and coefficient scale.

Use the penalty

use shrinkage::{Penalty, ProximalPenalty, Ridge};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let penalty = Ridge::new(0.5);
    let coefficients = [2.0, -1.0];
    println!("Penalty: {}", penalty.value(&coefficients)?);
    let mut shrunk = [0.0; 2];
    penalty.prox(&coefficients, 1.0, &mut shrunk)?;
    println!("Proximal result: {shrunk:?}");
    Ok(())
}

Use proximal gradient or IRLS with Gaussian or binomial datafits. Its proximal map divides each input by 1+sλ1 + s\lambda. With zero strength, it returns the input unchanged.

API: shrinkage::Ridge.