Shrinkage

shrinkage::HybridCoordinateDescent

Shrinkage for Rust · rust · 0.3.0

pub struct HybridCoordinateDescent<V = Vec<f64>>

Coordinate descent with periodic proximal-gradient steps for clustered lasso, chain fused lasso, and SLOPE with Gaussian or logistic loss.

Begin with a PG transition on the working set, then alternate five cluster sweeps with one PG transition. PG can split zero and nonzero blocks; CD moves entire exact-equality blocks and merges exact ties. Only a fresh full-space PG mapping, including the intercept derivative, certifies convergence. Diagnostic calls never advance or alter the iteration. Chain blocks are contiguous segments, with zero-weight edges kept as cuts. SLOPE blocks group exact magnitudes while retaining individual signs. Its zero block stays fixed during sweeps and can reactivate through full PG. Binomial problems use IRLS with weighted hybrid inner solves and Armijo backtracking on the original objective. Only the original-loss mapping certifies logistic convergence. Predictions remain linear predictors. Dynamic Gap Safe zero screening is enabled by default. Restrictions retain the complete original penalty, and certificates always use the original loss. Working sets are independently enabled through Self::working_set_policy. Disable both restrictions for complete matrix sweeps.

V is the backend's native vector, as for crate::ProximalGradient. Aggregates use dense storage: O(n * K + p + n) for K clusters, retaining buffers at their high-water capacities. Staging a PG rebuild retains both old and candidate aggregates. No normalized design or Gram is formed.

use faer::{Col, Mat};
use shrinkage::{ClusteredLasso, Gaussian, HybridCoordinateDescent, Problem};
let x = Mat::from_fn(4, 2, |i, j| ((i + 2 * j) % 3) as f64);
let fit = Problem::new(&x, Gaussian::new(&[1.0, 2.0, 0.0, 3.0]),
    ClusteredLasso::new(0.1, 0.2))
    .fit_with(&HybridCoordinateDescent::<Col<f64>>::new())?;
let predictions = fit.predict(&x)?;

Inherent implementation

impl<V> HybridCoordinateDescent<V>

check_every

pub fn check_every(self, count: usize) -> Self

Check every positive number of iterations, also initially and at budget.

cluster_sweeps

pub fn cluster_sweeps(self, count: usize) -> Self

Set the positive number of complete sweeps between PG transitions.

max_inner_iterations

pub fn max_inner_iterations(self, count: usize) -> Self

Limit PG transitions plus sweeps per logistic quadratic model (default 1,000). Inexact models can still provide accepted descent directions. Gaussian fits ignore this limit. The total max_iterations also applies.

max_iterations

pub fn max_iterations(self, count: usize) -> Self

Limit the total number of committed PG transitions and complete sweeps. Logistic fits share this budget across all quadratic subproblems.

max_outer_backtracks

pub fn max_outer_backtracks(self, count: usize) -> Self

Limit logistic step halvings after the full trial (default 100). This differs from curvature backtracking in HybridStep.

max_outer_iterations

pub fn max_outer_iterations(self, count: usize) -> Self

Limit accepted logistic IRLS steps (default 100). Gaussian fits ignore it.

new

pub fn new() -> Self

Use mapping tolerance 1e-6, 10,000 iterations, five sweeps per PG, checks every ten iterations, backtracking, and safe zero screening. Logistic fits allow 100 outer steps, 1,000 inner iterations per model, and 100 step halvings.

screening

pub fn screening(self, enabled: bool) -> Self

Enable dynamic Gap Safe zero screening, enabled by default. Certificates and stopping checks use the original loss and full design. Logistic quadratic models retain restrictions certified at outer iterates.

step_policy

pub fn step_policy(self, step: HybridStep) -> Self

Select backtracking or a computed fixed curvature upper bound.

terminate_on

pub fn terminate_on(self, criterion: StoppingCriterion) -> Self

Select a stopping rule. Only absolute PG mapping is supported.

tolerance

pub fn tolerance(self, absolute: f64) -> Self

Set the absolute infinity-norm full PG mapping tolerance.

working_set_policy

pub fn working_set_policy(self, policy: WorkingSetPolicy) -> Self

Select the working-set policy. The last working-set setter wins.

working_sets

pub fn working_sets(self, enabled: bool) -> Self

Enable automatic working sets, or disable heuristic restrictions.

