Shrinkage

shrinkage::Irls

Shrinkage for Rust · rust · 0.3.0

pub struct Irls

Iteratively reweighted least squares with coordinate-descent inner solves.

Fits differentiable losses with nonnegative diagonal working curvature and separable convex penalties. For nonconvex losses, KKT checks certify stationarity rather than global optimality. Backtracking evaluates the original penalized objective. The quadratic model floors predictor curvature at 1e-12 / nobs, leaving the original loss, gradient, and convergence check unchanged. Working sets use restricted checks between complete KKT checks. No safe screening or dual certificate is provided.

Solver workspace is O(nobs + nfeatures). Weighted column norms use LazyMatrix's O(nobs + nnz) operation once per column per outer iteration. Noncanonical sparse columns can require temporary O(nobs) scratch there.

use faer::Mat;
use shrinkage::{Binomial, Irls, L1, Problem};
let x = Mat::from_fn(4, 1, |i, _| i as f64);
let y = [0.0, 0.0, 1.0, 1.0];
let fit = Problem::new(&x, Binomial::new(&y), L1::new(0.1))
    .fit_with(&Irls::new())?;
let logits = fit.predict(&x)?;

Inherent implementation

impl Irls

max_backtracks

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

Set the maximum number of halvings after the initial full-step trial.

max_inner_iterations

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

Set the strictly positive sweep limit for each quadratic model. An inexact inner solve may still supply an accepted descent direction.

max_iterations

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

Set the strictly positive maximum number of accepted outer steps.

new

pub fn new() -> Self

Use KKT tolerance 1e-6, 100 outer iterations, 1,000 inner sweeps per outer iteration, at most 100 step halvings, and working sets.

terminate_on

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

Select a stopping rule. Only absolute KKT violation is supported.

tolerance

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

Set the finite, strictly positive absolute KKT 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. The last working-set setter wins.

Implementation of Clone

impl Clone for Irls

clone

fn clone(&self) -> Self

Implementation of Copy

impl Copy for Irls

Implementation of Debug

impl Debug for Irls

fmt

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

Implementation of Default

impl Default for Irls

default

fn default() -> Self

Implementation of ObservedSolver

impl<M, D, P> ObservedSolver<Problem<&M, D, P>> for Irls where M: RawColumns<f64> + ColumnStats<f64> + ?Sized, D: QuadraticModelDatafit, P: CoordinatePenalty

Implementation of PathSolver

impl<M, D, P, Q> PathSolver<Problem<&M, D, P>, Q> for shrinkage::Irls where M: RawColumns<f64> + ColumnStats<f64> + ?Sized, D: QuadraticModelDatafit, Q: CoordinatePenalty

Implementation of RegularizationPathSolver

impl<M, D, P> RegularizationPathSolver<Problem<&M, D, P>> for shrinkage::Irls where M: RawColumns<f64> + ColumnStats<f64> + ?Sized, D: QuadraticModelDatafit + NullModelDatafit, P: PathPenalty, <P as PathPenalty>::AtStrength: CoordinatePenalty

Implementation of Solver

impl<M, D, P> Solver<Problem<&M, D, P>> for Irls where M: RawColumns<f64> + ColumnStats<f64> + ?Sized, D: QuadraticModelDatafit, P: CoordinatePenalty

Implementation of Freeze

impl Freeze for Irls

Implementation of RefUnwindSafe

impl RefUnwindSafe for Irls

Implementation of Send

impl Send for Irls

Implementation of Sync

impl Sync for Irls

Implementation of Unpin

impl Unpin for Irls

Implementation of UnsafeUnpin

impl UnsafeUnpin for Irls

Implementation of UnwindSafe

impl UnwindSafe for Irls

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>