#[non_exhaustive]pub enum Penalty {
None,
L1,
L2,
ElasticNet(f64),
}Expand description
Regularization penalty for logistic regression.
Controls the type of regularization applied during training:
None— no regularizationL1— Lasso penalty (promotes sparsity via proximal gradient descent)L2— Ridge penalty (default, shrinks coefficients)ElasticNet(l1_ratio)— Mix of L1 and L2;l1_ratio∈ [0, 1] where 1.0 = pure L1, 0.0 = pure L2
§Solver compatibility
| Penalty | GradientDescent | L-BFGS |
|---|---|---|
None | ✓ | ✓ |
L1 | ✓ | ✗ (error) |
L2 | ✓ | ✓ |
ElasticNet | ✓ | ✗ (error) |
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
None
No regularization.
L1
L1 (Lasso) penalty — promotes sparse coefficients.
L2
L2 (Ridge) penalty — shrinks all coefficients (default).
ElasticNet(f64)
Elastic Net — mix of L1 and L2. The f64 is the L1 ratio ∈ [0, 1].
Trait Implementations§
impl StructuralPartialEq for Penalty
Auto Trait Implementations§
impl Freeze for Penalty
impl RefUnwindSafe for Penalty
impl Send for Penalty
impl Sync for Penalty
impl Unpin for Penalty
impl UnsafeUnpin for Penalty
impl UnwindSafe for Penalty
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
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