pub struct MultiTaskElasticNet<F> {
pub alpha: F,
pub l1_ratio: F,
pub fit_intercept: bool,
pub max_iter: usize,
pub tol: F,
}Expand description
Multi-task ElasticNet regression (joint multi-output L1/L2,1-regularized least squares).
Fits all target columns jointly under a blended group-Lasso (L2,1) +
squared-Frobenius (L2) penalty. Mirrors
sklearn.linear_model.MultiTaskElasticNet
(_coordinate_descent.py:402). MultiTaskLasso is
MultiTaskElasticNet(l1_ratio=1.0).
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§alpha: FRegularization strength scaling both penalty terms. Larger values specify stronger regularization.
l1_ratio: FElasticNet mixing parameter in [0, 1]. l1_ratio = 1 is the pure
L2,1 (group-Lasso) MultiTaskLasso; l1_ratio = 0 is a pure L2
(squared-Frobenius) penalty; intermediate values blend both.
fit_intercept: boolWhether to fit a per-task intercept (bias) term.
max_iter: usizeMaximum number of block-coordinate-descent iterations.
tol: FConvergence tolerance on the relative coefficient change / dual gap.
Implementations§
Source§impl<F: Float> MultiTaskElasticNet<F>
impl<F: Float> MultiTaskElasticNet<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new MultiTaskElasticNet with default settings.
Defaults: alpha = 1.0, l1_ratio = 0.5, fit_intercept = true,
max_iter = 1000, tol = 1e-4 — mirroring sklearn’s ctor defaults
MultiTaskElasticNet(alpha=1.0, l1_ratio=0.5, fit_intercept=True, max_iter=1000, tol=1e-4) (_coordinate_descent.py:402).
Sourcepub fn with_alpha(self, alpha: F) -> Self
pub fn with_alpha(self, alpha: F) -> Self
Set the regularization strength.
Sourcepub fn with_l1_ratio(self, l1_ratio: F) -> Self
pub fn with_l1_ratio(self, l1_ratio: F) -> Self
Set the ElasticNet mixing parameter (l1_ratio in [0, 1]).
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.
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 iterations.
Trait Implementations§
Source§impl<F: Clone> Clone for MultiTaskElasticNet<F>
impl<F: Clone> Clone for MultiTaskElasticNet<F>
Source§fn clone(&self) -> MultiTaskElasticNet<F>
fn clone(&self) -> MultiTaskElasticNet<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 MultiTaskElasticNet<F>
impl<F: Debug> Debug for MultiTaskElasticNet<F>
Source§impl<F: Float> Default for MultiTaskElasticNet<F>
impl<F: Float> Default for MultiTaskElasticNet<F>
Source§impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for MultiTaskElasticNet<F>
impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for MultiTaskElasticNet<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array2<F>,
) -> Result<FittedMultiTaskElasticNet<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array2<F>, ) -> Result<FittedMultiTaskElasticNet<F>, FerroError>
Fit the multi-task ElasticNet model using block coordinate descent.
Ports sklearn’s enet_coordinate_descent_multi_task
(_cd_fast.pyx:740) with l1_reg = alpha * l1_ratio * n_samples and
l2_reg = alpha * (1 - l1_ratio) * n_samples
(_coordinate_descent.py:655-656).
§Errors
Returns FerroError::ShapeMismatch if Y.nrows() differs from the
number of samples in X.
Returns FerroError::InvalidParameter if alpha is negative or
l1_ratio is outside [0, 1].
Returns FerroError::InsufficientSamples if there are no samples.
Returns FerroError::NumericalInstability if a required float constant
or column mean cannot be formed.
Source§type Fitted = FittedMultiTaskElasticNet<F>
type Fitted = FittedMultiTaskElasticNet<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Auto Trait Implementations§
impl<F> Freeze for MultiTaskElasticNet<F>where
F: Freeze,
impl<F> RefUnwindSafe for MultiTaskElasticNet<F>where
F: RefUnwindSafe,
impl<F> Send for MultiTaskElasticNet<F>where
F: Send,
impl<F> Sync for MultiTaskElasticNet<F>where
F: Sync,
impl<F> Unpin for MultiTaskElasticNet<F>where
F: Unpin,
impl<F> UnsafeUnpin for MultiTaskElasticNet<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for MultiTaskElasticNet<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