Shrinkage

shrinkage::CoordinatePenalty

Shrinkage for Rust · rust · 0.3.0

pub trait CoordinatePenalty: Penalty<Error = shrinkage::FitError>

A convex separable penalty with exact scalar updates and KKT checks.

The complete value must equal the sum of its coordinate terms. Coupled penalties, such as SLOPE and group lasso, do not satisfy this contract.

Methods

coordinate_violation

fn coordinate_violation(
    &self,
    coordinate: usize,
    value: f64,
    loss_gradient: f64
) -> Result<f64, FitError>

Return the distance of zero from loss_gradient + subgradient_j(value). The result must be finite and nonnegative, in gradient units.

Errors

Reject invalid parameters, indices, inputs, or nonfinite arithmetic.

minimize_coordinate

fn minimize_coordinate(
    &self,
    coordinate: usize,
    linear: f64,
    curvature: f64
) -> Result<f64, FitError>

Minimize curvature * value² / 2 - linear * value + penalty_j(value). Curvature must be finite and nonnegative. At zero curvature, return a finite minimizer when one exists, or an error for an unbounded subproblem.

Errors

Reject invalid parameters, indices, inputs, or nonfinite arithmetic.

Implementation of CoordinatePenalty

impl CoordinatePenalty for shrinkage::ElasticNet

Implementation of CoordinatePenalty

impl CoordinatePenalty for shrinkage::L1

Implementation of CoordinatePenalty

impl CoordinatePenalty for shrinkage::Ridge