pub struct LassoCV { /* private fields */ }Expand description
Lasso with the penalty chosen by K-fold cross-validation, as
scikit-learn’s LassoCV.
The candidate penalties are n_alphas values evenly spaced on a log scale
from α_max = max_j |x̃_jᵀ ỹ| / n (the smallest penalty giving an
all-zero solution) down to eps · α_max. For each fold the whole path is
fitted with warm starts, the penalty with the lowest mean test MSE is
chosen, and the Lasso is refitted on all the data. Folds are contiguous
blocks (scikit-learn’s default KFold without shuffling), so results
reproduce LassoCV(cv=5).
Implementations§
Source§impl LassoCV
impl LassoCV
Sourcepub fn eps(self, eps: f64) -> Self
pub fn eps(self, eps: f64) -> Self
Ratio of the smallest to the largest penalty on the automatic grid.
Sourcepub fn alphas(self, alphas: Vec<f64>) -> Self
pub fn alphas(self, alphas: Vec<f64>) -> Self
Explicit candidate penalties instead of the automatic grid.
Sourcepub fn tol(self, tol: f64) -> Self
pub fn tol(self, tol: f64) -> Self
Coordinate-descent tolerance, as Lasso::tol.
pub fn max_iter(self, max_iter: usize) -> Self
Sourcepub fn alphas_path(&self) -> Option<&[f64]>
pub fn alphas_path(&self) -> Option<&[f64]>
The candidate penalties, in decreasing order.
Sourcepub fn mse_path(&self) -> Option<&Array2<f64>>
pub fn mse_path(&self) -> Option<&Array2<f64>>
Test MSE of every penalty on every fold, shape (n_alphas, cv).
pub fn coef(&self) -> Option<&Array1<f64>>
pub fn intercept(&self) -> f64
Trait Implementations§
Source§impl Regressor for LassoCV
impl Regressor for LassoCV
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<()>
Weighted fits and weighted test MSEs, as LassoCV.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 LassoCV
impl RefUnwindSafe for LassoCV
impl Send for LassoCV
impl Sync for LassoCV
impl Unpin for LassoCV
impl UnsafeUnpin for LassoCV
impl UnwindSafe for LassoCV
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
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> ⓘ
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> ⓘ
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