Shrinkage

shrinkage::RestrictedProximalPenalty

Shrinkage for Rust · rust · 0.3.0

pub trait RestrictedProximalPenalty: ProximalPenalty

A convex penalty with an exact proximal map after excluding coordinates.

Each true entry in unpenalized excludes the corresponding coefficient. The restricted value equals the complete penalty evaluated with those coordinates set to zero. Its proximal map minimizes ||z - input||² / (2 * step) + self.value_restricted(z, unpenalized) and copies excluded inputs unchanged. Masks have one entry per coefficient.

A complete proximal map alone does not imply this capability. In particular, restoring excluded inputs after a coupled proximal map is generally wrong. External penalties must implement the restricted problem explicitly.

Methods

prox_restricted

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

Write the exact restricted proximal minimizer into reusable storage.

Errors

Reject invalid parameters, nonpositive or nonfinite steps, mismatched input, output, or mask lengths, nonfinite input (including excluded coordinates), or nonfinite arithmetic. Output is unspecified on error.

validate_restricted_input

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

Validate coefficients and a restriction without evaluating its value.

The default checks mask length and calls Penalty::validate_input on the complete coefficients. Override it if restriction changes input compatibility or if complete validation performs unused value arithmetic. This check must still reject invalid parameters and nonfinite excluded coefficients, including when an outer super::Scaled has zero scale.

Errors

Reject invalid parameters, coefficients, or mask lengths.

value_restricted

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

Evaluate the penalty with excluded coordinates set to zero.

Errors

Reject invalid parameters, mismatched mask lengths, nonfinite coefficients (including excluded ones), or nonfinite arithmetic.

Implementation of RestrictedProximalPenalty

impl RestrictedProximalPenalty for shrinkage::ElasticNet

Implementation of RestrictedProximalPenalty

impl RestrictedProximalPenalty for shrinkage::L1

Implementation of RestrictedProximalPenalty

impl RestrictedProximalPenalty for shrinkage::Ridge

Implementation of RestrictedProximalPenalty

impl<P: RestrictedProximalPenalty> RestrictedProximalPenalty for Scaled<P>