Shrinkage

shrinkage::ProximalGradient

Shrinkage for Rust · rust · 0.3.0

pub struct ProximalGradient<V = Vec<f64>>

Proximal gradient with backtracking for convex smooth predictor losses and complete convex proximal penalties.

V is the design backend's owned vector: faer::Col<f64>, nalgebra::DVector<f64>, ndarray::Array1<f64>, or Vec<f64> for sprs. No normalized design or Gram matrix is formed. LazyMatrix centers dense products before accumulation. Its generic scaled forward product still clones the input when the backend does not specialize normalization. crate::MultivariateGaussian with crate::AxisPenalty fits joint matrix coefficients and response-specific unpenalized intercepts through the same iteration, returning crate::MultivariateFit.

use faer::{Col, Mat};
use shrinkage::{Gaussian, Problem, ProximalGradient, Ridge};
let x = Mat::from_fn(3, 1, |i, _| i as f64);
let y = [1.0, 3.0, 5.0];
let fit = Problem::new(&x, Gaussian::new(&y), Ridge::new(0.1))
    .fit_with(&ProximalGradient::<Col<f64>>::new())?;
let predictions = fit.predict(&x)?;

Inherent implementation

impl shrinkage::ProximalGradient<Vec<f64>>

solve_runtime_path

pub fn solve_runtime_path(
    &self,
    problem: &RuntimeProblem<'_>,
    penalties: &[Box<dyn ProximalPenalty + '_>]
) -> Result<Vec<ProximalFit>, FitError<BackendError>>

Fit runtime-selected penalties in order with one prepared design.

Reuses native products and iteration storage and warms each point from the preceding optimization-scale parameters. The problem's penalty is replaced by the path entries. Steps and iteration budgets reset at each point; iteration-limit fits are retained as warm starts.

Errors

Returns validation or fitting errors without a partial path.

Inherent implementation

impl<V> ProximalGradient<V>

initial_step

pub fn initial_step(self, step: f64) -> Self

Set a finite positive initial step, halved until the smooth loss obeys its quadratic upper bound. Accepted steps are retained across iterations.

max_backtracks

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

Set the maximum number of step halvings for each line search.

max_iterations

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

Set the maximum number of accepted proximal updates.

new

pub fn new() -> Self

Use an absolute mapping tolerance of 1e-6, 10,000 iterations, initial step one, and at most 100 step halvings per iteration.

screening

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

Enable dynamic Gap Safe zero screening when every component supports it.

Enabled by default. Certificates use the original loss and penalty; unsupported compositions retain ordinary proximal-gradient fitting.

solve_path

pub fn solve_path<M, D, P, Q>(
    &self,
    problem: &Problem<&M, D, P>,
    penalties: &[Q]
) -> Result<Vec<ProximalFit>, FitError<<M as >::Error>> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, D: SmoothDatafit, Q: ProximalPenalty, V: ProximalVector

Fit penalties in the supplied order, preparing the design once.

The problem's penalty is replaced by each path entry. Native product buffers and iteration storage are reused; each point starts from the preceding optimization-scale coefficients and intercept. Each point resets its step and iteration budget. Results own independent parameters and preprocessing. An empty path returns no fits.

Errors

Returns validation, component, line-search, or backend errors without returning a partial path. Iteration-limit results remain in the path and provide the next warm start.

terminate_on

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

Select a criterion. This solver supports proximal-gradient mapping only.

tolerance

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

Set the absolute infinity-norm proximal-gradient mapping tolerance.

Implementation of Clone

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

clone

fn clone(&self) -> Self

Implementation of Copy

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

Implementation of Debug

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

fmt

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

Implementation of Default

impl<V> Default for ProximalGradient<V>

default

fn default() -> Self

Implementation of ObservedSolver

impl<M, D, P, V> ObservedSolver<Problem<&M, D, P>> for ProximalGradient<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, D: SmoothDatafit, P: ProximalPenalty, V: ProximalVector

Implementation of PathSolver

impl<D, P, Q> PathSolver<Problem<Box<dyn RuntimeDesign + '_>, D, P>, Q> for shrinkage::ProximalGradient<Vec<f64>> where D: SmoothDatafit, Q: ProximalPenalty

Implementation of PathSolver

impl<M, D, P, Q, V> PathSolver<Problem<&M, D, P>, Q> for shrinkage::ProximalGradient<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, D: SmoothDatafit, Q: ProximalPenalty, V: ProximalVector

Implementation of PathSolver

impl<M, P, Q, V> PathSolver<Problem<&M, MultivariateGaussian<'_>, AxisPenalty<P>>, AxisPenalty<Q>> for shrinkage::ProximalGradient<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, Q: ProximalPenalty, V: ProximalVector

Implementation of PathSolver

impl<P, Q: ProximalPenalty> PathSolver<Problem<Box<dyn RuntimeDesign + '_>, MultivariateGaussian<'_>, AxisPenalty<P>>, AxisPenalty<Q>> for shrinkage::ProximalGradient<Vec<f64>>

Implementation of RegularizationPathSolver

impl<D, P> RegularizationPathSolver<Problem<Box<dyn RuntimeDesign + '_>, D, P>> for shrinkage::ProximalGradient<Vec<f64>> where D: SmoothDatafit + NullModelDatafit, P: PathPenalty

Implementation of RegularizationPathSolver

impl<M, D, P, V> RegularizationPathSolver<Problem<&M, D, P>> for shrinkage::ProximalGradient<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, D: SmoothDatafit + NullModelDatafit, P: PathPenalty, V: ProximalVector

Implementation of RegularizationPathSolver

impl<M, P, V> RegularizationPathSolver<Problem<&M, MultivariateGaussian<'_>, AxisPenalty<P>>> for shrinkage::ProximalGradient<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, P: PathPenalty, V: ProximalVector

Implementation of RegularizationPathSolver

impl<P: PathPenalty> RegularizationPathSolver<Problem<Box<dyn RuntimeDesign + '_>, MultivariateGaussian<'_>, AxisPenalty<P>>> for shrinkage::ProximalGradient<Vec<f64>>

Implementation of Solver

impl<D: SmoothDatafit, P: ProximalPenalty> Solver<Problem<Box<dyn RuntimeDesign + '_>, D, P>> for shrinkage::ProximalGradient<Vec<f64>>

Implementation of Solver

impl<M, D, P, V> Solver<Problem<&M, D, P>> for ProximalGradient<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, D: SmoothDatafit, P: ProximalPenalty, V: ProximalVector

Implementation of Solver

impl<M, P, V> Solver<Problem<&M, MultivariateGaussian<'_>, AxisPenalty<P>>> for shrinkage::ProximalGradient<V> where M: RawColumns<f64> + ColumnStats<f64> + MatVecInto<V> + MatTransposeVecInto<V> + ?Sized, P: ProximalPenalty, V: ProximalVector

Implementation of Solver

impl<P: ProximalPenalty> Solver<Problem<Box<dyn RuntimeDesign + '_>, MultivariateGaussian<'_>, AxisPenalty<P>>> for shrinkage::ProximalGradient<Vec<f64>>

Implementation of Freeze

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

Implementation of RefUnwindSafe

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

Implementation of Send

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

Implementation of Sync

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

Implementation of Unpin

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

Implementation of UnsafeUnpin

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

Implementation of UnwindSafe

impl<V> UnwindSafe for ProximalGradient<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>