Shrinkage

shrinkage::GroupLasso

Shrinkage for Rust · rust · 0.3.0

pub struct GroupLasso

Group LASSO lambda * sum_g weights[g] * ||beta[g]||₂.

Groups address optimization-scale coefficients and exclude intercepts. The supplied DisjointGroups fixes the coefficient count, explicit weights, and coverage policy. There is no implicit group-size scaling. Zero-weight groups and uncovered coefficients are unpenalized. Singleton groups give weighted L1, and zero lambda gives the zero penalty.

The exact proximal map shrinks each block by max(1 - step * lambda * weight / ||input[g]||₂, 0) and copies free coordinates. Value evaluation and the prox take linear time and allocate no scratch storage. Gaussian fits use crate::ProximalGradient's reusable product and iteration workspaces through both typed and runtime problems.

use shrinkage::{DisjointGroups, GroupLasso, Penalty, ProximalPenalty, UncoveredPolicy};

let groups = DisjointGroups::new(
    3, vec![vec![0, 2]], vec![2.0], UncoveredPolicy::Unpenalized,
)?;
let penalty = GroupLasso::new(0.5, groups);
assert_eq!(penalty.value(&[3.0, 9.0, 4.0])?, 5.0);
let mut output = [0.0; 3];
penalty.prox(&[3.0, 9.0, 4.0], 2.0, &mut output)?;
assert!((output[0] - 1.8).abs() < 1e-14);
assert_eq!(output[1], 9.0);

Inherent implementation

impl GroupLasso

groups

pub fn groups(&self) -> &DisjointGroups

Immutable group definitions, weights, and coverage policy.

lambda

pub fn lambda(&self) -> f64

Configured multiplier of all explicit group weights.

new

pub fn new(lambda: f64, groups: DisjointGroups) -> Self

Set the overall strength and validated groups. Strength is checked on use.

Implementation of Clone

impl Clone for GroupLasso

clone

fn clone(&self) -> Self

Implementation of Debug

impl Debug for GroupLasso

fmt

fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

Implementation of Penalty

impl Penalty for GroupLasso

Error

type Error = FitError;

validate_input

fn validate_input(&self, coefficients: &[f64]) -> Result<(), FitError>

value

fn value(&self, coefficients: &[f64]) -> Result<f64, FitError>

Implementation of ProximalPenalty

impl ProximalPenalty for GroupLasso

prox

fn prox(
    &self,
    input: &[f64],
    step: f64,
    output: &mut [f64]
) -> Result<(), FitError>

Implementation of Freeze

impl Freeze for GroupLasso

Implementation of RefUnwindSafe

impl RefUnwindSafe for GroupLasso

Implementation of Send

impl Send for GroupLasso

Implementation of Sync

impl Sync for GroupLasso

Implementation of Unpin

impl Unpin for GroupLasso

Implementation of UnsafeUnpin

impl UnsafeUnpin for GroupLasso

Implementation of UnwindSafe

impl UnwindSafe for GroupLasso

Implementation of Any

impl<T> Any for T where T: 'static + ?Sized

Implementation of Borrow

impl<T> Borrow<T> for T where T: ?Sized

Implementation of BorrowMut

impl<T> BorrowMut<T> for T where T: ?Sized

Implementation of ByRef

impl<T> ByRef<T> for T

Implementation of CastableFrom

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT where ST: ?Sized, DT: ?Sized

Implementation of CastableFrom

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT where ST: ?Sized, DT: ?Sized

Implementation of CloneToUninit

impl<T> CloneToUninit for T where T: Clone

Implementation of From

impl<T> From<T> for T

Implementation of Imply

impl<T, U> Imply<T> for U where T: ?Sized, U: ?Sized

Implementation of Into

impl<T, U> Into<U> for T where U: From<T>

Implementation of IntoEither

impl<T> IntoEither for T

Implementation of Pointable

impl<T> Pointable for T

Implementation of Read

impl<T> Read<Exclusive, BecauseExclusive> for T where T: ?Sized

Implementation of Same

impl<T> Same for T

Implementation of SupersetOf

impl<SS, SP> SupersetOf<SS> for SP where SS: SubsetOf<SP>

Implementation of ToOwned

impl<T> ToOwned for T where T: Clone

Implementation of TryFrom

impl<T, U> TryFrom<U> for T where U: Into<T>

Implementation of TryInto

impl<T, U> TryInto<U> for T where U: TryFrom<T>