pub struct MultiTaskElasticNetCV<F> { /* private fields */ }Expand description
Multi-task ElasticNet regression with built-in cross-validation for joint
(alpha, l1_ratio) selection.
For each candidate l1_ratio, generates a log-spaced alpha grid (from the
L21 dual-norm alpha_max down to alpha_max * 1e-3), runs k-fold CV fitting
a MultiTaskElasticNet per fold, and selects the combination minimizing
the mean held-out MSE (averaged over samples and tasks).
Mirrors sklearn.linear_model.MultiTaskElasticNetCV
(_coordinate_descent.py:2806).
§Type Parameters
F: The floating-point type (f32orf64).
Implementations§
Source§impl<F: Float + FromPrimitive> MultiTaskElasticNetCV<F>
impl<F: Float + FromPrimitive> MultiTaskElasticNetCV<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new MultiTaskElasticNetCV with default settings.
Defaults mirror sklearn.linear_model.MultiTaskElasticNetCV.__init__
(_coordinate_descent.py:2989-3018), which fixes a single
l1_ratio=0.5:
l1_ratios = [0.5]n_alphas = 100cv = 5max_iter = 1000tol = 1e-4fit_intercept = true
Use with_l1_ratios to search a grid of
mixing ratios.
Sourcepub fn with_l1_ratios(self, l1_ratios: Vec<F>) -> Self
pub fn with_l1_ratios(self, l1_ratios: Vec<F>) -> Self
Set the candidate L1/L2 mixing ratios. Each value must be in [0, 1].
Sourcepub fn with_n_alphas(self, n_alphas: usize) -> Self
pub fn with_n_alphas(self, n_alphas: usize) -> Self
Set the number of alphas generated per l1_ratio.
Sourcepub fn with_cv(self, cv: usize) -> Self
pub fn with_cv(self, cv: usize) -> Self
Set the number of cross-validation folds (must be at least 2).
Sourcepub fn with_max_iter(self, max_iter: usize) -> Self
pub fn with_max_iter(self, max_iter: usize) -> Self
Set the maximum number of block-coordinate-descent iterations.
Sourcepub fn with_fit_intercept(self, fit_intercept: bool) -> Self
pub fn with_fit_intercept(self, fit_intercept: bool) -> Self
Set whether to fit per-task intercept terms.
Trait Implementations§
Source§impl<F: Clone> Clone for MultiTaskElasticNetCV<F>
impl<F: Clone> Clone for MultiTaskElasticNetCV<F>
Source§fn clone(&self) -> MultiTaskElasticNetCV<F>
fn clone(&self) -> MultiTaskElasticNetCV<F>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Debug> Debug for MultiTaskElasticNetCV<F>
impl<F: Debug> Debug for MultiTaskElasticNetCV<F>
Source§impl<F: Float + FromPrimitive> Default for MultiTaskElasticNetCV<F>
impl<F: Float + FromPrimitive> Default for MultiTaskElasticNetCV<F>
Source§impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for MultiTaskElasticNetCV<F>
impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for MultiTaskElasticNetCV<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array2<F>,
) -> Result<FittedMultiTaskElasticNetCV<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array2<F>, ) -> Result<FittedMultiTaskElasticNetCV<F>, FerroError>
Fit the MultiTaskElasticNetCV model.
For each candidate l1_ratio, generates the L21 alpha grid, runs k-fold
CV for every (alpha, l1_ratio) pair (fitting a MultiTaskElasticNet
per train fold and scoring held-out MSE), then refits on the full data
using the best combination. Mirrors LinearModelCV.fit
(_coordinate_descent.py:1552-1837).
§Errors
FerroError::ShapeMismatchifY.nrows()differs from the number of samples inX.FerroError::InvalidParameterifl1_ratiosis empty, any ratio is outside[0, 1], an auto-gridl1_ratiois0,cv < 2,n_alphas == 0, or X/Y contains NaN/infinity.FerroError::InsufficientSamplesifn_samples < cv.
Source§type Fitted = FittedMultiTaskElasticNetCV<F>
type Fitted = FittedMultiTaskElasticNetCV<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Auto Trait Implementations§
impl<F> Freeze for MultiTaskElasticNetCV<F>where
F: Freeze,
impl<F> RefUnwindSafe for MultiTaskElasticNetCV<F>where
F: RefUnwindSafe,
impl<F> Send for MultiTaskElasticNetCV<F>where
F: Send,
impl<F> Sync for MultiTaskElasticNetCV<F>where
F: Sync,
impl<F> Unpin for MultiTaskElasticNetCV<F>where
F: Unpin,
impl<F> UnsafeUnpin for MultiTaskElasticNetCV<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for MultiTaskElasticNetCV<F>where
F: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
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