Implementation of Clone

impl<V: core::clone::Clone> Clone for HybridCoordinateDescent<V>

clone

fn clone(&self) -> Self

Implementation of Copy

impl<V: core::marker::Copy> Copy for HybridCoordinateDescent<V>

Implementation of Debug

impl<V: core::fmt::Debug> Debug for HybridCoordinateDescent<V>

fmt

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

Implementation of Default

impl<V> Default for HybridCoordinateDescent<V>

default

fn default() -> Self

Implementation of ObservedSolver

impl<M, V, P> ObservedSolver<Problem<&M, Binomial<'_>, P>> for HybridCoordinateDescent<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, V: ProximalVector, P: ReducedCoordinatePenalty

Implementation of ObservedSolver

impl<M, V> ObservedSolver<Problem<&M, Gaussian<'_>, ChainFusedLasso>> for HybridCoordinateDescent<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, V: ProximalVector

Implementation of ObservedSolver

impl<M, V> ObservedSolver<Problem<&M, Gaussian<'_>, ClusteredLasso>> for HybridCoordinateDescent<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, V: ProximalVector

Implementation of ObservedSolver

impl<M, V> ObservedSolver<Problem<&M, Gaussian<'_>, Slope>> for HybridCoordinateDescent<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, V: ProximalVector

Implementation of PathSolver

impl<D: SmoothDatafit, P, Q: shrinkage::ProximalPenalty, V> PathSolver<Problem<Box<dyn RuntimeDesign + '_>, D, P>, Q> for HybridCoordinateDescent<V>

Implementation of PathSolver

impl<M, D, P, Q, V> PathSolver<Problem<&M, D, P>, Q> for HybridCoordinateDescent<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, D: HybridPathDatafit, Q: ReducedCoordinatePenalty, V: ProximalVector

Implementation of RegularizationPathSolver

impl<D: shrinkage::PathDatafit, P: PathPenalty, V> RegularizationPathSolver<Problem<Box<dyn RuntimeDesign + '_>, D, P>> for HybridCoordinateDescent<V>

Implementation of RegularizationPathSolver

impl<M, D, P, V> RegularizationPathSolver<Problem<&M, D, P>> for HybridCoordinateDescent<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, D: HybridPathDatafit, P: PathPenalty, <P as PathPenalty>::AtStrength: ReducedCoordinatePenalty, V: ProximalVector

Implementation of Solver

impl<M, V, P> Solver<Problem<&M, Binomial<'_>, P>> for HybridCoordinateDescent<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, V: ProximalVector, P: ReducedCoordinatePenalty

Implementation of Solver

impl<M, V> Solver<Problem<&M, Gaussian<'_>, ChainFusedLasso>> for HybridCoordinateDescent<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, V: ProximalVector

Implementation of Solver

impl<M, V> Solver<Problem<&M, Gaussian<'_>, ClusteredLasso>> for HybridCoordinateDescent<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, V: ProximalVector

Implementation of Solver

impl<M, V> Solver<Problem<&M, Gaussian<'_>, Slope>> for HybridCoordinateDescent<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, V: ProximalVector

Implementation of Solver

impl<V> Solver<Problem<Box<dyn RuntimeDesign + '_>, Box<dyn SmoothDatafit<Error = FitError> + '_>, Box<dyn ProximalPenalty<Error = FitError> + '_>>> for HybridCoordinateDescent<V>

Implementation of Freeze

impl<V> Freeze for HybridCoordinateDescent<V> where PhantomData<V>: Freeze

Implementation of RefUnwindSafe

impl<V> RefUnwindSafe for HybridCoordinateDescent<V> where PhantomData<V>: RefUnwindSafe

Implementation of Send

impl<V> Send for HybridCoordinateDescent<V> where PhantomData<V>: Send

Implementation of Sync

impl<V> Sync for HybridCoordinateDescent<V> where PhantomData<V>: Sync

Implementation of Unpin

impl<V> Unpin for HybridCoordinateDescent<V> where PhantomData<V>: Unpin

Implementation of UnsafeUnpin

impl<V> UnsafeUnpin for HybridCoordinateDescent<V> where PhantomData<V>: UnsafeUnpin

Implementation of UnwindSafe

impl<V> UnwindSafe for HybridCoordinateDescent<V> where PhantomData<V>: UnwindSafe

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>