pub struct Lasso { /* private fields */ }Expand description
Lasso regression with an unpenalised intercept, fitted by cyclic coordinate descent.
Minimises 1/(2n)·‖y − b − Xw‖² + α‖w‖₁, the same objective as
scikit-learn’s Lasso(alpha=α). The classic DML learner for
high-dimensional confounders.
Implementations§
Source§impl Lasso
impl Lasso
pub fn new(alpha: f64) -> Self
Sourcepub fn tol(self, tol: f64) -> Self
pub fn tol(self, tol: f64) -> Self
Stopping rule of scikit-learn’s Lasso(tol=tol) (default 1e-4): once
no coefficient moves by more than tol · max|w| in a sweep, stop if the
duality gap, which bounds the distance to the optimal objective, is at
most tol · ‖y − ȳ‖² / n. With α = 0 only the first condition applies.
pub fn max_iter(self, max_iter: usize) -> Self
pub fn coef(&self) -> Option<&Array1<f64>>
pub fn intercept(&self) -> f64
Trait Implementations§
Source§impl Regressor for Lasso
impl Regressor for Lasso
Source§fn fit_weighted(
&mut self,
x: ArrayView2<'_, f64>,
y: ArrayView1<'_, f64>,
w: ArrayView1<'_, f64>,
) -> Result<()>
fn fit_weighted( &mut self, x: ArrayView2<'_, f64>, y: ArrayView1<'_, f64>, w: ArrayView1<'_, f64>, ) -> Result<()>
Minimises 1/(2n)·Σ wᵢ rᵢ² + α‖β‖₁ with weights rescaled to sum to
n, as scikit-learn’s Lasso.fit(sample_weight=w).
fn fit(&mut self, x: ArrayView2<'_, f64>, y: ArrayView1<'_, f64>) -> Result<()>
fn predict(&self, x: ArrayView2<'_, f64>) -> Result<Array1<f64>>
fn fresh(&self) -> Box<dyn Regressor>
Auto Trait Implementations§
impl Freeze for Lasso
impl RefUnwindSafe for Lasso
impl Send for Lasso
impl Sync for Lasso
impl Unpin for Lasso
impl UnsafeUnpin for Lasso
impl UnwindSafe for Lasso
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more